This repository was archived by the owner on Dec 4, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 877
/
Copy pathindex.js
158 lines (128 loc) · 5.01 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
var fs = require('fs');
var path = require('canonical-path');
var Package = require('dgeni').Package;
var basePackage = require('../docs-package');
var targetPackage = require('../target-package');
var cheatsheetPackage = require('../cheatsheet-package');
var PROJECT_PATH = path.resolve(__dirname, "../../..");
var PUBLIC_PATH = path.resolve(PROJECT_PATH, 'public');
var DOCS_PATH = path.resolve(PUBLIC_PATH, 'docs');
var ANGULAR2_DOCS_PATH = path.resolve(__dirname, '../../../../angular/modules/@angular/docs');
module.exports = new Package('angular.io', [basePackage, targetPackage, cheatsheetPackage])
.factory(require('./services/renderMarkdown'))
.processor(require('./processors/addJadeDataDocsProcessor'))
.processor(require('./processors/matchUpDirectiveDecorators'))
.processor(require('./processors/filterMemberDocs'))
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
.factory(require('./services/packageInfo'))
// Configure rendering
.config(function(templateFinder, templateEngine, renderDocsProcessor) {
templateFinder.templateFolders
.unshift(path.resolve(__dirname, 'templates'));
// helpers are made available to the nunjucks templates
renderDocsProcessor.helpers.relativePath = function(from, to) {
return path.relative(from, to);
};
})
.config(function(parseTagsProcessor, getInjectables) {
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions.concat(getInjectables(require('./tag-defs')));
})
.config(function(readTypeScriptModules, writeFilesProcessor, readFilesProcessor) {
var angular_repo_path = path.resolve(__dirname, '../../../../angular');
// confirm that the angular repo is actually there.
if (!fs.existsSync(angular_repo_path)) {
throw new Error('build-api-docs task requires the angular repo to be at ' + angular_repo_path);
}
readTypeScriptModules.basePath = path.resolve(angular_repo_path, 'packages');
readTypeScriptModules.ignoreExportsMatching = [/^(_|ɵ)/];
readTypeScriptModules.sourceFiles = [
'animations/index.ts',
'animations/browser/index.ts',
'animations/browser/testing.ts',
'common/index.ts',
'common/testing/index.ts',
'core/index.ts',
'core/testing/index.ts',
'forms/index.ts',
'http/index.ts',
'http/testing/index.ts',
'platform-browser/index.ts',
'platform-browser/animations/index.ts',
'platform-browser/testing/index.ts',
'platform-browser-dynamic/index.ts',
'platform-browser-dynamic/testing/index.ts',
'platform-server/index.ts',
'platform-server/testing/index.ts',
'platform-webworker/index.ts',
'platform-webworker-dynamic/index.ts',
'router/index.ts',
'router/testing/index.ts',
'upgrade/index.ts',
'upgrade/static/index.ts'
];
readTypeScriptModules.hidePrivateMembers = true;
readFilesProcessor.basePath = DOCS_PATH;
readFilesProcessor.sourceFiles = [{
basePath: ANGULAR2_DOCS_PATH,
include: path.resolve(ANGULAR2_DOCS_PATH, 'cheatsheet/*.md')
}];
})
.config(function(getLinkInfo) {
getLinkInfo.useFirstAmbiguousLink = false;
})
.config(function(readFilesProcessor, generateNavigationDoc) {
// Clear out unwanted processors
generateNavigationDoc.$enabled = false;
})
.config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) {
computePathsProcessor.pathTemplates.push({
docTypes: ['module'],
getPath: function computeModulePath(doc) {
doc.moduleFolder = doc.id.replace(/^@angular\//, '');
return doc.moduleFolder + '/index.html';
},
getOutputPath: function computeModulePath(doc) {
return doc.moduleFolder + '/index.jade';
}
});
computePathsProcessor.pathTemplates.push({
docTypes: EXPORT_DOC_TYPES,
pathTemplate: '${moduleDoc.moduleFolder}/${name}-${docType}.html',
outputPathTemplate:'${moduleDoc.moduleFolder}/${name}-${docType}.jade',
});
computePathsProcessor.pathTemplates.push({
docTypes: ['decorator'],
pathTemplate: '${moduleDoc.moduleFolder}/${name}-${docType}.html',
outputPathTemplate:'${moduleDoc.moduleFolder}/${name}-${docType}.jade',
});
computePathsProcessor.pathTemplates.push({
docTypes: ['jade-data'],
pathTemplate: '${originalDoc.moduleFolder}/_data',
outputPathTemplate: '${path}.json'
});
computePathsProcessor.pathTemplates.push({
docTypes: ['api-list-data'],
pathTemplate: 'api-list.json',
outputPathTemplate: '${path}'
});
computePathsProcessor.pathTemplates.push({
docTypes: ['api-list-audit'],
pathTemplate: 'api-list-audit.json',
outputPathTemplate: '${path}'
});
computePathsProcessor.pathTemplates.push({
docTypes: ['cheatsheet-data'],
pathTemplate: '../guide/cheatsheet.json',
outputPathTemplate: '${path}'
});
})
.config(function(getLinkInfo) {
getLinkInfo.relativeLinks = true;
})
.config(function(templateEngine, getInjectables) {
templateEngine.filters = templateEngine.filters.concat(getInjectables([
require('./rendering/trimBlankLines'),
require('./rendering/toId'),
require('./rendering/indentForMarkdown')
]));
});