Pete Bacon Darwin d509bd6849 build(aio): improve the API Pipe pages (#22702)
This change adds:

* an impure badge for Pipes that are marked as  `pure: false`
* a pipe specific overview that shows the syntax for using a pipe in a template.
* an "input value" section describing the type of the value that the pipe expects.
* a "pipe params" section describing any additional params that a pipe expects.

PR Close #22702
2018-03-14 14:21:11 -07:00

20 lines
753 B
JavaScript

module.exports = function extractPipeParams(createDocMessage) {
return {
$runAfter: ['extractDecoratedClassesProcessor'],
$runBefore: ['docs-processed'],
$process(docs) {
docs.forEach(doc => {
if (doc.docType === 'pipe') {
const transformFn = doc.members && doc.members.find(member => member.name === 'transform');
if (!transformFn) {
throw new Error(createDocMessage('Missing `transform` method - pipes must implement PipeTransform interface', doc));
}
doc.pipeName = doc.pipeOptions.name.replace(/^["']|["']$/g, '');
doc.valueParam = transformFn.parameterDocs[0];
doc.pipeParams = transformFn.parameterDocs.slice(1);
}
});
}
};
};