Skip to content

Commit

Permalink
feat: add parsing of deprecated arguments
Browse files Browse the repository at this point in the history
- Add parsing of deprecated arguments

Closes #157
  • Loading branch information
ifedchankau committed Aug 17, 2018
1 parent b12b5f0 commit ad9f919
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const getArgumentObject = (object, context) => {
object.description, context.regexp.defaultValue),
description: unifyDescription(object.description.trim()),
};

argument.usage = getValueByRegexp(
argument.description, context.regexp.usage) ? false : true;
argument.isFlag = identifyIsFlag(object.arg, argument);
argument.type = getPropertyType(object.arg, argument, context);
return argument;
Expand Down
1 change: 1 addition & 0 deletions src/template/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const context = {
'+[\\S]+[^<\\)\\"])(>|\\)|\\"|,\\s)',
split: /[\|]|\",\s\"|\"\sor\s\"|,\s/,
},
usage: '(\\[|\\()deprecated(\\]|\\))',
argument: {
short: '(\\s|^)(-[^-]*?)(\\s|=|$)',
long: '()(--.+?)(\\s|=|$)',
Expand Down
2 changes: 1 addition & 1 deletion src/templatizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const templatizer = (context, config) => {
optionSchema.default = option.defaultValue;
}
if (option.enum) optionSchema.enum = option.enum;

if (!option.usage) optionSchema.usage = option.usage;
result.definitions.arguments.properties[argumentName] = optionSchema;
});

Expand Down
10 changes: 6 additions & 4 deletions test/parsing/files/full.example.valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@
"--stdin": {
"id": "linterhub:stdin",
"type": "string",
"description": "Lint code provided on <STDIN> - (default is 'false\")",
"default": false
"description": "Lint code provided on <STDIN> - (default is 'false\") [deprecated]",
"default": false,
"usage": false
},
"--SPACE": {
"id": "args:--SPACE",
"type": "number",
"description": "USE SPACE INDENT INSTEAD OF TABS DEFAULTS TO 2",
"default": 2
"description": "(Deprecated) USE SPACE INDENT INSTEAD OF TABS DEFAULTS TO 2",
"default": 2,
"usage": false
},
"--parser": {
"id": "args:--parser",
Expand Down
4 changes: 2 additions & 2 deletions test/parsing/files/full.example.valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
Options:

--ext [String] Specify JavaScript file extensions - [default: .js]
--stdin Lint code provided on <STDIN> - (default is 'false")
--SPACE USE SPACE INDENT INSTEAD OF TABS DEFAULTS TO 2
--stdin Lint code provided on <STDIN> - (default is 'false") [deprecated]
--SPACE (Deprecated) USE SPACE INDENT INSTEAD OF TABS DEFAULTS TO 2
--parser Which parser to use. <flow|babylon|typescript|css|less|scss|json|json5|json-stringify|graphql|markdown|vue|yaml>
--arrow-parens=<avoid|always> Include parentheses around a sole arrow function parameter.
Defaults to avoid.
Expand Down

0 comments on commit ad9f919

Please sign in to comment.