A CLI generator to generate API documentation vue-block-system projects
Install
$ npm install -g vue-block-documentation
Commands
To use the generator open your console and change directory to the src directory of your vue-block-system project.
init-block-documentation
This will initialize the block documentation tool in your project, it will ask you to confirm some settings. This will most likely mean pressing enter until it's done.
$ init-block-documentation
generate-block-documentation
This is where the magic happens. Running this fill scan the block directory annd create a documentation folder in the src folder. Opening this on a webserver will display your generated documentation.
$ generate-block-documentation
Options:
-i, --input <input>
: Override the input directory.-o, --output <output>
: Override the output directory.
Typing your block data
The tool will scan the block folders for the {BlockName}Data.js
files, this file should contain all the data provided by your API. Describing the data is done by using Vue-Types.
Basic example
; heading: VueTypesstringisRequired paragraph: VueTypesstringisRequired image: VueTypesshape src: VueTypesstringisRequired alt: VueTypesstringisRequired isRequired;
Using external objects
To avoid having to redefine the same object over and over again you can also import js files that describe the shape of the reusable object
ImageDataObject.js
; src: VueTypesstringisRequired alt: VueTypesstringisRequired;
BlockFooData.js
;; heading: VueTypesstringisRequired paragraph: VueTypesstringisRequired image: VueTypesshapeImageDataObjectisRequired;
Adding custom descriptions and placeholders
When generating API documentation it also outputs example json structures, for easy development you want this to be as accurate as possible for the backender building your API. To create better documentation you can add descriptions and placeholder values into your object describing the object. You do this by adding a comment block above your data object. The structure for adding descriptions and placeholder is as followed:
@param {description|placehoder} [NAME_OF_YOUR_PARAM] Your description goes here...
This could end up in the following:
; /** * @param * @param * * @param * @param * * @param * * @param * @param * * @param * @param */ heading: VueTypesstringisRequired paragraph: VueTypesstringisRequired image: VueTypesshape src: VueTypesstringisRequired alt: VueTypesstringisRequired isRequired;
Notes:
- All imported files should be javascript files and will be parsed as es2015.
- When using external object, descriptions and placeholders are shared amongst all parent files!
Demo
This tool wil only work on a vue-block-system project. I've created an example output so you can preview what the output might look like!