feat(@angular/cli): add usage notes to help JSON

This commit is contained in:
Hans 2018-09-17 14:40:57 -07:00
parent e6f9ae98f5
commit 3bb6548d15
2 changed files with 26 additions and 2 deletions

View File

@ -112,6 +112,9 @@ export enum CommandType {
Default = Custom,
}
/**
* A description of a command, its metadata.
*/
export interface CommandDescription {
name: string;
description: string;
@ -119,7 +122,12 @@ export interface CommandDescription {
/**
* A long description of the option, in Markdown format.
*/
longDescription: string;
longDescription?: string;
/**
* Additional notes about usage of this command.
*/
usageNotes?: string;
options: Option[];

View File

@ -73,13 +73,29 @@ export async function parseJsonSchemaToCommandDescription(
const ldPath = resolve(dirname(jsonPath), schema.$longDescription);
longDescription = readFileSync(ldPath, 'utf-8');
}
let usageNotes = '';
if (typeof schema.$usageNotes == 'string' && schema.$usageNotes) {
const unPath = resolve(dirname(jsonPath), schema.$usageNotes);
usageNotes = readFileSync(unPath, 'utf-8');
}
const scope = _getEnumFromValue(schema.$scope, CommandScope, CommandScope.Default);
const type = _getEnumFromValue(schema.$type, CommandType, CommandType.Default);
const description = '' + (schema.description === undefined ? '' : schema.description);
const hidden = !!schema.$hidden;
return { name, description, longDescription, hidden, type, options, aliases, scope, impl };
return {
name,
description,
...(longDescription ? { longDescription } : {}),
...(usageNotes ? { usageNotes } : {}),
hidden,
type,
options,
aliases,
scope,
impl,
};
}
export async function parseJsonSchemaToOptions(