detect deprecated methods

If a method in an include is marked deprecated, make sure that
the documentation is marked deprecated.

It's OK for the documentation to mark something deprecated that
is not marked as such in the includes since the documentation may
be ahead of the includes.

Fix a couple of mistakes found around deprecated methods.

Docs-Preview: https://skia.org/?cl=114184
TBR=caryclark@google.com
Bug: skia:6898
Change-Id: I2bb4c293d7bf28e5d12f9ae01b7be49ce48b9ee4
Reviewed-on: https://skia-review.googlesource.com/114184
Commit-Queue: Cary Clark <caryclark@skia.org>
Reviewed-by: Cary Clark <caryclark@skia.org>
This commit is contained in:
Cary Clark 2018-03-19 09:04:10 -04:00 committed by Skia Commit-Bot
parent a7d661a681
commit 89b1456b55
6 changed files with 28 additions and 72 deletions

View File

@ -2416,19 +2416,7 @@ then r, g, and b are ignored.
# ------------------------------------------------------------------------------
#Method void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const
#In Draw
#Line # deprecated ##
Deprecated. Use eraseARGB or eraseColor.
#Param r amount of red ##
#Param g amount of green ##
#Param b amount of blue ##
#NoExample
##
#SeeAlso eraseColor eraseARGB erase
#Deprecated
##
# ------------------------------------------------------------------------------

View File

@ -112,7 +112,6 @@ is useful to position one or more <a href="#Bitmap">Bitmaps</a> within a shared
| <a href="#SkBitmap_erase">erase</a> | writes <a href="undocumented#Color">Color</a> to rectangle of pixels |
| <a href="#SkBitmap_eraseARGB">eraseARGB</a> | writes <a href="undocumented#Color">Color</a> to pixels |
| <a href="#SkBitmap_eraseColor">eraseColor</a> | writes <a href="undocumented#Color">Color</a> to pixels |
| <a href="#SkBitmap_eraseRGB">eraseRGB</a> | deprecated |
| <a href="#SkBitmap_extractAlpha">extractAlpha</a> | creates <a href="#Bitmap">Bitmap</a> containing <a href="undocumented#Alpha">Alpha</a> of pixels |
| <a href="#SkBitmap_extractSubset">extractSubset</a> | creates <a href="#Bitmap">Bitmap</a>, sharing pixels if possible |
| <a href="#SkBitmap_getAddr">getAddr</a> | returns readable pixel address as void pointer |
@ -2571,7 +2570,6 @@ Marks that pixels in <a href="undocumented#Pixel_Ref">Pixel Ref</a> have changed
| <a href="#SkBitmap_erase">erase</a> | writes <a href="undocumented#Color">Color</a> to rectangle of pixels |
| <a href="#SkBitmap_eraseARGB">eraseARGB</a> | writes <a href="undocumented#Color">Color</a> to pixels |
| <a href="#SkBitmap_eraseColor">eraseColor</a> | writes <a href="undocumented#Color">Color</a> to pixels |
| <a href="#SkBitmap_eraseRGB">eraseRGB</a> | deprecated |
<a name="SkBitmap_eraseColor"></a>
## eraseColor
@ -2645,23 +2643,6 @@ amount of <a href="undocumented#RGB_Blue">Color RGB Blue</a>, from no blue (0) t
void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const
</pre>
Deprecated. Use <a href="#SkBitmap_eraseARGB">eraseARGB</a> or <a href="#SkBitmap_eraseColor">eraseColor</a>.
### Parameters
<table> <tr> <td><a name="SkBitmap_eraseRGB_r"> <code><strong>r </strong></code> </a></td> <td>
amount of red</td>
</tr> <tr> <td><a name="SkBitmap_eraseRGB_g"> <code><strong>g </strong></code> </a></td> <td>
amount of green</td>
</tr> <tr> <td><a name="SkBitmap_eraseRGB_b"> <code><strong>b </strong></code> </a></td> <td>
amount of blue</td>
</tr>
</table>
### See Also
<a href="#SkBitmap_eraseColor">eraseColor</a> <a href="#SkBitmap_eraseARGB">eraseARGB</a> <a href="#SkBitmap_erase">erase</a>
---
<a name="SkBitmap_erase"></a>

