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

Commit f2c3776

Browse files
njs50petebacondarwin
authored andcommitted
fix(ng-doc/component-groups-generate processor): use path/outputPath specified in processing.api-docs
1 parent bb1d730 commit f2c3776

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

ngdoc/processors/component-groups-generate.js

+8-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 apiConfig = config.get('processing.api-docs');
17+
if ( !apiConfig ) {
18+
throw new Error('Invalid configuration. You must provide config.processing.api-docs');
19+
}
20+
1621
_.forEach(moduleMap, function(module) {
1722

1823
_(module.components)
@@ -22,6 +27,7 @@ module.exports = {
2227
delete docTypes.overview;
2328
})
2429
.map(function(docs, docType) {
30+
var templateParams = { area: module.area, module: module.name, docType: docType, name: 'index'};
2531
return {
2632
id: module.id + '.' + docType,
2733
docType: 'componentGroup',
@@ -30,8 +36,8 @@ module.exports = {
3036
moduleDoc: module,
3137
area: module.area,
3238
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 })
39+
outputPath: path.join(partialsPath, _.template(apiConfig.outputPath, templateParams)),
40+
path: _.template(apiConfig.path, templateParams)
3541
};
3642
})
3743
.tap(function(groups) {

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

+41
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var processor = require('../../processors/component-groups-generate');
33
var Config = require('dgeni').Config;
44

55
describe("component-groups processor", function() {
6+
67
it("should create a new doc for each group of components (by docType) in each module", function() {
78
var docs = [];
89
var modules = [{
@@ -20,8 +21,48 @@ describe("component-groups processor", function() {
2021

2122
config = new Config();
2223
config.set('rendering.contentsFolder', 'partials');
24+
config.set('processing.api-docs', {
25+
outputPath: '${area}/${module}/${docType}/${name}.html',
26+
path: '${area}/${module}/${docType}/${name}'
27+
});
28+
2329
processor.process(docs, config, modules);
2430

2531
expect(docs.length).toEqual(2);
32+
33+
});
34+
35+
36+
it("should use the outputPath and path specified in processing.api-docs", function() {
37+
var docs = [];
38+
var modules = [{
39+
id: 'mod1',
40+
name: 'test',
41+
area: 'api-docs',
42+
components: [
43+
{ docType: 'a', id: 'a1' },
44+
{ docType: 'a', id: 'a2' },
45+
{ docType: 'a', id: 'a3' },
46+
{ docType: 'a', id: 'a4' },
47+
{ docType: 'b', id: 'b1' },
48+
{ docType: 'b', id: 'b2' },
49+
{ docType: 'b', id: 'a3' }
50+
]
51+
}];
52+
53+
config = new Config();
54+
config.set('rendering.contentsFolder', 'partials');
55+
config.set('processing.api-docs', {
56+
outputPath: '${area}/${module}/${docType}/${name}.html',
57+
path: '${area}/${module}/${docType}/${name}'
58+
});
59+
60+
processor.process(docs, config, modules);
61+
62+
expect(docs[0].path).toBe('api-docs/test/a/index');
63+
expect(docs[0].outputPath).toBe('partials/api-docs/test/a/index.html');
64+
2665
});
66+
67+
2768
});

0 commit comments

Comments
 (0)