Skip to content

xt-docs


xt-docs command generates source code documentation for an extension project.


Extension CLI uses JSDoc specification to generate documentation for javascript files in an extension project. JSDoc is a flexible documentation generator that converts javascript code comments to readable HTML/CSS files which you can be hosted for example with github pages.

Commands

Braces { } indicate that the user must choose one (and only one) of the items inside the braces.

Default command

1
xt-docs

Command using custom configuration file path

1
xt-docs {-c|--config} "/path/to/config.json"

Build docs and keep watching changes

1
xt-docs {-w|--watch}

Get help using this command

1
xt-docs --help

Package.json scripts

After installing extension-cli, you can run these commands from a terminal using syntax npx xt-docs.

Or you can add an option to packages.json scripts section and then execute the command as npm run docs. See example below.

1
2
3
"scripts":{
  "docs": "xt-docs"
}

Configuration

By default the CLI will look for docs configuration in two different places:

  • in package.json using key xtdocs

  • in a file named .xtdocs.json in project root

If these two locations cause a conflict, alternatively you can provide a path to configuration file with -c (--config) flag, followed by path to file. See commands for an example.

You can use any compatible template of choice to style your docs. You can find some templating options here.

Default Configuration

The CLI uses a documentation configuration file shown below. You can override any of these key-value pairs at project level. You can also add key-value pairs that are not defined here so long as they follow to JSDoc guidelines.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
  "tags": {
    "allowUnknownTags": true,
    "dictionaries": [
      "jsdoc"
    ]
  },
  "source": {
    "include": [
      "src"
    ],
    "includePattern": ".js$",
    "excludePattern": "(node_modules/)"
  },
  "plugins": [
    "plugins/markdown"
  ],
  "templates": {
    "default": {
      "cleverLinks": true,
      "monospaceLinks": false
    }
  },
  "opts": {
    "destination": "./public/documentation",
    "encoding": "utf8",
    "private": true,
    "recurse": true,
    "template": "templates/default"
  }
}