Skip to content

Commit d99da90

Browse files
committed
docs: generate documentation for require-example (fixes #35)
1 parent 682b6bd commit d99da90

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ JSDoc linting rules for ESLint.
2020
* [`check-types`](#eslint-plugin-jsdoc-rules-check-types)
2121
* [`newline-after-description`](#eslint-plugin-jsdoc-rules-newline-after-description)
2222
* [`require-description-complete-sentence`](#eslint-plugin-jsdoc-rules-require-description-complete-sentence)
23+
* [`require-example`](#eslint-plugin-jsdoc-rules-require-example)
2324
* [`require-hyphen-before-param-description`](#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description)
2425
* [`require-param`](#eslint-plugin-jsdoc-rules-require-param)
2526
* [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)
@@ -40,6 +41,7 @@ This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
4041
| [`check-types`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-check-types) | [`checkTypes`](https://github.com/jscs-dev/jscs-jsdoc#checktypes) |
4142
| [`newline-after-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description) | [`requireNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirenewlineafterdescription) and [`disallowNewlineAfterDescription`](https://github.com/jscs-dev/jscs-jsdoc#disallownewlineafterdescription) |
4243
| [`require-description-complete-sentence`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-description-complete-sentence) | [`requireDescriptionCompleteSentence`](https://github.com/jscs-dev/jscs-jsdoc#requiredescriptioncompletesentence) |
44+
| [`require-example`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-example) | N/A |
4345
| [`require-hyphen-before-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description) | [`requireHyphenBeforeDescription`](https://github.com/jscs-dev/jscs-jsdoc#requirehyphenbeforedescription) |
4446
| [`require-param`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param) | [`checkParamExistence`](https://github.com/jscs-dev/jscs-jsdoc#checkparamexistence) |
4547
| [`require-param-description`](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-param-description) | [`requireParamDescription`](https://github.com/jscs-dev/jscs-jsdoc#requireparamdescription) |
@@ -91,6 +93,7 @@ Finally, enable all of the rules that you would like to use.
9193
"jsdoc/check-types": 1,
9294
"jsdoc/newline-after-description": 1,
9395
"jsdoc/require-description-complete-sentence": 1,
96+
"jsdoc/require-example": 1,
9497
"jsdoc/require-hyphen-before-param-description": 1,
9598
"jsdoc/require-param": 1,
9699
"jsdoc/require-param-description": 1,
@@ -835,6 +838,71 @@ function quux () {
835838
```
836839

837840

841+
<a name="eslint-plugin-jsdoc-rules-require-example"></a>
842+
### <code>require-example</code>
843+
844+
Requires that all functions have examples.
845+
846+
* All functions must have one or more `@example` tags.
847+
* Every example tag must have a non-empty description that explains the method's usage.
848+
849+
|||
850+
|---|---|
851+
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
852+
|Tags|`example`|
853+
854+
The following patterns are considered problems:
855+
856+
```js
857+
/**
858+
*
859+
*/
860+
function quux () {
861+
862+
}
863+
// Message: Missing JSDoc @example declaration.
864+
865+
/**
866+
* @example
867+
*/
868+
function quux () {
869+
870+
}
871+
// Message: Missing JSDoc @example description.
872+
```
873+
874+
The following patterns are not considered problems:
875+
876+
```js
877+
/**
878+
* @example
879+
* // arbitrary example content
880+
*/
881+
function quux () {
882+
883+
}
884+
885+
/**
886+
* @example
887+
* quux(); // does something useful
888+
*/
889+
function quux () {
890+
891+
}
892+
893+
/**
894+
* @example <caption>Valid usage</caption>
895+
* quux(); // does something useful
896+
*
897+
* @example <caption>Invalid usage</caption>
898+
* quux('random unwanted arg'); // results in an error
899+
*/
900+
function quux () {
901+
902+
}
903+
```
904+
905+
838906
<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
839907
### <code>require-hyphen-before-param-description</code>
840908

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"babel-plugin-add-module-exports": "^0.2.1",
1515
"babel-plugin-transform-flow-strip-types": "^6.18.0",
1616
"babel-preset-env": "^1.2.2",
17+
"babel-preset-es2015": "^6.24.1",
1718
"babel-register": "^6.18.0",
1819
"chai": "^3.5.0",
1920
"eslint": "^3.10.2",

0 commit comments

Comments
 (0)