Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 8be7b5d

Browse files
chore(docs): update to dgeni-0.4.0
* update package with new services and computeId config * generateIndexPagesProcessor was not using log * use StringMap not ES6-shim Map in errorNamespaceMap * remove unused dependencies from generateErrorDocsProcessor * ensure generatePagesDataProcessor adds its doc to the collection * debugDumpProcessor was moved to dgeni-packages
1 parent a3fbf0f commit 8be7b5d

25 files changed

+861
-928
lines changed

docs/config/index.js

Lines changed: 141 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,153 @@
1-
var _ = require('lodash');
1+
"use strict";
2+
23
var path = require('canonical-path');
34
var packagePath = __dirname;
45

5-
var basePackage = require('dgeni-packages/ngdoc');
6-
var examplesPackage = require('dgeni-packages/examples');
6+
var Package = require('dgeni').Package;
7+
8+
// Create and export a new Dgeni package called dgeni-example. This package depends upon
9+
// the jsdoc and nunjucks packages defined in the dgeni-packages npm module.
10+
module.exports = new Package('angularjs', [
11+
require('dgeni-packages/ngdoc'),
12+
require('dgeni-packages/nunjucks'),
13+
require('dgeni-packages/examples')
14+
])
15+
16+
17+
.factory(require('./services/errorNamespaceMap'))
18+
.factory(require('./services/getMinerrInfo'))
19+
.factory(require('./services/getVersion'))
20+
.factory(require('./services/gitData'))
21+
22+
.factory(require('./services/deployments/debug'))
23+
.factory(require('./services/deployments/default'))
24+
.factory(require('./services/deployments/jquery'))
25+
.factory(require('./services/deployments/production'))
26+
27+
.factory(require('./inline-tag-defs/type'))
28+
29+
30+
.processor(require('./processors/error-docs'))
31+
.processor(require('./processors/index-page'))
32+
.processor(require('./processors/keywords'))
33+
.processor(require('./processors/pages-data'))
34+
.processor(require('./processors/versions-data'))
35+
36+
37+
.config(function(dgeni, log, readFilesProcessor, writeFilesProcessor) {
38+
39+
dgeni.stopOnValidationError = true;
40+
dgeni.stopOnProcessingError = true;
41+
42+
log.level = 'info';
43+
44+
readFilesProcessor.basePath = path.resolve(__dirname,'../..');
45+
readFilesProcessor.sourceFiles = [
46+
{ include: 'src/**/*.js', basePath: 'src' },
47+
{ include: 'docs/content/**/*.ngdoc', basePath: 'docs/content' }
48+
];
49+
50+
writeFilesProcessor.outputFolder = 'build/docs';
51+
52+
})
53+
54+
55+
.config(function(parseTagsProcessor) {
56+
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/tutorial-step'));
57+
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/sortOrder'));
58+
})
59+
60+
61+
.config(function(inlineTagProcessor, typeInlineTagDef) {
62+
inlineTagProcessor.inlineTagDefinitions.push(typeInlineTagDef);
63+
})
64+
65+
66+
.config(function(templateFinder, renderDocsProcessor, gitData) {
67+
templateFinder.templateFolders.unshift(path.resolve(packagePath, 'templates'));
68+
renderDocsProcessor.extraData.git = gitData;
69+
})
70+
71+
72+
.config(function(computePathsProcessor, computeIdsProcessor) {
73+
74+
computePathsProcessor.pathTemplates.push({
75+
docTypes: ['error'],
76+
pathTemplate: 'error/${namespace}/${name}',
77+
outputPathTemplate: 'partials/error/${namespace}/${name}.html'
78+
});
79+
80+
computePathsProcessor.pathTemplates.push({
81+
docTypes: ['errorNamespace'],
82+
pathTemplate: 'error/${name}',
83+
outputPathTemplate: 'partials/error/${name}.html'
84+
});
85+
86+
computePathsProcessor.pathTemplates.push({
87+
docTypes: ['overview', 'tutorial'],
88+
getPath: function(doc) {
89+
var docPath = path.dirname(doc.fileInfo.relativePath);
90+
if ( doc.fileInfo.baseName !== 'index' ) {
91+
docPath = path.join(docPath, doc.fileInfo.baseName);
92+
}
93+
return docPath;
94+
},
95+
getOutputPath: function(doc) {
96+
return 'partials/' + doc.path +
97+
( doc.fileInfo.baseName === 'index' ? '/index.html' : '.html');
98+
}
99+
});
100+
101+
computePathsProcessor.pathTemplates.push({
102+
docTypes: ['e2e-test'],
103+
getPath: function() {},
104+
outputPathTemplate: 'ptore2e/${example.id}/${deployment.name}_test.js'
105+
});
7106

8-
module.exports = function(config) {
107+
computePathsProcessor.pathTemplates.push({
108+
docTypes: ['indexPage'],
109+
getPath: function() {},
110+
outputPathTemplate: '${id}.html'
111+
});
9112

10-
config = basePackage(config);
11-
config = examplesPackage(config);
12113

13-
config.append('processing.processors', [
14-
require('./processors/git-data'),
15-
require('./processors/error-docs'),
16-
require('./processors/keywords'),
17-
require('./processors/versions-data'),
18-
require('./processors/pages-data'),
19-
require('./processors/protractor-generate'),
20-
require('./processors/index-page'),
21-
require('./processors/debug-dump')
22-
]);
114+
computeIdsProcessor.idTemplates.push({
115+
docTypes: ['overview', 'tutorial', 'e2e-test', 'indexPage'],
116+
getId: function(doc) { return doc.fileInfo.baseName; },
117+
getAliases: function(doc) { return [doc.id]; }
118+
});
23119

24-
config.append('processing.tagDefinitions', [
25-
require('./tag-defs/tutorial-step'),
26-
require('./tag-defs/sortOrder')
27-
]);
120+
computeIdsProcessor.idTemplates.push({
121+
docTypes: ['error', 'errorNamespace'],
122+
getId: function(doc) { return 'error:' + doc.name; },
123+
getAliases: function(doc) { return [doc.id]; }
124+
});
125+
})
28126

29-
config.append('processing.defaultTagTransforms', [
30-
require('dgeni-packages/jsdoc/tag-defs/transforms/trim-whitespace')
31-
]);
32127

33-
config.append('processing.inlineTagDefinitions', [
34-
require('./inline-tag-defs/type')
35-
]);
128+
.config(function(
129+
generateIndexPagesProcessor,
130+
generateProtractorTestsProcessor,
131+
generateExamplesProcessor,
132+
debugDeployment, defaultDeployment,
133+
jqueryDeployment, productionDeployment) {
36134

37-
config.set('processing.search.ignoreWordsFile', path.resolve(packagePath, 'ignore.words'));
135+
generateIndexPagesProcessor.deployments = [
136+
debugDeployment,
137+
defaultDeployment,
138+
jqueryDeployment,
139+
productionDeployment
140+
];
38141

39-
config.prepend('rendering.templateFolders', [
40-
path.resolve(packagePath, 'templates')
41-
]);
142+
generateProtractorTestsProcessor.deployments = [
143+
defaultDeployment,
144+
jqueryDeployment
145+
];
42146

43-
return config;
44-
};
147+
generateExamplesProcessor.deployments = [
148+
debugDeployment,
149+
defaultDeployment,
150+
jqueryDeployment,
151+
productionDeployment
152+
];
153+
});

