Skip to content

Commit 3bb6548

Browse files
committed
feat(@angular/cli): add usage notes to help JSON
1 parent e6f9ae9 commit 3bb6548

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

packages/angular/cli/models/interface.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,22 @@ export enum CommandType {
112112
Default = Custom,
113113
}
114114

115+
/**
116+
* A description of a command, its metadata.
117+
*/
115118
export interface CommandDescription {
116119
name: string;
117120
description: string;
118121

119122
/**
120123
* A long description of the option, in Markdown format.
121124
*/
122-
longDescription: string;
125+
longDescription?: string;
126+
127+
/**
128+
* Additional notes about usage of this command.
129+
*/
130+
usageNotes?: string;
123131

124132
options: Option[];
125133

packages/angular/cli/utilities/json-schema.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,29 @@ export async function parseJsonSchemaToCommandDescription(
7373
const ldPath = resolve(dirname(jsonPath), schema.$longDescription);
7474
longDescription = readFileSync(ldPath, 'utf-8');
7575
}
76+
let usageNotes = '';
77+
if (typeof schema.$usageNotes == 'string' && schema.$usageNotes) {
78+
const unPath = resolve(dirname(jsonPath), schema.$usageNotes);
79+
usageNotes = readFileSync(unPath, 'utf-8');
80+
}
7681

7782
const scope = _getEnumFromValue(schema.$scope, CommandScope, CommandScope.Default);
7883
const type = _getEnumFromValue(schema.$type, CommandType, CommandType.Default);
7984
const description = '' + (schema.description === undefined ? '' : schema.description);
8085
const hidden = !!schema.$hidden;
8186

82-
return { name, description, longDescription, hidden, type, options, aliases, scope, impl };
87+
return {
88+
name,
89+
description,
90+
...(longDescription ? { longDescription } : {}),
91+
...(usageNotes ? { usageNotes } : {}),
92+
hidden,
93+
type,
94+
options,
95+
aliases,
96+
scope,
97+
impl,
98+
};
8399
}
84100

85101
export async function parseJsonSchemaToOptions(

0 commit comments

Comments
 (0)