This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
/
index.js
78 lines (65 loc) · 2.49 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const path = require('canonical-path');
const Package = require('dgeni').Package;
const projectPath = path.resolve(__dirname, '../..');
const packagePath = __dirname;
module.exports = new Package('angular-md', [
require('dgeni-packages/ngdoc'),
require('dgeni-packages/nunjucks')
])
.processor(require('./processors/componentsData'))
.processor(require('./processors/indexPage'))
.processor(require('./processors/buildConfig'))
.processor(require('./processors/content'))
.config(function(log, templateEngine, templateFinder) {
templateFinder.templateFolders = [
path.resolve(packagePath, 'template'),
path.resolve(packagePath, 'template/ngdoc'),
path.resolve(packagePath, '../app-template')
];
})
.config(function(readFilesProcessor, writeFilesProcessor) {
readFilesProcessor.basePath = projectPath;
readFilesProcessor.sourceFiles = [
{ include: 'src/components/**/*.js', basePath: '.' },
{ include: 'src/core/**/*.js', basePath: '.' },
{ include: 'docs/content/**/*.md', basePath: 'docs/content', fileReader: 'ngdocFileReader' }
];
writeFilesProcessor.outputFolder = 'dist/docs';
})
.config(function(computeIdsProcessor, computePathsProcessor) {
computeIdsProcessor.idTemplates.push({
docTypes: ['content'],
idTemplate: { getId: ({ fileInfo }) => `content-${fileInfo.relativePath.replace("/","-")}` },
getAliases: function(doc) { return [doc.id]; }
});
// Build custom paths and outputPaths for "content" pages (theming and CSS).
computePathsProcessor.pathTemplates.push({
docTypes: ['content'],
getPath: function(doc) {
let docPath = path.dirname(doc.fileInfo.relativePath);
if (doc.fileInfo.baseName !== 'index') {
docPath = path.join(docPath, doc.fileInfo.baseName);
}
return docPath;
},
getOutputPath: function(doc) {
return path.join(
'partials',
path.dirname(doc.fileInfo.relativePath),
doc.fileInfo.baseName) + '.html';
}
});
// The default dgeni path for directives and services is something like
// "api/material.components.autocomplete/directive/mdAutocomplete".
// The module name is rather unnecessary, so we override with the shorter
// "api/directive/mdAutocomplete".
computePathsProcessor.pathTemplates.push({
docTypes: ['directive', 'service', 'type'],
getPath: function(doc) {
return path.join(doc.area, doc.docType, doc.name);
}
});
})
.config(function(generateComponentGroupsProcessor) {
generateComponentGroupsProcessor.$enabled = false;
});