Skip to content

Commit

Permalink
feat(@angular/cli): add usage notes to help JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Sep 19, 2018
1 parent e6f9ae9 commit 3bb6548
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/angular/cli/models/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,22 @@ export enum CommandType {
Default = Custom,
}

/**
* A description of a command, its metadata.
*/
export interface CommandDescription {
name: string;
description: string;

/**
* A long description of the option, in Markdown format.
*/
longDescription: string;
longDescription?: string;

/**
* Additional notes about usage of this command.
*/
usageNotes?: string;

options: Option[];

Expand Down
18 changes: 17 additions & 1 deletion packages/angular/cli/utilities/json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3bb6548

Please sign in to comment.