Skip to content
This repository was archived by the owner on Mar 31, 2025. It is now read-only.

Commit 48d105b

Browse files
fix(ng-doc/component-groups-generate): allow path/outputPath to be configurable
You can now configure the path and outputPath of the component groups documents. See #50
1 parent 71ced7d commit 48d105b

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

ngdoc/processors/component-groups-generate.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ module.exports = {
1313
throw new Error('Invalid configuration. You must provide config.rendering.contentsFolder');
1414
}
1515

16+
var options = _.assign({
17+
outputPath: '${module.area}/${module.name}/${docType}/index.html',
18+
path: '${module.area}/${module.name}/${docType}'
19+
}, config.get('processing.component-groups', {}));
20+
1621
_.forEach(moduleMap, function(module) {
1722

1823
_(module.components)
@@ -30,8 +35,8 @@ module.exports = {
3035
moduleDoc: module,
3136
area: module.area,
3237
components: docs,
33-
outputPath: path.join(partialsPath, _.template('${module.area}/${module.name}/${docType}/index.html', { module: module, docType: docType })),
34-
path: _.template('${module.area}/${module.name}/${docType}', { module: module, docType: docType })
38+
outputPath: path.join(partialsPath, _.template(options.outputPath, { module: module, docType: docType })),
39+
path: _.template(options.path, { module: module, docType: docType })
3540
};
3641
})
3742
.tap(function(groups) {

ngdoc/spec/processors/component-groups-generate.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,35 @@ describe("component-groups processor", function() {
2424

2525
expect(docs.length).toEqual(2);
2626
});
27+
28+
29+
it("should use the outputPath and path specified in processing.component-groups", function() {
30+
var docs = [];
31+
var modules = [{
32+
id: 'mod1',
33+
name: 'test',
34+
area: 'api-docs',
35+
components: [
36+
{ docType: 'a', id: 'a1' },
37+
{ docType: 'a', id: 'a2' },
38+
{ docType: 'a', id: 'a3' },
39+
{ docType: 'a', id: 'a4' },
40+
{ docType: 'b', id: 'b1' },
41+
{ docType: 'b', id: 'b2' },
42+
{ docType: 'b', id: 'a3' }
43+
]
44+
}];
45+
46+
config = new Config();
47+
config.set('rendering.contentsFolder', 'partials');
48+
config.set('processing.component-groups', {
49+
outputPath: '${module.area}/${module.name}/${docType}/${module.name}.html',
50+
path: '${module.area}/${module.name}/${docType}/${module.name}'
51+
});
52+
53+
processor.process(docs, config, modules);
54+
55+
expect(docs[0].path).toBe('api-docs/test/a/test');
56+
expect(docs[0].outputPath).toBe('partials/api-docs/test/a/test.html');
57+
});
2758
});

0 commit comments

Comments
 (0)