Skip to content

Commit 9a42e80

Browse files
authored
Merge pull request #101 from ember-learn/feat/allow-specifying-documenter
[feat] Allow specifying a documenter
2 parents b1d4a05 + 253a021 commit 9a42e80

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

lib/broccoli/docs-filter.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict';
2+
3+
const Filter = require('broccoli-persistent-filter');
4+
5+
const documenterRegex = /\/\*+\s*@documenter ([a-zA-Z]+)\s*\*+\//;
6+
7+
module.exports = class DocsFilter extends Filter {
8+
constructor(inputNode, documenter) {
9+
super(inputNode);
10+
11+
this.documenter = documenter;
12+
}
13+
14+
processString(content) {
15+
let match = content.match(documenterRegex);
16+
17+
if (match) {
18+
if (match[1] === this.documenter) {
19+
return content.replace(documenterRegex, '');
20+
}
21+
22+
return '';
23+
}
24+
25+
return content;
26+
}
27+
}

lib/models/plugin-registry.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const DocsFilter = require('../broccoli/docs-filter');
4+
35
function isPluginPack(addon) {
46
return addon.pkg.keywords.indexOf('ember-cli-addon-docs-plugin-pack') !== -1;
57
}
@@ -27,7 +29,7 @@ class PluginRegistry {
2729
createDocsGenerators(inputTree, options) {
2830
if (this._docsGenerators === null) {
2931
this._docsGenerators = this.plugins.map(p => p.createDocsGenerator(
30-
inputTree,
32+
new DocsFilter(inputTree, p.name.replace('ember-cli-addon-docs-', '')),
3133
options
3234
));
3335
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"broccoli-filter": "^1.2.4",
2828
"broccoli-funnel": "^2.0.1",
2929
"broccoli-merge-trees": "^2.0.0",
30+
"broccoli-persistent-filter": "^1.4.3",
3031
"broccoli-plugin": "^1.3.0",
3132
"broccoli-stew": "^1.5.0",
3233
"ember-ace": "^1.2.0",

sandbox/app/components/esdoc-component.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @documenter esdoc */
2+
13
import Component from '@ember/component';
24
import { action } from '@ember-decorators/object';
35
import { argument } from '@ember-decorators/argument';

sandbox/app/components/yuidoc-component.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/** @documenter yuidoc */
2+
13
import Component from '@ember/component';
24

35
/**
@@ -61,9 +63,4 @@ YUIDocComponent.reopenClass({
6163
isYUIDocComponent: true
6264
});
6365

64-
/**
65-
ESDoc is double documenting this export, so hide the second export.
66-
67-
@hide
68-
*/
6966
export default YUIDocComponent;

0 commit comments

Comments
 (0)