Skip to content

Commit

Permalink
Fix typos for the @emits tag in the JS package tracking-jsdoc.
Browse files Browse the repository at this point in the history
  • Loading branch information
eason9487 committed Apr 15, 2024
1 parent 341ca71 commit 7a051a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/js/jsdoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Plugins implemented elsewhere, that are bundled here for easier use
### Event emitters descriptions
[`woocommerce-grow-tracking-jsdoc/fires-description`](https://github.com/woocommerce/grow/tree/add/jsdoc/packages/js/tracking-jsdoc#emitters)
To document what or when is emitted with `@fires` or `@emmits`.
To document what or when is emitted with `@fires` or `@emits`.
#### Imported types
`jsdoc-plugin-typescript`
Expand Down
4 changes: 2 additions & 2 deletions packages/js/tracking-jsdoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ You may add any of the following properties to your JSDoc config (`.jsdocrc.json
Then make sure `jsdoc` uses it, by `jsdoc -r your/source/files/ -c .jsdocrc.json`.
## Emitters
If you would like to add some descriptions to `@fires` or `@emmits` tags, for example to specify what data is attached to the event, add `fires-description` to your plugins list:
If you would like to add some descriptions to `@fires` or `@emits` tags, for example to specify what data is attached to the event, add `fires-description` to your plugins list:
```json
{
"plugins": [
// To be able to add descriptions to `@fires` & `@emmits`
// To be able to add descriptions to `@fires` & `@emits`
"woocommerce-grow-tracking-jsdoc/fires-description"
],
//
Expand Down
22 changes: 10 additions & 12 deletions packages/js/tracking-jsdoc/fires-description.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
/**
* JSDoc plugin that allows to use descriptions for built-in `@fires` & `@emmits` tags.
* JSDoc plugin that allows to use descriptions for built-in `@fires` & `@emits` tags.
*
* Overwrites the standard definition with `canHaveName: true` option,
* and tweaks `applyNamespace` to apply it only to `value.name`.
*/
const { applyNamespace } = require( 'jsdoc/name' );

exports.defineTags = function ( dictionary ) {
dictionary
.defineTag( 'fires', {
mustHaveValue: true,
canHaveName: true,
onTagged( doclet, tag ) {
doclet.fires = doclet.fires || [];
tag.value.name = applyNamespace( tag.value.name, 'event' );
doclet.fires.push( tag.value );
},
} )
.synonym( ' emmits' );
dictionary.defineTag( 'fires', {
mustHaveValue: true,
canHaveName: true,
onTagged( doclet, tag ) {
doclet.fires = doclet.fires || [];
tag.value.name = applyNamespace( tag.value.name, 'event' );
doclet.fires.push( tag.value );
},
} );
};

0 comments on commit 7a051a3

Please sign in to comment.