fix(aio): convert API and content docs to JSON
This commit is contained in:
parent
5e9474d24c
commit
dfed388139
|
@ -46,6 +46,7 @@ module.exports =
|
||||||
.processor(require('./processors/extractDecoratedClasses'))
|
.processor(require('./processors/extractDecoratedClasses'))
|
||||||
.processor(require('./processors/matchUpDirectiveDecorators'))
|
.processor(require('./processors/matchUpDirectiveDecorators'))
|
||||||
.processor(require('./processors/filterMemberDocs'))
|
.processor(require('./processors/filterMemberDocs'))
|
||||||
|
.processor(require('./processors/convertToJson'))
|
||||||
|
|
||||||
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
|
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
|
||||||
.factory('packageInfo', function() { return require(path.resolve(PROJECT_ROOT, 'package.json')); })
|
.factory('packageInfo', function() { return require(path.resolve(PROJECT_ROOT, 'package.json')); })
|
||||||
|
@ -211,12 +212,12 @@ module.exports =
|
||||||
doc.id.replace(/^@angular\//, API_SEGMENT + '/').replace(/\/index$/, '');
|
doc.id.replace(/^@angular\//, API_SEGMENT + '/').replace(/\/index$/, '');
|
||||||
return doc.moduleFolder;
|
return doc.moduleFolder;
|
||||||
},
|
},
|
||||||
outputPathTemplate: '${moduleFolder}/index.html'
|
outputPathTemplate: '${moduleFolder}/index.json'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe']),
|
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe']),
|
||||||
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
||||||
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.html',
|
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
docTypes: ['api-list-data', 'api-list-audit'],
|
docTypes: ['api-list-data', 'api-list-audit'],
|
||||||
|
@ -229,10 +230,17 @@ module.exports =
|
||||||
outputPathTemplate: '${path}'
|
outputPathTemplate: '${path}'
|
||||||
},
|
},
|
||||||
{docTypes: ['example-region'], getOutputPath: function() {}},
|
{docTypes: ['example-region'], getOutputPath: function() {}},
|
||||||
{docTypes: ['content'], pathTemplate: '${id}', outputPathTemplate: '${path}.html'}
|
{docTypes: ['content'], pathTemplate: '${id}', outputPathTemplate: '${path}.json'}
|
||||||
];
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
.config(function(convertToJsonProcessor, EXPORT_DOC_TYPES) {
|
||||||
|
convertToJsonProcessor.docTypes = EXPORT_DOC_TYPES.concat([
|
||||||
|
'content', 'decorator', 'directive', 'pipe', 'module'
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function requireFolder(folderPath) {
|
function requireFolder(folderPath) {
|
||||||
const absolutePath = path.resolve(__dirname, folderPath);
|
const absolutePath = path.resolve(__dirname, folderPath);
|
||||||
return fs.readdirSync(absolutePath)
|
return fs.readdirSync(absolutePath)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
module.exports = function convertToJsonProcessor() {
|
||||||
|
|
||||||
|
return {
|
||||||
|
$runAfter: ['checkUnbalancedBackTicks'],
|
||||||
|
$runBefore: ['writeFilesProcessor'],
|
||||||
|
docTypes: [],
|
||||||
|
$process: function(docs) {
|
||||||
|
const docTypes = this.docTypes
|
||||||
|
docs.forEach((doc) => {
|
||||||
|
if (docTypes.indexOf(doc.docType) !== -1) {
|
||||||
|
const output = {
|
||||||
|
title: doc.title || doc.name,
|
||||||
|
content: doc.renderedContent
|
||||||
|
};
|
||||||
|
doc.renderedContent = JSON.stringify(output, null, 2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
|
@ -102,7 +102,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
|
||||||
|
|
||||||
|
|
||||||
doc.searchTerms = {
|
doc.searchTerms = {
|
||||||
titleWords: extractTitleWords(doc.name),
|
titleWords: extractTitleWords(doc.title || doc.name),
|
||||||
keywords: words.sort().join(' '),
|
keywords: words.sort().join(' '),
|
||||||
members: members.sort().join(' ')
|
members: members.sort().join(' ')
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue