aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/bookmaker/spellCheck.cpp
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-05-16 07:07:07 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-16 11:35:24 +0000
commit682c58da482155213e8cd2834b57bc6541e510a0 (patch)
tree63d666ea9ec0c2e765557e61e9ec5fc78ad9747f /tools/bookmaker/spellCheck.cpp
parent4c2a34e4804e5affa8447b590578a359bad2caf8 (diff)
Documentation refresh
- add links to types within methods - add check to see that all references and definitions match - add style to tables to make them easier to read - use https everywhere - remove trailing spaces - move overview inside class - split class and struct in summary tables - add missing #Line - clean up SkImageInfo constant documentation - work on SkColor documentation - allow common phrases to take different parameters - add more flexibility to generated tables - tighten token parent requirements - generalize deprecated and example interfaces - detect inner constructors R=caryclark@google.com Docs-Preview: https://skia.org/?cl=121799 Bug: skia:6898 Change-Id: Ia75a23740b80259460916890b310e2a9f024962a Reviewed-on: https://skia-review.googlesource.com/121799 Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'tools/bookmaker/spellCheck.cpp')
-rw-r--r--tools/bookmaker/spellCheck.cpp48
1 files changed, 32 insertions, 16 deletions
diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp
index 488ceacc7d..be17855f9b 100644
--- a/tools/bookmaker/spellCheck.cpp
+++ b/tools/bookmaker/spellCheck.cpp
@@ -42,12 +42,17 @@ private:
kColumn,
};
+ enum class PrintCheck {
+ kWordsOnly,
+ kAllowNumbers,
+ };
+
bool check(Definition* );
bool checkable(MarkType markType);
- void childCheck(const Definition* def, const char* start);
+ void childCheck(Definition* def, const char* start);
void leafCheck(const char* start, const char* end);
bool parseFromFile(const char* path) override { return true; }
- void printCheck(string str);
+ void printCheck(string str, PrintCheck);
void reset() override {
INHERITED::resetCommon();
@@ -168,7 +173,7 @@ bool SpellCheck::check(Definition* def) {
case MarkType::kDescription:
fInDescription = true;
break;
- case MarkType::kDoxygen:
+ case MarkType::kDetails:
break;
case MarkType::kDuration:
break;
@@ -182,8 +187,6 @@ bool SpellCheck::check(Definition* def) {
break;
case MarkType::kExternal:
break;
- case MarkType::kFile:
- break;
case MarkType::kFormula:
fInFormula = true;
break;
@@ -223,6 +226,8 @@ bool SpellCheck::check(Definition* def) {
} break;
case MarkType::kNoExample:
break;
+ case MarkType::kNoJustify:
+ break;
case MarkType::kOutdent:
break;
case MarkType::kParam: {
@@ -238,7 +243,13 @@ bool SpellCheck::check(Definition* def) {
fInCode = true;
this->wordCheck(paramParser.fChar - paramName, paramName);
fInCode = false;
- } break;
+ } break;
+ case MarkType::kPhraseDef:
+ break;
+ case MarkType::kPhraseParam:
+ break;
+ case MarkType::kPhraseRef:
+ break;
case MarkType::kPlatform:
break;
case MarkType::kPopulate:
@@ -271,7 +282,10 @@ bool SpellCheck::check(Definition* def) {
case MarkType::kSubstitute:
break;
case MarkType::kSubtopic:
- this->printCheck(printable);
+ // TODO: add a tag that allows subtopic labels in illustrations to skip spellcheck?
+ if (string::npos == fFileName.find("illustrations.bmh")) {
+ this->printCheck(printable, PrintCheck::kAllowNumbers);
+ }
break;
case MarkType::kTable:
break;
@@ -279,16 +293,11 @@ bool SpellCheck::check(Definition* def) {
break;
case MarkType::kText:
break;
- case MarkType::kTime:
- break;
case MarkType::kToDo:
break;
case MarkType::kTopic:
- this->printCheck(printable);
+ this->printCheck(printable, PrintCheck::kWordsOnly);
break;
- case MarkType::kTrack:
- // don't output children
- return true;
case MarkType::kTypedef:
break;
case MarkType::kUnion:
@@ -348,11 +357,11 @@ bool SpellCheck::checkable(MarkType markType) {
return BmhParser::Resolvable::kYes == fBmhParser.kMarkProps[(int) markType].fResolve;
}
-void SpellCheck::childCheck(const Definition* def, const char* start) {
+void SpellCheck::childCheck(Definition* def, const char* start) {
const char* end;
fLineCount = def->fLineCount;
if (def->isRoot()) {
- fRoot = const_cast<RootDefinition*>(def->asRoot());
+ fRoot = def->asRoot();
}
for (auto& child : def->fChildren) {
end = child->fStart;
@@ -459,9 +468,16 @@ void SpellCheck::leafCheck(const char* start, const char* end) {
} while (++chPtr <= end);
}
-void SpellCheck::printCheck(string str) {
+void SpellCheck::printCheck(string str, PrintCheck allowed) {
string word;
for (std::stringstream stream(str); stream >> word; ) {
+ if (PrintCheck::kAllowNumbers == allowed && (std::isdigit(word.back()) || 'x' == word.back())) {
+ // allow ###x for RGB_888x
+ if ((size_t) std::count_if(word.begin(), word.end() - 1,
+ [](unsigned char c){ return std::isdigit(c); } ) == word.length() - 1) {
+ continue;
+ }
+ }
wordCheck(word);
}
}