fix(aio): convert API and content docs to JSON

This commit is contained in:
Peter Bacon Darwin 2017-02-21 16:57:19 +00:00 committed by Igor Minar
parent 5e9474d24c
commit dfed388139
3 changed files with 32 additions and 4 deletions

View File

@ -46,6 +46,7 @@ module.exports =
.processor(require('./processors/extractDecoratedClasses'))
.processor(require('./processors/matchUpDirectiveDecorators'))
.processor(require('./processors/filterMemberDocs'))
.processor(require('./processors/convertToJson'))
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
.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$/, '');
return doc.moduleFolder;
},
outputPathTemplate: '${moduleFolder}/index.html'
outputPathTemplate: '${moduleFolder}/index.json'
},
{
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe']),
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.html',
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
},
{
docTypes: ['api-list-data', 'api-list-audit'],
@ -229,10 +230,17 @@ module.exports =
outputPathTemplate: '${path}'
},
{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) {
const absolutePath = path.resolve(__dirname, folderPath);
return fs.readdirSync(absolutePath)

View File

@ -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);
}
});
}
};
};

View File

@ -102,7 +102,7 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
doc.searchTerms = {
titleWords: extractTitleWords(doc.name),
titleWords: extractTitleWords(doc.title || doc.name),
keywords: words.sort().join(' '),
members: members.sort().join(' ')
};