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
a4fcd07792
commit
4fd9988251
@ -3,7 +3,9 @@ const Package = require('dgeni').Package;
|
||||
const basePackage = require('../angular-base-package');
|
||||
const contentPackage = require('../content-package');
|
||||
const {CONTENTS_PATH, TEMPLATES_PATH, requireFolder} = require('../config');
|
||||
|
||||
const CLI_SOURCE_ROOT = resolve(CONTENTS_PATH, 'cli-src');
|
||||
const CLI_SOURCE_PATH = resolve(CLI_SOURCE_ROOT, 'node_modules/@angular/cli');
|
||||
const CLI_SOURCE_HELP_PATH = resolve(CLI_SOURCE_PATH, 'help');
|
||||
|
||||
// Define the dgeni package for generating the docs
|
||||
module.exports = new Package('cli-docs', [basePackage, contentPackage])
|
||||
@ -18,12 +20,11 @@ module.exports = new Package('cli-docs', [basePackage, contentPackage])
|
||||
|
||||
// Configure file reading
|
||||
.config(function(readFilesProcessor, cliCommandFileReader) {
|
||||
const CLI_SOURCE_PATH = resolve(CONTENTS_PATH, 'cli-src/node_modules/@angular/cli/help');
|
||||
readFilesProcessor.fileReaders.push(cliCommandFileReader);
|
||||
readFilesProcessor.sourceFiles = readFilesProcessor.sourceFiles.concat([
|
||||
{
|
||||
basePath: CLI_SOURCE_PATH,
|
||||
include: resolve(CLI_SOURCE_PATH, '*.json'),
|
||||
basePath: CLI_SOURCE_HELP_PATH,
|
||||
include: resolve(CLI_SOURCE_HELP_PATH, '*.json'),
|
||||
fileReader: 'cliCommandFileReader'
|
||||
},
|
||||
{
|
||||
@ -42,6 +43,23 @@ module.exports = new Package('cli-docs', [basePackage, contentPackage])
|
||||
})
|
||||
|
||||
|
||||
.config(function(renderDocsProcessor) {
|
||||
|
||||
const cliPackage = require(resolve(CLI_SOURCE_PATH, 'package.json'));
|
||||
const repoUrlParts = cliPackage.repository.url.replace(/\.git$/, '').split('/');
|
||||
const version = `v${cliPackage.version}`;
|
||||
const repo = repoUrlParts.pop();
|
||||
const owner = repoUrlParts.pop();
|
||||
const cliVersionInfo = {
|
||||
gitRepoInfo: { owner, repo },
|
||||
currentVersion: { raw: version }
|
||||
};
|
||||
|
||||
// Add the cli version data to the renderer, for use in things like github links
|
||||
renderDocsProcessor.extraData.cliVersionInfo = cliVersionInfo;
|
||||
})
|
||||
|
||||
|
||||
.config(function(convertToJsonProcessor, postProcessHtml) {
|
||||
convertToJsonProcessor.docTypes = convertToJsonProcessor.docTypes.concat(['cli-command', 'cli-overview']);
|
||||
postProcessHtml.docTypes = postProcessHtml.docTypes.concat(['cli-command', 'cli-overview']);
|
||||
|
Reference in New Issue
Block a user