v0.0.500 12/19/17
Introducing a powerful tool for generating documentation. Feedback and questions are encouraged, updates to come!
A Javascript library for generating documentation.
page not found bruh.
Documentron is a library for quicker documentation by Chris Malcolm. Documentron parses scripts and looks for comment blocks, with the open portion having double ** asterisks. Documentron's documentation is actually documented by itself! Other libraries like this exist, but some key goals and features documentron implented can be seen below.
A doc item has 3 parts: a name, description, and a series of commands we call attribues or tags. Coincidentally, they are defined by @+'CommandName'. This syntax is loosely based on the JSDoc syntax. Some improvements were creating more flexible framework for subparameters, flags, and groups, as mentioned above. Preceding Asterisks (*) in front of commands are optional and will be ignored.
/** myFunction * * my description here * *** comments * @attribute1 * @attribute2 * @andSoOn... * */ function myFunction(){ }
Before starting make sure you have included jquery and the documentron.js library in the head of your script
{{addingLib}}
Then we start an instance of documentron and parse the script using AJAX. Check Constructor for complete set of initial options and source inputs.
$(function(){ //create a new instance var doc = new Documentron({ url: "js/myScript.js", onSuccess: function(data){ //we'll print the object console.log(doc.ToObject()) } }) })
Here we document a simple function addNumbers(a,b) in our myScript.js file.
{{addNumbers}}
What we would see in the console would be an object like so! Its that easy, now you can use this object to quickly generate documentation pages, or use doc.generateHTML() for quick HTML output or doc.generateMD() for Markdown!
Below you can see what object is parsed from this text!
{ "isDocObject":true, //true = not a nested group "name":"addNumbers", "description":"This function adds two numbers (A+B) together.", "group": "helpers", "param":[ { "description":"First number to add", "type":"number", "default":"1", "sample":"2", "flags":{}, //custom flags "name":"A" }, { "description":"Second number to add", "type":"number", "default":"0", "flags":{}, //custom flags "name":"B" } ], "returns":{ "description":"- Resulting total number", "type":"number" }, "paramNamesArr":["A","B"], "function":true //not plain info, not property }
And using doc.generateHTML() results in something like this!
addNumbers(A,B)
This function adds two numbers (A+B) together.
Returns (number) -- Resulting total number
You can download directly from github here, or check out the repository to contribute.
Visit RepoBelow is a demo of how source code (shown immediately below here) is converted into documentation. In this case its documentation.js itself , and in the future I will likely offer other js scripts to try... change the dropdown tab to see some different parsed results (JSON/Html/Markdown/etc).
{{demoSrc}}
Check here for all the latest news.
Introducing a powerful tool for generating documentation. Feedback and questions are encouraged, updates to come!
Project Developed by Chris Malcolm
Grab + Contribute: github
This work is licensed under a MIT license.