Simple documentation generator using sourcecat and emu
This is a simple documentation generator that generates an output markdown
file designed to be saved as your
README.md in your repository.
Install using the instructions shown in the lovely nodei.co badge above then run in a repository directory:
gendocs > README.md
Emu looks for standard JS block comments, but with two asterisks instead of one. While emu is unfussy about the content of those comments, gendocs is expecting mardown formatted text to be present.
/**# module-levelThis is a module which does blah.## Example UsageJump up and down.## Reference**//**### sayHello(target)The `sayHello` function is used to say, um, hello to the specifiedtarget.**/;
NOTE: As emu is a little fussy about the indentation of the documentation within the comment block, it's wise to make sure you indent your documentation one level in from the opening comment. If you haven't you will notice this with code samples losing indentation.
Gendocs uses a simple plugin system to allow you to customize the
documentation generated. Most plugins are manually enabled through
configuration within a
docs.json file, though some are enabled
Generate badges for your documentation without having to remember those special markdown image link things.
Will be inserted just before the first non top level (
encountered in your documentation.
If you want to bootstrap a new
docs.json file in your project directory
then try the following:
curl > docs.json
Copy and paste. Yeah, I'm not a fan. If I'm going to write some example code, I'd rather write it once and include it into a file. This plugin helps you do that and it's enabled by default.
Any time a line similar to the following is encountered:
The file contents is included and an appropriate Github flavoured markdown code section is created with the syntax highlighting mode to set match the file type. So in the case of our previous example, something like the following might get created in our resulting markdown file:
!!!jsconsole.log('this is a tricky demo');!!!
You have to imagine that the exclamation marks are backticks in the output above, but you get the idea.
NOTE: Should you wish to highlight a syntax that is different to it's
extension (or it's extension is not recognised), simply specify the
highlighter syntax directly after the the
<<< directive. For example,
to include a stylus file using the css highlighter, you could do something
At this stage, all include paths are relative to the project root rather
than the source file location. So if you had were including an example from
a subfolder in your project, rather than referencing
examples/demo.js and everything will be sweet.
If you have example code in a gist then you can include that into your readme also quite easily. For example:
However, as gendocs is unable to determine what the file type is from a raw http request (and github serves all raw content as text/plain IIRC) you need to tell gendocs the typeof of syntax highlighting you want:
In addition to the format outlined above, I have been experimenting with adding support for the leanpub markdown includes:
Insert the license at the tail end of your documentation. Uses the current
year and package information from the
package.json file to generate an
appropriate license for your project. The license(s) that will be appended
to your README are based on the licenses specified in the
To enable, you will need to inform
docs.json that you want this
If you want to override the copyright holder (or year) from the default of
the author in the package.json file, then use the following in your
Currently implemented license templates can be found at the following location:
Copyright (c) 2015 Damon Oehlman firstname.lastname@example.org
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.