sb-doc
v1.0.0
Published
A documentation tool to write markdown documentation.
Downloads
1
Maintainers
Readme
sb-doc
Library for markdown JavaScript documentation.
Installation
npm install --save-dev sb-doc
Usage
Say you have a directory layout:
.
├── src/src-file.js
└── documentation.js
With the following contents:
// src/src-file.js
/**
* @module module-name
*/
/**
* A class description.
*/
class SrcClass {
/**
* A static member.
* @type {Array<any>}
* @readonly
*/
static aMember;
/**
* A member.
* @type {Array<any>}
*/
aMember;
/**
* Also a member.
* @type {number}
*/
get alsoAMember() {
return 0;
}
/**
* A constructor.
* @param {Array<number>} numbers The variable array numbers.
*/
constructor(...numbers) {
// ...
}
/**
* A non static method, who overrides its super class function.
* @returns {string} A string is returned.
* @override
*/
nonStaticFunction() {
// ...
}
/**
* Does something.
* @param {object} options The options.
*/
static staticFunction(options) {
// ...
}
}
module.exports = {
SrcClass
}
// documentation.js
const sbDoc = require('sb-doc');
console.log(sbDoc('src/src-file.js').markdown)
// Output:
//
// # module:module-name
// ## Constatns
// | Name | Type | Description |
// | --- | --- | --- |
// | `someConstant` | `object` | A constant |
//
// ## Functions
// ##### `aFunction()`
// A function.
// | Parameters | - | |
// | --- | --- | --- |
// | **Returns** | `void` |
//
// ## Classes
// ### SrcClass
// A class description.
// ```js
// class SrcClass {
// constructor(...numbers);
// @override nonStaticFunction();
// static staticFunction(options);
// }
// ```
// #### Members
// | Name | Type | Description |
// | --- | --- | --- |
// | `static aStaticMember` | `Array<any>` | A static member. |
// | `aMember` | `Array<any>` | A member. |
// | `alsoAMember` | `number` | Also a member. |
//
// #### Functions
// ##### `@override nonStaticFunction()`
// A non static method, who overrides its super class function.
// | Parameters | - | |
// | --- | --- | --- |
// | **Returns** | `string` | A string is returned. |
//
// ##### `static staticFunction(options)`
// Does something.
// | Parameters | | |
// | --- | --- | --- |
// | **Name** | **Type** | **Description** |
// | `options` | `object` | The options. |
// | **Returns** | `void` |
Which results in the following markdown:
module:module-name
Constatns
| Name | Type | Description | | --- | --- | --- | |
someConstant
|object
| A constant |Functions
aFunction()
A function. | Parameters | - | | | --- | --- | --- | | Returns |
void
|Classes
SrcClass
A class description.
class SrcClass { constructor(...numbers); @override nonStaticFunction(); static staticFunction(options); }
Members
| Name | Type | Description | | --- | --- | --- | |
static aStaticMember
|Array<any>
| A static member. | |aMember
|Array<any>
| A member. | |alsoAMember
|number
| Also a member. |Functions
@override nonStaticFunction()
A non static method, who overrides its super class function. | Parameters | - | | | --- | --- | --- | | Returns |
string
| A string is returned. |
static staticFunction(options)
Does something. | Parameters | | | | --- | --- | --- | | Name | Type | Description | |
options
|object
| The options. | | Returns |void
|
Further Documentation
For more accurate and detailed insight go visit the GitHub Page and look into the source code or the documentation.
Creator
Severin Buchser