View File

@ -3524,10 +3524,10 @@
"name": "Font_Metrics"
},
"Paint_Image_Filter_Methods": {
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setStyle(SkPaint::kStroke_Style);\n paint.setStrokeWidth(2);\n SkRegion region;\n region.op( 10, 10, 50, 50, SkRegion::kUnion_Op);\n region.op( 10, 50, 90, 90, SkRegion::kUnion_Op);\n paint.setImageFilter(SkBlurImageFilter::Make(5.0f, 5.0f, nullptr));\n canvas->drawRegion(region, paint);\n paint.setImageFilter(nullptr);\n paint.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 5));\n canvas->translate(100, 100);\n canvas->drawRegion(region, paint);\n}\n",
"code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setStyle(SkPaint::kStroke_Style);\n paint.setStrokeWidth(2);\n SkRegion region;\n region.op( 10, 10, 50, 50, SkRegion::kUnion_Op);\n region.op( 10, 50, 90, 90, SkRegion::kUnion_Op);\n paint.setImageFilter(SkBlurImageFilter::Make(5.0f, 5.0f, nullptr));\n canvas->drawRegion(region, paint);\n paint.setImageFilter(nullptr);\n paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, 5));\n canvas->translate(100, 100);\n canvas->drawRegion(region, paint);\n}\n",
"width": 256,
"height": 256,
"hash": "0b2eec148d6397d6231e1fa0b3d1496d",
"hash": "250e45c5935d54eac6aca775d1fe3475",
"file": "SkPaint_Reference",
"name": "Image_Filter_Methods"
},

View File

@ -1643,6 +1643,7 @@ public:
fInBrace = nullptr;
fIncludeWord = nullptr;
fLastObject = nullptr;
fAttrDeprecated = nullptr;
fPrev = '\0';
fInChar = false;
fInCharCommentString = false;
@ -1815,6 +1816,9 @@ protected:
MarkType fMarkType;
};
static const char gAttrDeprecated[];
static const size_t kAttrDeprecatedLen;
DefinitionMap fMaps[Last_MarkType + 1];
unordered_map<string, Definition> fIncludeMap;
unordered_map<string, IClassDefinition> fIClassMap;
@ -1829,6 +1833,7 @@ protected:
Definition* fInBrace;
Definition* fLastObject;
Definition* fPriorEnum;
const Definition* fAttrDeprecated;
int fPriorIndex;
const char* fIncludeWord;
char fPrev;
@ -1938,7 +1943,6 @@ public:
fEnumDef = nullptr;
fMethodDef = nullptr;
fBmhStructDef = nullptr;
fAttrDeprecated = nullptr;
fInStruct = false;
fWroteMethod = false;
fIndentNext = false;
@ -1961,7 +1965,6 @@ private:
const Definition* fEnumDef;
const Definition* fMethodDef;
const Definition* fBmhStructDef;
const Definition* fAttrDeprecated;
const char* fContinuation; // used to construct paren-qualified method name
int fAnonymousEnumCount;
int fEnumItemValueTab;

View File

@ -9,6 +9,9 @@
#include "SkOSFile.h"
#include "SkOSPath.h"
const char IncludeParser::gAttrDeprecated[] = "SK_ATTR_DEPRECATED";
const size_t IncludeParser::kAttrDeprecatedLen = sizeof(gAttrDeprecated) - 1;
const IncludeKey kKeyWords[] = {
{ "", KeyWord::kNone, KeyProperty::kNone },
{ "SK_API", KeyWord::kSK_API, KeyProperty::kModifier },
@ -329,7 +332,8 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) {
}
}
if (!def) {
if ("SK_ATTR_DEPRECATED" == token.fName) {
if (gAttrDeprecated == token.fName) {
fAttrDeprecated = &token;
break;
}
if (0 == token.fName.find("SkDEBUGCODE")) {
@ -353,6 +357,9 @@ bool IncludeParser::crossCheck(BmhParser& bmhParser) {
if (MarkType::kDefinedBy == def->fMarkType) {
def->fParent->fVisited = true;
}
if (token.fDeprecated && !def->fDeprecated) {
fFailed = !def->reportError<bool>("expect bmh to be marked deprecated");
}
} else {
SkDebugf("method differs from bmh: %s\n", fullName.c_str());
fFailed = true;
@ -1749,7 +1756,8 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) {
child->fStart, fLastObject->fLineCount);
if (!checkDeprecated.eof()) {
checkDeprecated.skipWhiteSpace();
if (checkDeprecated.startsWith("SK_ATTR_DEPRECATED")) {
if (checkDeprecated.startsWith(gAttrDeprecated)) {
fAttrDeprecated = child;
break;
}
}
@ -1759,7 +1767,8 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) {
std::advance(tokenIter, child->fParentIndex);
tokenIter = std::prev(tokenIter);
TextParser previousToken(&*tokenIter);
if (previousToken.startsWith("SK_ATTR_DEPRECATED")) {
if (previousToken.startsWith(gAttrDeprecated)) {
fAttrDeprecated = &*tokenIter;
break;
}
if (Bracket::kPound == child->fParent->fBracket &&
@ -1774,6 +1783,11 @@ bool IncludeParser::parseObject(Definition* child, Definition* markupDef) {
if (!this->parseMethod(child, markupDef)) {
return child->reportError<bool>("failed to parse method");
}
if (fAttrDeprecated) {
Definition* lastMethod = &markupDef->fTokens.back();
lastMethod->fDeprecated = true;
fAttrDeprecated = nullptr;
}
break;
case Bracket::kSlashSlash:
case Bracket::kSlashStar:
@ -2047,35 +2061,7 @@ bool IncludeParser::parseChar() {
']' == test ? Bracket::kSquare : Bracket::kBrace) == this->topBracket()) {
this->popBracket();
if (!fInFunction) {
bool deprecatedMacro = false;
if (')' == test) {
auto iter = fParent->fTokens.end();
bool lookForWord = false;
while (fParent->fTokens.begin() != iter) {
--iter;
if (lookForWord) {
if (Definition::Type::kWord != iter->fType) {
break;
}
string word(iter->fContentStart, iter->length());
if ("SK_ATTR_EXTERNALLY_DEPRECATED" == word) {
deprecatedMacro = true;
// remove macro paren (would confuse method parsing later)
fParent->fTokens.pop_back();
fParent->fChildren.pop_back();
}
break;
}
if (Definition::Type::kBracket != iter->fType) {
break;
}
if (Bracket::kParen != iter->fBracket) {
break;
}
lookForWord = true;
}
}
fInFunction = ')' == test && !deprecatedMacro;
fInFunction = ')' == test;
} else {
fInFunction = '}' != test;
}

View File

@ -1533,10 +1533,8 @@ bool IncludeWriter::populate(Definition* def, ParentPair* prevPair, RootDefiniti
memberStart = &child;
staticOnly = false;
}
const char attrDeprecated[] = "SK_ATTR_DEPRECATED";
const size_t attrDeprecatedLen = sizeof(attrDeprecated) - 1;
if (attrDeprecatedLen == child.fContentEnd - child.fContentStart &&
!strncmp(attrDeprecated, child.fStart, attrDeprecatedLen)) {
if (kAttrDeprecatedLen == (size_t) (child.fContentEnd - child.fContentStart) &&
!strncmp(gAttrDeprecated, child.fStart, kAttrDeprecatedLen)) {
fAttrDeprecated = &child;
}
continue;