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
This commit is contained in:

committed by
Kara Erickson

parent
cd2ebd22fd
commit
d509bd6849
19
aio/tools/transforms/angular-api-package/processors/extractPipeParams.js
vendored
Normal file
19
aio/tools/transforms/angular-api-package/processors/extractPipeParams.js
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user