aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/bookmaker/mdOut.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-02-15 17:31:24 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-16 15:35:36 +0000
commit2a8c48be4ff65d873d9d5ba65ecef989d82dd0be (patch)
tree184c3941e072103ec71ae30363098d0f9e953443 /tools/bookmaker/mdOut.cpp
parent6848b716f7d51a2456535f9a1a5e1bed725fdd64 (diff)
improve bookmaker defines and references
generating replacement includes exposed errors mostly dealing with globals like SkAlphaType and members. Rewrite finding and resolving links to hopefully make this area more robust. TBR=caryclark@google.com Docs-Preview: https://skia.org/?cl=107160 Bug: skia:6898 Change-Id: I9b8025160203d204286f3f6ca0cebd70da6253b4 Reviewed-on: https://skia-review.googlesource.com/107160 Commit-Queue: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools/bookmaker/mdOut.cpp')
-rw-r--r--tools/bookmaker/mdOut.cpp67
1 files changed, 37 insertions, 30 deletions
diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp
index 77a370e156..c14ac23a43 100644
--- a/tools/bookmaker/mdOut.cpp
+++ b/tools/bookmaker/mdOut.cpp
@@ -569,8 +569,9 @@ const Definition* MdOut::isDefined(const TextParser& parser, const string& ref,
// try with a prefix
if ('k' == ref[0]) {
for (auto const& iter : fBmhParser.fEnumMap) {
- if (iter.second.find(ref, RootDefinition::AllowParens::kYes)) {
- return &iter.second;
+ auto def = iter.second.find(ref, RootDefinition::AllowParens::kYes);
+ if (def) {
+ return def;
}
}
if (fEnumClass) {
@@ -650,37 +651,41 @@ string MdOut::linkName(const Definition* ref) const {
// def should not include SkXXX_
string MdOut::linkRef(const string& leadingSpaces, const Definition* def,
const string& ref, BmhParser::Resolvable resolvable) const {
- string buildup;
+ string buildup;
+ string refName;
const string* str = &def->fFiddle;
SkASSERT(str->length() > 0);
- size_t under = str->find('_');
- const Definition* curRoot = fRoot;
- string classPart = string::npos != under ? str->substr(0, under) : *str;
- bool classMatch = curRoot->fName == classPart;
- while (curRoot->fParent) {
- curRoot = curRoot->fParent;
- classMatch |= curRoot->fName == classPart;
+ string classPart = *str;
+ bool globalEnumMember = false;
+ if (MarkType::kAlias == def->fMarkType) {
+ def = def->fParent;
+ SkASSERT(def);
+ SkASSERT(MarkType::kSubtopic == def->fMarkType ||MarkType::kTopic == def->fMarkType);
}
- const Definition* defRoot;
- const Definition* temp = def;
- do {
- defRoot = temp;
- if (!(temp = temp->fParent)) {
- break;
+ if (MarkType::kSubtopic == def->fMarkType) {
+ const Definition* topic = def->topicParent();
+ SkASSERT(topic);
+ classPart = topic->fName;
+ refName = def->fName;
+ } else if (MarkType::kTopic == def->fMarkType) {
+ refName = def->fName;
+ } else {
+ if ('k' == (*str)[0] && string::npos != str->find("_Sk")) {
+ globalEnumMember = true;
+ } else {
+ SkASSERT("Sk" == str->substr(0, 2) || "SK" == str->substr(0, 2)
+ // FIXME: kitchen sink catch below, need to do better
+ || string::npos != def->fFileName.find("undocumented"));
+ size_t under = str->find('_');
+ classPart = string::npos != under ? str->substr(0, under) : *str;
}
- classMatch |= temp != defRoot && temp->fName == classPart;
- } while (true);
- string namePart = string::npos != under ? str->substr(under + 1, str->length()) : *str;
+ refName = def->fFiddle;
+ }
+ bool classMatch = fRoot->fFileName == def->fFileName;
SkASSERT(fRoot);
SkASSERT(fRoot->fFileName.length());
- if (classMatch) {
- buildup = "#";
- if (*str != classPart && "Sk" == classPart.substr(0, 2)) {
- buildup += classPart + "_";
- }
- buildup += namePart;
- } else {
- string filename = defRoot->asRoot()->fFileName;
+ if (!classMatch) {
+ string filename = def->fFileName;
if (filename.substr(filename.length() - 4) == ".bmh") {
filename = filename.substr(0, filename.length() - 4);
}
@@ -688,15 +693,18 @@ string MdOut::linkRef(const string& leadingSpaces, const Definition* def,
while (start > 0 && (isalnum(filename[start - 1]) || '_' == filename[start - 1])) {
--start;
}
- buildup = filename.substr(start) + "#" + (classMatch ? namePart : *str);
+ buildup = filename.substr(start);
}
+ buildup += "#" + refName;
if (MarkType::kParam == def->fMarkType) {
const Definition* parent = def->fParent;
SkASSERT(MarkType::kMethod == parent->fMarkType);
buildup = '#' + parent->fFiddle + '_' + ref;
}
string refOut(ref);
- std::replace(refOut.begin(), refOut.end(), '_', ' ');
+ if (!globalEnumMember) {
+ std::replace(refOut.begin(), refOut.end(), '_', ' ');
+ }
if (ref.length() > 2 && islower(ref[0]) && "()" == ref.substr(ref.length() - 2)) {
refOut = refOut.substr(0, refOut.length() - 2);
}
@@ -719,7 +727,6 @@ string MdOut::linkRef(const string& leadingSpaces, const Definition* def,
found = true;
}
}
-
}
if (!found) {
SkDebugf(""); // convenient place to set a breakpoint