Skip to content

feat: add @deprecation and @since docs #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions metadata-generator/src/Meta/MetaEntities.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ struct Version {
bool operator >=(const Version& other) const {
return !(*this < other);
}
std::string toString() const {
std::string result;
if (Major >= 0) {
result.append(std::to_string(Major));
if (Minor >= 0) {
result.append("." + std::to_string(Minor));
if (SubMinor >= 0) {
result.append("." + std::to_string(SubMinor));
}
}
}
return result;
}
};

enum MetaFlags : uint16_t {
Expand Down
18 changes: 15 additions & 3 deletions metadata-generator/src/TypeScript/DocSetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,39 @@ using namespace std;

std::string TSComment::toString(std::string linePrefix)
{
if (description.length() == 0 && params.size() == 0) {
if (description.length() == 0 && params.size() == 0 && deprecatedIn.isUnknown() && introducedIn.isUnknown()) {
return std::string();
}

std::stringstream result;
result << linePrefix << "/**" << std::endl;
std::string processedDesc = description;
findAndReplaceIn(processedDesc, "\n", "");
result << linePrefix << " * " << processedDesc << std::endl;
if (processedDesc.length() > 0) {
result << linePrefix << " * " << processedDesc << std::endl;
}
for (std::pair<std::string, std::string>& param : params) {
// @param paramName - paramDesc
result << linePrefix << " * "
<< "@param " + param.first + " - " + param.second << std::endl;
}
if (!introducedIn.isUnknown()) {
result << linePrefix << " * " << "@since " << introducedIn.toString() << std::endl;
}
if (!deprecatedIn.isUnknown()) {
result << linePrefix << " * " << "@deprecated " << deprecatedIn.toString() << std::endl;
}
result << linePrefix << " */" << std::endl;
return result.str();
}

TSComment DocSetManager::getCommentFor(Meta::Meta* meta, Meta::Meta* parent)
{
return (parent == nullptr) ? getCommentFor(meta->name, meta->type) : getCommentFor(meta->name, meta->type, parent->name, parent->type);
auto comment = (parent == nullptr) ? getCommentFor(meta->name, meta->type) : getCommentFor(meta->name, meta->type, parent->name, parent->type);
comment.deprecatedIn = meta->deprecatedIn;
comment.introducedIn = meta->introducedIn;
comment.obsoletedIn = meta->obsoletedIn;
return comment;
}

TSComment DocSetManager::getCommentFor(std::string name, Meta::MetaType type, std::string parentName, Meta::MetaType parentType)
Expand Down
6 changes: 5 additions & 1 deletion metadata-generator/src/TypeScript/DocSetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ struct TSComment {
* \brief A brief description of the symbol.
*/
std::string description;

Meta::Version introducedIn = UNKNOWN_VERSION;
Meta::Version obsoletedIn = UNKNOWN_VERSION;
Meta::Version deprecatedIn = UNKNOWN_VERSION;

/*
* \brief An optional list of parameters. Useful in method and function comments.
Expand Down Expand Up @@ -74,4 +78,4 @@ class DocSetManager {
};
}

#endif //METADATAGENERATOR_DOCSETPARSER_H
#endif //METADATAGENERATOR_DOCSETPARSER_H
Loading