build(docs-infra): display github links in CLI API docs (#26515)
This commit includes the following changes: * CLI version information is read from the CLI package from which we read the help files. * CLI API pages now contain GH links * line numbers are not shown in GH links, if the doc does not have a truthy `startingLine` value. This allows us to remove hard coded checks for `guide` pages * content pages and CLI api docs no longer have a `startingLine` * the hard-coded `packages` path segment has been removed from the templates; instead we now only use the `realProjectRelativePath`. * the `realProjectRelativePath` has been updated accordingly for API and CLI API docs. PR Close #26515
This commit is contained in:

committed by
Alex Rickabaugh

parent
9e8903ada1
commit
4c0ad5238e
@ -34,6 +34,7 @@ module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
.processor(require('./processors/removeInjectableConstructors'))
|
||||
.processor(require('./processors/processPackages'))
|
||||
.processor(require('./processors/processNgModuleDocs'))
|
||||
.processor(require('./processors/fixupRealProjectRelativePath'))
|
||||
|
||||
|
||||
/**
|
||||
|
14
aio/tools/transforms/angular-api-package/processors/fixupRealProjectRelativePath.js
vendored
Normal file
14
aio/tools/transforms/angular-api-package/processors/fixupRealProjectRelativePath.js
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
module.exports = function fixupRealProjectRelativePath(API_DOC_TYPES) {
|
||||
return {
|
||||
$runAfter: ['readTypeScriptModules'],
|
||||
$runBefore: ['processing-docs'],
|
||||
$process(docs) {
|
||||
docs.forEach(doc => {
|
||||
if (API_DOC_TYPES.indexOf(doc.docType) !== -1 && doc.fileInfo && doc.fileInfo.realProjectRelativePath) {
|
||||
// this is an API doc - so fix up its real path
|
||||
doc.fileInfo.realProjectRelativePath = 'packages/' + doc.fileInfo.realProjectRelativePath;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
@ -0,0 +1,36 @@
|
||||
const testPackage = require('../../helpers/test-package');
|
||||
const processorFactory = require('./fixupRealProjectRelativePath');
|
||||
const Dgeni = require('dgeni');
|
||||
|
||||
describe('fixupRealProjectRelativePath processor', () => {
|
||||
|
||||
it('should be available on the injector', () => {
|
||||
const dgeni = new Dgeni([testPackage('angular-api-package')]);
|
||||
const injector = dgeni.configureInjector();
|
||||
const processor = injector.get('fixupRealProjectRelativePath');
|
||||
expect(processor.$process).toBeDefined();
|
||||
expect(processor.$runAfter).toContain('readTypeScriptModules');
|
||||
expect(processor.$runBefore).toContain('processing-docs');
|
||||
});
|
||||
|
||||
it('should add `packages` segment to the start of `realProjectRelativePath` for API docs', () => {
|
||||
const processor = processorFactory(['class', 'member']);
|
||||
const docs = [
|
||||
{ docType: 'class', fileInfo: { realProjectRelativePath: 'a/b/c' } },
|
||||
{ docType: 'member', fileInfo: { realProjectRelativePath: 'a/b/c/d' } },
|
||||
{ docType: 'cli-command', fileInfo: { realProjectRelativePath: 'a/b/c' } },
|
||||
{ docType: 'class', fileInfo: { } },
|
||||
{ docType: 'class' },
|
||||
];
|
||||
processor.$process(docs);
|
||||
|
||||
expect(docs).toEqual([
|
||||
{ docType: 'class', fileInfo: { realProjectRelativePath: 'packages/a/b/c' } },
|
||||
{ docType: 'member', fileInfo: { realProjectRelativePath: 'packages/a/b/c/d' } },
|
||||
{ docType: 'cli-command', fileInfo: { realProjectRelativePath: 'a/b/c' } },
|
||||
{ docType: 'class', fileInfo: { } },
|
||||
{ docType: 'class' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user