Skip to content

JSDoc plugin pre-process typical MobX tags to make them parsable

License

Notifications You must be signed in to change notification settings

jjingrong/jsdoc-mobx-tags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

jsdoc-mobx-tags npm version Downloads

JSDoc plugin pre-process typical MobX tags to make them parsable

Currently - parsing MobX tags results in errors such as

ERROR: Unable to parse ../SomeMobXComponent.js: Unexpected character '@'

This simple plugin for JSDoc aims to fix that.


Currently supports common MobX tags, such as

  • @observer
  • @observable
  • @computed

INSTALL

The jsdoc-mobx-tags plugin can be installed using NPM.

npm install --save-dev jsdoc-mobx-tags

Usage

To use plugin you should include the plugin module in the plugins array of JSDoc's configuration file.

{
    "plugins": ["node_modules/jsdoc-mobx-tags/jsdoc-mobx-tags"]
}

Details

@observer

Assumes layout to be in the form -

@observer
/**
 * Some documentation
 * Some more js documentation
 */
class SomeComponent extends React.Component {
  <Your Component code here>
}

Output :

/**
 * MobX @observer
 * Some documentation
 * Some more js documentation
 */
class SomeComponent extends React.Component {
  <Your Component code here>
}

@computed

Assumes layout to be in the form similar to @observer -

@computed
/**
 * Some description
 *
 * @return {type} Some type
 */
get someValue() {
  return this.value;
}

Output :

/**
 * MobX @computed
 * Some description
 *
 * @return {type} Some type
 */
get someValue() {
  return this.value;
}

@observable

Assumes layout to be in the form -

/* JSDOC: MARK START OBSERVABLE */
@observable someVariable = 0
@observable someString = ''
/* JSDOC: MARK END OBSERVABLE */

Output :

mobxObservables() {
  /**  
   * MobX @observable
   */
  someVariable = 0
  /**  
   * MobX @observable
   */
  someString = ''
}

Contributing

Feel free to open issues/PRs. This is implemented as a quick hack for my own usage, but I realised that some others may find it useful too :)

About

JSDoc plugin pre-process typical MobX tags to make them parsable

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published