|
1 | 1 | # Documenter |
2 | 2 |
|
3 | | -Documenter is a flexible tool for generating documentation for your Denali project (app or addon). Generated docs can be published to your own hosted website, to the central Denali documentation repository (docs.denalijs.org), or even run locally to give you offline, versioned docs for free. |
| 3 | +Generate documentation for your JavaScript or Typescript projects! |
4 | 4 |
|
| 5 | +Includes support for API reference docs generated automatically from code comments, as well as Markdown guides. |
| 6 | + |
| 7 | +Documenter does not generate HTMl or any other kind of rendered output - it only extracts the documentation from your codebase and supplies it in a structured, consistent format for you to render as you wish. |
| 8 | + |
| 9 | +Used by the [Denali CLI](denalijs.org) to generate documentation for Denali projects, but it's not tied to Denali projects only. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +You can use the extracter directly: |
| 14 | + |
| 15 | +```js |
| 16 | +import { Extracter } from 'documenter'; |
| 17 | + |
| 18 | +let extracter = new Extracter({ |
| 19 | + |
| 20 | + // The base directory to start everything from |
| 21 | + dir: process.cwd(), |
| 22 | + |
| 23 | + // The directory to scan for Markdown files |
| 24 | + pagesDir: 'guides', |
| 25 | + |
| 26 | + // An array of glob patterns to search for source files |
| 27 | + sourceDirs: [ 'src' ], |
| 28 | + |
| 29 | + // The name of the project |
| 30 | + projectName: 'typescript-project', |
| 31 | + |
| 32 | + // The current version of the project |
| 33 | + projectVersion: '1.0.0' |
| 34 | + |
| 35 | +}); |
| 36 | + |
| 37 | +let docs = extracter.extract(); |
| 38 | +``` |
| 39 | + |
| 40 | +Or, if you happen to be using Broccoli, you can use the Broccoli plugin: |
| 41 | + |
| 42 | +```js |
| 43 | +import { ExtracterTree } from 'documenter'; |
| 44 | + |
| 45 | +// inputTree should contain the pages and source you want to extract |
| 46 | +// All paths will be relative to the inputTree |
| 47 | +let extracter = new ExtracterTree(inputTree, { |
| 48 | + |
| 49 | + // The directory to scan for Markdown files |
| 50 | + pagesDir: 'guides', |
| 51 | + |
| 52 | + // An array of glob patterns to search for source files |
| 53 | + sourceDirs: [ 'src' ], |
| 54 | + |
| 55 | + // The name of the project |
| 56 | + projectName: 'typescript-project', |
| 57 | + |
| 58 | + // The current version of the project |
| 59 | + projectVersion: '1.0.0' |
| 60 | + |
| 61 | +}); |
| 62 | + |
| 63 | +// The Broccoli plugin will write out the resulting docs data to `docs.json` |
| 64 | +// If a `docs.json` exists in the inputTree, it will simply copy that over |
| 65 | +// and skip the extraction. |
| 66 | +``` |
| 67 | + |
| 68 | +For an example of what the final docs structure looks like, check the [test output helper file](https://github.com/denali-js/documenter/blob/master/test/helpers/output-expectation.js). |
0 commit comments