diff --git a/metadata-generator/src/Meta/MetaEntities.h b/metadata-generator/src/Meta/MetaEntities.h index 18709ead..1bacf55b 100644 --- a/metadata-generator/src/Meta/MetaEntities.h +++ b/metadata-generator/src/Meta/MetaEntities.h @@ -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 { diff --git a/metadata-generator/src/TypeScript/DocSetManager.cpp b/metadata-generator/src/TypeScript/DocSetManager.cpp index 13de5a52..bf28bdc8 100644 --- a/metadata-generator/src/TypeScript/DocSetManager.cpp +++ b/metadata-generator/src/TypeScript/DocSetManager.cpp @@ -90,7 +90,7 @@ 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(); } @@ -98,19 +98,31 @@ std::string TSComment::toString(std::string linePrefix) 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& 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) diff --git a/metadata-generator/src/TypeScript/DocSetManager.h b/metadata-generator/src/TypeScript/DocSetManager.h index 06cc2d41..2c146e02 100644 --- a/metadata-generator/src/TypeScript/DocSetManager.h +++ b/metadata-generator/src/TypeScript/DocSetManager.h @@ -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. @@ -74,4 +78,4 @@ class DocSetManager { }; } -#endif //METADATAGENERATOR_DOCSETPARSER_H \ No newline at end of file +#endif //METADATAGENERATOR_DOCSETPARSER_H