@@ -76,7 +76,7 @@ export class Docs {
76
76
if ( ! isArray ( subtopicOrCommand ) ) {
77
77
// If it is not subtopic (array) it is a command in the top-level topic
78
78
const command = subtopicOrCommand ;
79
- const commandMeta = this . resolveCommandMeta ( ensureString ( command . id ) ) ;
79
+ const commandMeta = this . resolveCommandMeta ( ensureString ( command . id ) , command , 1 ) ;
80
80
await this . populateCommand ( topic , null , command , commandMeta ) ;
81
81
commandNames . push ( subtopic ) ;
82
82
continue ;
@@ -105,7 +105,9 @@ export class Docs {
105
105
// Commands within the sub topic
106
106
const filenames : string [ ] = [ ] ;
107
107
for ( const command of subtopicOrCommand ) {
108
- const commandMeta = this . resolveCommandMeta ( ensureString ( command . id ) ) ;
108
+ const fullTopic = ensureString ( command . id ) . replace ( / : \w + $ / , '' ) ;
109
+ const commandsInFullTopic = subtopicOrCommand . filter ( cmd => ensureString ( cmd . id ) . indexOf ( fullTopic ) === 0 ) ;
110
+ const commandMeta = this . resolveCommandMeta ( ensureString ( command . id ) , command , commandsInFullTopic . length ) ;
109
111
110
112
filenames . push ( await this . populateCommand ( topic , subtopic , command , commandMeta ) ) ;
111
113
}
@@ -198,7 +200,7 @@ export class Docs {
198
200
}
199
201
}
200
202
201
- private resolveCommandMeta ( commandId : string ) {
203
+ private resolveCommandMeta ( commandId : string , command , commandsInTopic : number ) {
202
204
const commandMeta : JsonMap = { } ;
203
205
// Remove top level topic, since the topic meta is already for that topic
204
206
const commandParts = commandId . split ( ':' ) ;
@@ -221,7 +223,15 @@ export class Docs {
221
223
// This means there wasn't meta information going all the way down to the command, which is ok.
222
224
return commandMeta ;
223
225
} else {
224
- events . emit ( 'warning' , `subtopic "${ part } " meta not found for command ${ commandId } ` ) ;
226
+ if ( commandsInTopic !== 1 ) {
227
+ events . emit ( 'warning' , `subtopic "${ part } " meta not found for command ${ commandId } ` ) ;
228
+ } else {
229
+ // Since there is no command meta, just use the command description since that is what oclif does.
230
+ if ( ! commandMeta . description ) {
231
+ commandMeta . description = command . description ;
232
+ commandMeta . longDescription = command . longDescription ;
233
+ }
234
+ }
225
235
}
226
236
}
227
237
return commandMeta ;
0 commit comments