@@ -218,24 +218,58 @@ function conciseMetaLine(author, lastUpdated, tags) {
218218 return meta . length ? `\n---\n\n_${ meta . join ( ' • ' ) } _\n` : '' ;
219219}
220220
221+ function generateMiniSubtocTOC ( obj ) {
222+ if ( ! obj . subtoc || ! obj . subtoc . length ) return '' ;
223+ let out = '## Subcommands\n' ;
224+ obj . subtoc . forEach ( ( sub ) => {
225+ out += `- [${ sub . Name } ](./${ slugify ( sub . Name ) } .md)` ;
226+ if ( sub . short_description ) out += `: ${ sub . short_description } ` ;
227+ out += '\n' ;
228+ } ) ;
229+ return out + '\n' ;
230+ }
231+
232+ function hasOnlySubtocContent ( obj ) {
233+ // Returns true if the main file has no meaningful content except subtoc
234+ return ! (
235+ obj . long_description ||
236+ obj . command ||
237+ obj . flags ||
238+ obj . examples ||
239+ obj [ 'command similiar examples' ] ||
240+ obj . steps ||
241+ obj . prerequisites ||
242+ obj . warnings ||
243+ obj . links ||
244+ obj . related_commands ||
245+ obj . output_example
246+ ) ;
247+ }
248+
221249function generateContentFile ( obj , idx , tocData ) {
222250 let slug = slugify ( obj . Name ) ;
223251 let md = `[⬅️ Back to Table of Contents](../README.md#${ slug } )\n\n` ;
224252 md += `# ${ obj . Name } \n\n` ;
225253 if ( obj . category ) md += renderCategory ( obj . category ) ;
226254 if ( obj . short_description ) md += `> ${ obj . short_description } \n\n` ;
227- if ( obj . long_description ) md += `${ obj . long_description } \n\n` ;
228- if ( obj . command ) md += renderCommand ( obj . command ) ;
229- if ( obj . flags ) md += renderFlags ( obj . flags ) ;
230- if ( obj . examples ) md += renderExamples ( obj . examples ) ;
231- if ( obj [ 'command similiar examples' ] )
232- md += renderCommandExamples ( obj [ 'command similiar examples' ] ) ;
233- if ( obj . steps ) md += renderSteps ( obj . steps ) ;
234- if ( obj . prerequisites ) md += renderPrerequisites ( obj . prerequisites ) ;
235- if ( obj . warnings ) md += renderWarnings ( obj . warnings ) ;
236- if ( obj . links ) md += renderLinks ( obj . links ) ;
237- if ( obj . related_commands ) md += renderRelatedCommands ( obj . related_commands ) ;
238- if ( obj . output_example ) md += renderOutputExample ( obj . output_example ) ;
255+ // If only subtoc, add mini-TOC
256+ if ( obj . subtoc && obj . subtoc . length && hasOnlySubtocContent ( obj ) ) {
257+ md += generateMiniSubtocTOC ( obj ) ;
258+ } else {
259+ if ( obj . long_description ) md += `${ obj . long_description } \n\n` ;
260+ if ( obj . command ) md += renderCommand ( obj . command ) ;
261+ if ( obj . flags ) md += renderFlags ( obj . flags ) ;
262+ if ( obj . examples ) md += renderExamples ( obj . examples ) ;
263+ if ( obj [ 'command similiar examples' ] )
264+ md += renderCommandExamples ( obj [ 'command similiar examples' ] ) ;
265+ if ( obj . steps ) md += renderSteps ( obj . steps ) ;
266+ if ( obj . prerequisites ) md += renderPrerequisites ( obj . prerequisites ) ;
267+ if ( obj . warnings ) md += renderWarnings ( obj . warnings ) ;
268+ if ( obj . links ) md += renderLinks ( obj . links ) ;
269+ if ( obj . related_commands ) md += renderRelatedCommands ( obj . related_commands ) ;
270+ if ( obj . output_example ) md += renderOutputExample ( obj . output_example ) ;
271+ }
272+ if ( obj . subtoc ) md += renderSubtoc ( obj . subtoc ) ;
239273 md += conciseMetaLine ( obj . author , obj . last_updated , obj . tags ) ;
240274 return md ;
241275}
@@ -271,9 +305,8 @@ function main() {
271305 obj . subtoc . forEach ( ( sub , subIdx ) => {
272306 const subPath = path . join ( CONTENTS_DIR , `${ slugify ( sub . Name ) } .md` ) ;
273307 let subMd = '' ;
274- // Back to parent
308+ // Always add Back to parent
275309 subMd += `[⬅️ Back to ${ obj . Name } ](./${ slugify ( obj . Name ) } .md)\n\n` ;
276- // Previous step
277310 if ( subIdx > 0 ) {
278311 const prev = obj . subtoc [ subIdx - 1 ] ;
279312 subMd += `[⬆️ Previous Step: ${ prev . Name } ](./${ slugify (
0 commit comments