Loading.. Hold one one sec.

Whoops 404

page not found bruh.

What is Documentron?

A library for documenting libraries

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.

FEATURES

  • Async parsing - Parsing can be done via url async requests.
  • Advanced Grouping - Groups and subgroups (@group) for better organization and filtering.
  • Subparameters - parameters (@param) and return (@return) can have subparameters (list inside list) (for example, if documenting an object argument)
  • Shared data - parameters (@param) and return (@return) can share similar data, allowing you to document with less redundancy. See @SHARED
  • Meta data - Data not related to and/or meant for your own purposes can be stored as well. See @META.
  • Auto-Generate JSON/HTML/MD - Quick Customizable Templating and built in template engine
  • Extendable Flags - Flags for params can have custom values.
  • Minimum Dependencies - No extensive library requirements or server installs

Syntax

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(){
	
}

Adding the Library

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())
		}
	})
})

Example

Here we document a simple function addNumbers(a,b) in our myScript.js file.

{{addNumbers}}

Output

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!

JSON OUTPUT

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
}

HTML OUTPUT

And using doc.generateHTML() results in something like this!

addNumbers() Returns: number

addNumbers(A,B)

This function adds two numbers (A+B) together.

  • A (number) - First number to add ...ex: 2 Default: 1
  • B (number) - Second number to add ... Default: 0

Returns (number) -- Resulting total number

DOWNLOAD Latest: {{github.version}}

You can download directly from github here, or check out the repository to contribute.

Visit Repo
{{github.files.fullSource.description}} ({{github.files.fullSource.size}})
{{github.files.compressed.description}} ({{github.files.compressed.size}})

DOCS

{{docData}}
Nav Docs ▲

NAV Back to Top

{{docNav}}

DEMO

Below 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).

View Demo Src: documentron.js

{{demoSrc}}
							

Result

News

Check here for all the latest news.

v0.0.500 12/19/17

Introducing a powerful tool for generating documentation. Feedback and questions are encouraged, updates to come!

About

Project Developed by Chris Malcolm

Grab + Contribute: github

This work is licensed under a MIT license.