Skip to content

Commit 625c804

Browse files
committed
fix: update readme, fix broccoli tree options
1 parent 730a4a5 commit 625c804

File tree

2 files changed

+76
-9
lines changed

2 files changed

+76
-9
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,68 @@
11
# Documenter
22

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!
44

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

src/trees/extracter.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ export default class ExtracterTree extends Tree {
2424

2525
options: {
2626
/**
27-
* The root directory of the project to extract documentation from
27+
* The name of the project we are extracting docs from
2828
*/
29-
dir: string;
29+
projectName: string;
30+
/**
31+
* The version string of the project we are extracting docs from
32+
*/
33+
projectVersion: string;
3034
/**
3135
* The path to the directory containing all the Pages to build, relative to `dir`. Defaults to `docs`
3236
*/
@@ -48,7 +52,6 @@ export default class ExtracterTree extends Tree {
4852
options.sourceDirs = options.sourceDirs || [ 'src' ];
4953
options.pagesDir = options.pagesDir || 'docs';
5054
this.options = <any>options;
51-
this.projectPkg = readPkg(options.dir);
5255
}
5356

5457
build() {
@@ -59,11 +62,11 @@ export default class ExtracterTree extends Tree {
5962
fs.writeFileSync(path.join(this.outputPath, 'docs.json'), docs);
6063
} else {
6164
let extracter = new Extracter({
62-
projectName: this.projectPkg.name,
63-
projectVersion: this.projectPkg.version,
64-
dir: this.options.dir,
65-
sourceDirs: this.options.sourceDirs.map((dir) => path.join(input, dir)),
66-
pagesDir: path.join(input, this.options.pagesDir)
65+
dir: input,
66+
projectName: this.options.projectName,
67+
projectVersion: this.options.projectVersion,
68+
sourceDirs: this.options.sourceDirs,
69+
pagesDir: this.options.pagesDir
6770
});
6871
let docs = extracter.extract();
6972
fs.writeFileSync(path.join(this.outputPath, 'docs.json'), JSON.stringify(docs));

0 commit comments

Comments
 (0)