docs/config/inline-tag-defs/type.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
var typeClassFilter = require('dgeni-packages/ngdoc/rendering/filters/type-class');
1+
"use strict";
2+
23
var encoder = new require('node-html-encoder').Encoder();
34

4-
module.exports = {
5-
name: 'type',
6-
description: 'Replace with markup that displays a nice type',
7-
handlerFactory: function() {
8-
return function(doc, tagName, tagDescription) {
9-
return '<a href="" class="' + typeClassFilter.process(tagDescription) + '">'+encoder.htmlEncode(tagDescription) + '</a>';
10-
};
11-
}
12-
};
5+
/**
6+
* @dgService typeInlineTagDef
7+
* @description
8+
* Replace with markup that displays a nice type
9+
*/
10+
module.exports = function typeInlineTagDef(getTypeClass) {
11+
return {
12+
name: 'type',
13+
handler: function(doc, tagName, tagDescription) {
14+
return '<a href="" class="' + getTypeClass(tagDescription) + '">'+encoder.htmlEncode(tagDescription) + '</a>';
15+
}
16+
};
17+
};

docs/config/processors/debug-dump.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/config/processors/error-docs.js

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,52 @@
1+
"use strict";
2+
13
var _ = require('lodash');
2-
var log = require('winston');
34
var path = require('canonical-path');
45

