allow bookmaker methods to auto-populate
Adds
#Populate
as markup inside #Method, replacing
the method's description and #Param
and #Return. If present, this info
is retrieved from the include when
writing the web markdown and the
generated include.
TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=162820
Bug: skia:
Change-Id: I5df16f227b86651d463e03ddd33849bb127891c0
Reviewed-on: https://skia-review.googlesource.com/c/162820
Commit-Queue: Cary Clark <caryclark@skia.org>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp
index 4f841e4..52620f8 100644
--- a/tools/bookmaker/definition.cpp
+++ b/tools/bookmaker/definition.cpp
@@ -467,9 +467,11 @@
bool expectReturn = this->methodHasReturn(name, &methodParser);
bool foundReturn = false;
bool foundException = false;
+ bool foundPopulate = false;
for (auto& child : fChildren) {
foundException |= MarkType::kDeprecated == child->fMarkType
|| MarkType::kExperimental == child->fMarkType;
+ foundPopulate |= MarkType::kPopulate == child->fMarkType;
if (MarkType::kReturn != child->fMarkType) {
if (MarkType::kParam == child->fMarkType) {
child->fVisited = false;
@@ -484,7 +486,7 @@
}
foundReturn = true;
}
- if (expectReturn && !foundReturn && !foundException) {
+ if (expectReturn && !foundReturn && !foundException && !foundPopulate) {
return methodParser.reportError<bool>("missing #Return marker");
}
const char* paren = methodParser.strnchr('(', methodParser.fEnd);
@@ -518,7 +520,7 @@
foundParam = true;
}
- if (!foundParam && !foundException) {
+ if (!foundParam && !foundException && !foundPopulate) {
return methodParser.reportError<bool>("no #Param found");
}
if (')' == nextEnd[0]) {
@@ -587,7 +589,8 @@
priorDef = nullptr;
}
if (!descEnd) {
- return incomplete ? true : methodParser.reportError<bool>("missing description");
+ return incomplete || foundPopulate ? true :
+ methodParser.reportError<bool>("missing description");
}
TextParser description(fFileName, descStart, descEnd, fLineCount);
// expect first word capitalized and pluralized. expect a trailing period
@@ -891,7 +894,7 @@
return nullptr;
}
-const Definition* Definition::hasParam(string ref) const {
+Definition* Definition::hasParam(string ref) {
SkASSERT(MarkType::kMethod == fMarkType);
for (auto iter : fChildren) {
if (MarkType::kParam != iter->fMarkType) {
@@ -900,7 +903,18 @@
if (iter->fName == ref) {
return &*iter;
}
-
+ }
+ for (auto& iter : fTokens) {
+ if (MarkType::kComment != iter.fMarkType) {
+ continue;
+ }
+ TextParser parser(&iter);
+ if (!parser.skipExact("@param ")) {
+ continue;
+ }
+ if (parser.skipExact(ref.c_str())) {
+ return &iter;
+ }
}
return nullptr;
}