From 80247e594d1fb168e11a19ce6a73a7e7169ec1f5 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Wed, 11 Jul 2018 16:18:41 -0400 Subject: Publish docs for rrect, picture, blendmode Complete basic docs for SkRRect, SkPicture, SkBlendMode. Add a new rule that checks the main description tense. Check for spelling errors. R=caryclark@google.com Docs-Preview: https://skia.org/?cl=138542 Bug: skia:6898 Change-Id: Iba547873775a89f1d652be9b0219b84ffa8d0628 Reviewed-on: https://skia-review.googlesource.com/138542 Commit-Queue: Cary Clark Reviewed-by: Cary Clark Auto-Submit: Cary Clark --- tools/bookmaker/bookmaker.cpp | 10 ++---- tools/bookmaker/definition.cpp | 64 +++++++++++++++++++++++++++++++++++++++ tools/bookmaker/includeParser.cpp | 8 +++-- tools/bookmaker/includeWriter.cpp | 1 + tools/bookmaker/mdOut.cpp | 2 +- tools/bookmaker/spellCheck.cpp | 13 +++++++- 6 files changed, 87 insertions(+), 11 deletions(-) (limited to 'tools') diff --git a/tools/bookmaker/bookmaker.cpp b/tools/bookmaker/bookmaker.cpp index 15598be95f..65f89f5dfe 100644 --- a/tools/bookmaker/bookmaker.cpp +++ b/tools/bookmaker/bookmaker.cpp @@ -48,10 +48,9 @@ trouble with aliases, plurals deprecated methods should be sorted down in md out, and show include "Deprecated." text body. rewrap text to fit in some number of columns #Literal is inflexible, making the entire #Code block link-less (see $Literal in SkImageInfo) - would rather keep links for boby above #Literal, and/or make it a block and not a one-liner + would rather keep links for body above #Literal, and/or make it a block and not a one-liner add check to require #Const to contain #Code block if defining const or constexpr (enum consts have - #Code blocks inside the #Enum def -add spelling rule to look for x-bit but allow x bits + #Code blocks inside the #Enum def) There are a number of formatting bugs with ad hoc patches where a substitution doesn't keep the space before or after, or the linefeeds before or after. The rules are not very good either. @@ -72,8 +71,6 @@ there is special case code to skip phrase def when looking for additional substi phrase def. Could put it in the token list instead I guess, or make a definition subclass used by phrase def with an additional slot... - - #Deprecated soon ## should emit the text "To be deprecated soon." (right now you get just "soon") @@ -86,9 +83,8 @@ has #Const children. If so, generate a summary table first. Or, only allow #Line and moderate text description in #Const. Put more verbose text, example, seealso, in subsequent #SubTopic. Alpha_Type does this and it looks good. -more spelling: x-value y-value - see head of selfCheck.cpp for additional todos +see head of spellCheck.cpp for additional todos */ /* diff --git a/tools/bookmaker/definition.cpp b/tools/bookmaker/definition.cpp index 18ce808068..056e4f7fe4 100644 --- a/tools/bookmaker/definition.cpp +++ b/tools/bookmaker/definition.cpp @@ -530,6 +530,67 @@ bool Definition::checkMethod() const { return paramError.reportError("#Param without param in #Method"); } } + // check after end of #Line and before next child for description + const char* descStart = fContentStart; + const char* descEnd = nullptr; + for (auto& child : fChildren) { + if (MarkType::kAnchor == child->fMarkType) { + continue; + } + if (MarkType::kCode == child->fMarkType) { + continue; + } + if (MarkType::kDeprecated == child->fMarkType) { + return true; + } + if (MarkType::kExperimental == child->fMarkType) { + return true; + } + if (MarkType::kFormula == child->fMarkType) { + continue; + } + if (MarkType::kList == child->fMarkType) { + continue; + } + if (MarkType::kMarkChar == child->fMarkType) { + continue; + } + if (MarkType::kPhraseRef == child->fMarkType) { + continue; + } + if (MarkType::kPrivate == child->fMarkType) { + return true; + } + TextParser emptyCheck(fFileName, descStart, child->fStart, child->fLineCount); + if (!emptyCheck.eof() && emptyCheck.skipWhiteSpace()) { + descStart = emptyCheck.fChar; + emptyCheck.trimEnd(); + descEnd = emptyCheck.fEnd; + break; + } + descStart = child->fTerminator; + } + if (!descEnd) { + return methodParser.reportError("missing description"); + } + TextParser description(fFileName, descStart, descEnd, fLineCount); + // expect first word capitalized and pluralized. expect a trailing period + SkASSERT(descStart < descEnd); + if (!isupper(descStart[0])) { + description.reportWarning("expected capital"); + } else if ('.' != descEnd[-1]) { + description.reportWarning("expected period"); + } else { + if (!description.startsWith("For use by Android")) { + description.skipToSpace(); + if (',' == description.fChar[-1]) { + --description.fChar; + } + if ('s' != description.fChar[-1]) { + description.reportWarning("expected plural"); + } + } + } return true; } @@ -852,6 +913,9 @@ bool Definition::methodHasReturn(string name, TextParser* methodParser) const { if (methodParser->skipExact("static")) { methodParser->skipWhiteSpace(); } + if (methodParser->skipExact("virtual")) { + methodParser->skipWhiteSpace(); + } const char* lastStart = methodParser->fChar; const char* nameInParser = methodParser->strnstr(name.c_str(), methodParser->fEnd); methodParser->skipTo(nameInParser); diff --git a/tools/bookmaker/includeParser.cpp b/tools/bookmaker/includeParser.cpp index 716d90afeb..238fcf5109 100644 --- a/tools/bookmaker/includeParser.cpp +++ b/tools/bookmaker/includeParser.cpp @@ -2469,9 +2469,12 @@ bool IncludeParser::parseChar() { // find token on start of line auto lineIter = fParent->fTokens.end(); do { + if (fParent->fTokens.begin() == lineIter) { + break; + } --lineIter; } while (lineIter->fContentStart > fLine); - if (lineIter->fContentStart < fLine) { + if (lineIter->fContentStart < fLine && fParent->fTokens.end() != lineIter) { ++lineIter; } Definition* lineStart = &*lineIter; @@ -2571,7 +2574,8 @@ bool IncludeParser::parseChar() { list::iterator baseIter = fParent->fTokens.end(); list::iterator namedIter = fParent->fTokens.end(); for (auto tokenIter = fParent->fTokens.end(); - fParent->fTokens.begin() != tokenIter--; ) { + fParent->fTokens.begin() != tokenIter; ) { + --tokenIter; if (tokenIter->fLineCount == fLineCount) { if ('f' == tokenIter->fStart[0] && isupper(tokenIter->fStart[1])) { if (namedIter != fParent->fTokens.end()) { diff --git a/tools/bookmaker/includeWriter.cpp b/tools/bookmaker/includeWriter.cpp index 18beff4809..e16da320eb 100644 --- a/tools/bookmaker/includeWriter.cpp +++ b/tools/bookmaker/includeWriter.cpp @@ -2051,6 +2051,7 @@ bool IncludeWriter::populate(BmhParser& bmhParser) { return this->reportError("expected fileName.h"); } string skClassName = fileName.substr(0, fileName.length() - 2); + this->reset(); fOut = fopen(fileName.c_str(), "wb"); if (!fOut) { SkDebugf("could not open output file %s\n", fileName.c_str()); diff --git a/tools/bookmaker/mdOut.cpp b/tools/bookmaker/mdOut.cpp index 653ca5e2f3..4fdc206185 100644 --- a/tools/bookmaker/mdOut.cpp +++ b/tools/bookmaker/mdOut.cpp @@ -1354,7 +1354,7 @@ void MdOut::markTypeOut(Definition* def, const Definition** prior) { if (fBmhParser.fTopicMap.end() == fBmhParser.fTopicMap.find(fullName)) { (*subtopic)->reportError("missing #Details subtopic"); } - subtopicName = parentSubtopic->fName + '_' + subtopicName; + // subtopicName = parentSubtopic->fName + '_' + subtopicName; string noUnderscores = subtopicName; replace_all(noUnderscores, "_", " "); details = this->anchorLocalRef(subtopicName, noUnderscores) + " "; diff --git a/tools/bookmaker/spellCheck.cpp b/tools/bookmaker/spellCheck.cpp index a65e2c1762..39621dbb0c 100644 --- a/tools/bookmaker/spellCheck.cpp +++ b/tools/bookmaker/spellCheck.cpp @@ -20,7 +20,10 @@ if word is camel cased, look for :: matches on suffix when function crosses lines, whole thing isn't seen as a 'word' e.g., search for largeArc in path words in external not seen + +look for x-bit but allow x bits */ + struct CheckEntry { string fFile; int fLine; @@ -389,6 +392,7 @@ void SpellCheck::leafCheck(const char* start, const char* end) { int inParens = 0; bool inQuotes = false; bool allLower = true; + char prePriorCh = 0; char priorCh = 0; char lastCh = 0; const char* wordStart = nullptr; @@ -400,7 +404,10 @@ void SpellCheck::leafCheck(const char* start, const char* end) { if (!allLower || (!inQuotes && '\"' != lastCh && !inParens && ')' != lastCh && !inAngles && '>' != lastCh)) { string word(wordStart, (possibleEnd ? possibleEnd : wordEnd) - wordStart); - wordCheck(word); + if ("e" != word || !isdigit(prePriorCh) || ('+' != lastCh && + '-' != lastCh && !isdigit(lastCh))) { + this->wordCheck(word); + } } wordStart = nullptr; } @@ -469,6 +476,7 @@ void SpellCheck::leafCheck(const char* start, const char* end) { wordEnd = chPtr; break; } + prePriorCh = priorCh; priorCh = lastCh; lastCh = *chPtr; } while (++chPtr <= end); @@ -655,6 +663,9 @@ void SpellCheck::wordCheck(string str) { } iter->second.fCount += 1; } else { + if ("e" == str) { + SkDebugf(""); + } CheckEntry* entry = &mappy[str]; entry->fFile = fFileName; entry->fLine = fLineCount + fLocalLine; -- cgit v1.2.3