Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created February 9, 2012 04:47
Show Gist options
  • Select an option

  • Save isaacs/1777387 to your computer and use it in GitHub Desktop.

Select an option

Save isaacs/1777387 to your computer and use it in GitHub Desktop.
This is an example format for the API reference documentation for a node module, in json
{ type: 'module',
name: 'cluster',
desc: 'The long html description thing at the beginning, examples, etc.',
events:
[ { type: 'event',
name: 'fork',
arguments: [ { name: 'worker', type: 'object', class: 'Worker' } ],
desc: 'blahblah long html description' },
{ type: 'event',
name: 'ready',
arguments: [ { name: 'worker', type: 'object', class: 'Worker' } ],
desc: 'help all the humans' } ],
classes:
[ { type: 'class',
name: 'Worker',
classMethods:
[ { type: 'function',
name: 'someClassMethod',
return:
{ type: 'boolean',
desc: 'True if it worked. Otherwise false.' },
arguments:
[ { type: 'string', name: 'foo', optional: true, default: 'blerg' },
{ type: 'object',
name: 'settings',
options:
[ { name: 'src', type: 'string', description: 'The source string' },
{ name: 'dest',
type: 'string',
desc: 'The destination string' } ] } ] } ],
methods: [ { type: 'function', name: 'sendMessage', arguments: [] } ],
properties:
[ { name: 'someProperty', type: 'number', default: 100 },
{ name: 'otherProp',
type: 'object',
class: 'Worker',
desc: 'An \'other worker\' property' } ],
events: [ {} ] } ] }
@AndreasMadsen

Copy link
Copy Markdown

I think there need some internal boolean.
In this case Worker class is an internal constructor function, but you can using instanceof cluster.Worker and its methods and events is allowed.

Also properties like cluster.workers is a type:map but is values are Worker objects, how do we specify that.

It would also be nice with readable and writable labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment