Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions helpers/generate-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@
}

if ( currentSection === SECTION_COMMAND ) {
const [ , command, description ] = line.match( COMMAND_REGEXP );
result.commands.push( {
command,
description,
} );
const match = line.match( COMMAND_REGEXP );
if ( match ) {
const [ , command, description ] = match;
result.commands.push( {
command,
description,
} );
} else if ( result.commands.length ) {
// Continuation of a wrapped command description.
result.commands[ result.commands.length - 1 ].description += ' ' + line;

Check warning on line 77 in helpers/generate-docs.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `.at(…)` over `[….length - index]`.

See more on https://sonarcloud.io/project/issues?id=Automattic_vip-cli&issues=AZ8-TR2LfszopVab3nZ4&open=AZ8-TR2LfszopVab3nZ4&pullRequest=2943
} else {
console.error( 'Unknown command line', line );
}
continue;
}
if ( currentSection === SECTION_OPTIONS ) {
Expand All @@ -79,8 +87,11 @@
option,
description,
} );
} else if ( result.options.length ) {
// Continuation of a wrapped option description.
result.options[ result.options.length - 1 ].description += ' ' + line;

Check warning on line 92 in helpers/generate-docs.js

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `.at(…)` over `[….length - index]`.

See more on https://sonarcloud.io/project/issues?id=Automattic_vip-cli&issues=AZ8-TR2LfszopVab3nZ5&open=AZ8-TR2LfszopVab3nZ5&pullRequest=2943
} else {
console.log( 'Unknown option', line );
console.error( 'Unknown option', line );
}
continue;
}
Expand Down