5-
module.exports = {
6-
name: 'error-docs',
7-
description: 'Compute the various fields for docs in the Error area',
8-
runAfter: ['tags-extracted', 'compute-path'],
9-
runBefore: ['extra-docs-added'],
10-
exports: {
11-
errorNamespaces: ['factory', function() { return {}; }],
12-
minerrInfo: ['factory', function(config) {
13-
var minerrInfoPath = config.get('processing.errors.minerrInfoPath');
14-
if ( !minerrInfoPath ) {
15-
throw new Error('Error in configuration: Please provide a path to the minerr info file (errors.json) ' +
16-
'in the `config.processing.errors.minerrInfoPath` property');
17-
}
18-
return require(minerrInfoPath);
19-
}]
20-
},
21-
process: function(docs, partialNames, errorNamespaces, minerrInfo) {
22-
23-
// Create error namespace docs and attach error docs to each
24-
_.forEach(docs, function(doc) {
25-
if ( doc.docType === 'error' ) {
26-
27-
// Parse out the error info from the id
28-
parts = doc.name.split(':');
29-
doc.namespace = parts[0];
30-
doc.name = parts[1];
31-
32-
33-
var namespaceDoc = errorNamespaces[doc.namespace];
34-
if ( !namespaceDoc ) {
35-
// First time we came across this namespace, so create a new one
36-
namespaceDoc = errorNamespaces[doc.namespace] = {
37-
area: doc.area,
38-
name: doc.namespace,
39-
errors: [],
40-
path: path.dirname(doc.path),
41-
outputPath: path.dirname(doc.outputPath) + '.html',
42-
docType: 'errorNamespace'
43-
};
6+
/**
7+
* @dgProcessor errorDocsProcessor
8+
* @description
9+
* Process "error" docType docs and generate errorNamespace docs
10+
*/
11+
module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
12+
return {
13+
$runAfter: ['tags-extracted'],
14+
$runBefore: ['extra-docs-added'],
15+
$process: function(docs) {
16+
17+
// Create error namespace docs and attach error docs to each
18+
docs.forEach(function(doc) {
19+
var parts, namespaceDoc;
20+
21+
if ( doc.docType === 'error' ) {
22+
23+
// Parse out the error info from the id
24+
parts = doc.name.split(':');
25+
doc.namespace = parts[0];
26+
doc.name = parts[1];
27+
28+
// Get or create the relevant errorNamespace doc
29+
namespaceDoc = errorNamespaceMap.get(doc.namespace);
30+
if ( !namespaceDoc ) {
31+
namespaceDoc = {
32+
area: 'error',
33+
name: doc.namespace,
34+
errors: [],
35+
docType: 'errorNamespace'
36+
};
37+
errorNamespaceMap.set(doc.namespace, namespaceDoc);
38+
}
39+
40+
// Link this error doc to its namespace doc
41+
namespaceDoc.errors.push(doc);
42+
doc.namespaceDoc = namespaceDoc;
43+
doc.formattedErrorMessage = getMinerrInfo().errors[doc.namespace][doc.name];
4444
}
45-
46-
// Add this error to the namespace
47-
namespaceDoc.errors.push(doc);
48-
doc.namespace = namespaceDoc;
49-
50-
doc.formattedErrorMessage = minerrInfo.errors[doc.namespace.name][doc.name];
51-
52-
}
53-
54-
});
55-
56-
57-
return docs.concat(_.values(errorNamespaces));
58-
}
59-
};
45+
});
46+
47+
errorNamespaceMap.forEach(function(errorNamespace) {
48+
docs.push(errorNamespace);
49+
});
50+
}
51+
};
52+
};

docs/config/processors/git-data.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)