Skip to content

Commit daceac1

Browse files
authored
feat: add @deprecation and @since docs (#246)
1 parent 6ec9a8f commit daceac1

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

metadata-generator/src/Meta/MetaEntities.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ struct Version {
6262
bool operator >=(const Version& other) const {
6363
return !(*this < other);
6464
}
65+
std::string toString() const {
66+
std::string result;
67+
if (Major >= 0) {
68+
result.append(std::to_string(Major));
69+
if (Minor >= 0) {
70+
result.append("." + std::to_string(Minor));
71+
if (SubMinor >= 0) {
72+
result.append("." + std::to_string(SubMinor));
73+
}
74+
}
75+
}
76+
return result;
77+
}
6578
};
6679

6780
enum MetaFlags : uint16_t {

metadata-generator/src/TypeScript/DocSetManager.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,39 @@ using namespace std;
9090

9191
std::string TSComment::toString(std::string linePrefix)
9292
{
93-
if (description.length() == 0 && params.size() == 0) {
93+
if (description.length() == 0 && params.size() == 0 && deprecatedIn.isUnknown() && introducedIn.isUnknown()) {
9494
return std::string();
9595
}
9696

9797
std::stringstream result;
9898
result << linePrefix << "/**" << std::endl;
9999
std::string processedDesc = description;
100100
findAndReplaceIn(processedDesc, "\n", "");
101-
result << linePrefix << " * " << processedDesc << std::endl;
101+
if (processedDesc.length() > 0) {
102+
result << linePrefix << " * " << processedDesc << std::endl;
103+
}
102104
for (std::pair<std::string, std::string>& param : params) {
103105
// @param paramName - paramDesc
104106
result << linePrefix << " * "
105107
<< "@param " + param.first + " - " + param.second << std::endl;
106108
}
109+
if (!introducedIn.isUnknown()) {
110+
result << linePrefix << " * " << "@since " << introducedIn.toString() << std::endl;
111+
}
112+
if (!deprecatedIn.isUnknown()) {
113+
result << linePrefix << " * " << "@deprecated " << deprecatedIn.toString() << std::endl;
114+
}
107115
result << linePrefix << " */" << std::endl;
108116
return result.str();
109117
}
110118

111119
TSComment DocSetManager::getCommentFor(Meta::Meta* meta, Meta::Meta* parent)
112120
{
113-
return (parent == nullptr) ? getCommentFor(meta->name, meta->type) : getCommentFor(meta->name, meta->type, parent->name, parent->type);
121+
auto comment = (parent == nullptr) ? getCommentFor(meta->name, meta->type) : getCommentFor(meta->name, meta->type, parent->name, parent->type);
122+
comment.deprecatedIn = meta->deprecatedIn;
123+
comment.introducedIn = meta->introducedIn;
124+
comment.obsoletedIn = meta->obsoletedIn;
125+
return comment;
114126
}
115127

116128
TSComment DocSetManager::getCommentFor(std::string name, Meta::MetaType type, std::string parentName, Meta::MetaType parentType)

metadata-generator/src/TypeScript/DocSetManager.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ struct TSComment {
2121
* \brief A brief description of the symbol.
2222
*/
2323
std::string description;
24+
25+
Meta::Version introducedIn = UNKNOWN_VERSION;
26+
Meta::Version obsoletedIn = UNKNOWN_VERSION;
27+
Meta::Version deprecatedIn = UNKNOWN_VERSION;
2428

2529
/*
2630
* \brief An optional list of parameters. Useful in method and function comments.
@@ -74,4 +78,4 @@ class DocSetManager {
7478
};
7579
}
7680

77-
#endif //METADATAGENERATOR_DOCSETPARSER_H
81+
#endif //METADATAGENERATOR_DOCSETPARSER_H

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy