API Reference

docutils_react_docgen

docutils extension for documenting React modules. Requires react-docgen

docutils_react_docgen.docutils_react_docgen.find_package(dirname)

find commonjs package for given directory. Starts from dirname and recurses up the directory tree looking for bower.json or package.json.

Returns a tuple (dirname, package)

dirname
The directory the .json file was found in.
package
A dict loaded from the .json file. Its keys are the module filenames.
docutils_react_docgen.docutils_react_docgen.react_docgen(args, react_docgen='react-docgen')

Execute react-docgen with the given arguments.

args is a string which may contain spaces.

react_docgen is also a string which may contain spaces.

Returns the output of react-docgen as a dict whose keys are module filenames (strings), and whose values are module metadata (dicts).

WARNING
The default for react_docgen always evaluates to its initial value.
docutils_react_docgen.docutils_react_docgen.react_doc_to_rst(doc_dict, options, formatter_class, args='')

Convert doc_dict, the react-docgen output dict to a string of ReStructuredText, according to the options and using the formatter_class

args is the string of arguments passed to the directive. The default is ‘’. Only required when using absolute addressing so the Formatter can recover the path_argument.

docutils_react_docgen.docutils_react_docgen.run_react_docgen(args, options={'src': '', 'show_prop_type': False, 'tab_size': 4, 'use_commonjs_module_name': True, 'path_index': 0, 'module_description_missing': 'Module doc string is missing!', 'exclude': '', 'include': '', 'module_prop_description_missing': 'Property doc string is missing!', 'module_underline_character': '-'})

Execute SETTINGS['react_docgen'] with the given args.

args is a string which may contain spaces.

SETTINGS['react_docgen'] is also a string which may contain spaces.

options is a dict of directive options.

The command output is expected to be a JSON blob representing a dict whose keys are the module filenames (strings), and whose values are the module metadata (dicts).

However, the blob is simply converted into a python object and returned.

Implements the project_base setting and the path_index option.

class docutils_react_docgen.docutils_react_docgen.Formatter(options, dirname, args='')

Formatter(options, dirname).run(doc_dict) returns a string.

options
a dict of options.
dirname
the directory to search for the CommonJS package if the use_commonjs_module_name option is True
doc_dict
a dict of react-docgen module metadata
args
Default is ‘’. The string of arguments passed to the directive. Required when using absolute addressing.
class docutils_react_docgen.docutils_react_docgen.ReactDocgen(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Docutils Directive which calls the react-docgen executable.

formatter_class

alias of Formatter