From d51f19350bab150da23575bfa27e94e467df99d6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 30 Sep 2020 21:15:47 -0700 Subject: [PATCH] fix: ensure unique ids --- src/ditamap/command.ts | 18 ++++++++---------- src/utils.ts | 10 ++++++---- templates/cli_reference_topic.hbs | 2 +- templates/command.hbs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ditamap/command.ts b/src/ditamap/command.ts index 8d50fb1b..4b6ad698 100644 --- a/src/ditamap/command.ts +++ b/src/ditamap/command.ts @@ -7,7 +7,7 @@ import { asString, Dictionary, ensureJsonMap, ensureObject, ensureString, JsonMap } from '@salesforce/ts-types'; import { join } from 'path'; -import { helpFromDescription, punctuate } from '../utils'; +import { events, helpFromDescription, punctuate } from '../utils'; import { Ditamap } from './ditamap'; export type CommandHelpInfo = { @@ -33,7 +33,12 @@ export class Command extends Ditamap { const description = punctuate(asString(command.longDescription) || asString(command.description)); // Help are all the lines after the first line in the description. Before oclif, there was a 'help' property so continue to // support that. - const help = this.formatParagraphs(asString(command.help) || helpFromDescription(asString(command.description))); + + if (!description) { + events.emit('warning', `Missing description for ${command.id}\n`); + } + + const help = this.formatParagraphs(asString(command.help) || helpFromDescription(description)); let trailblazerCommunityUrl; let trailblazerCommunityName; @@ -43,17 +48,10 @@ export class Command extends Ditamap { trailblazerCommunityName = community.name; } - let fullName: string; - if (subtopic) { - fullName = commandWithUnderscores.replace(`${topic}_${subtopic}_`, ''); - } else { - fullName = commandWithUnderscores.replace(`${topic}_`, ''); - } const state = command.state || commandMeta.state; this.data = Object.assign(command, { binary: 'sfdx', - // The old style didn't have the topic or subtopic in the reference ID. - full_name_with_underscores: fullName, + commandWithUnderscores, help, description, parameters, diff --git a/src/utils.ts b/src/utils.ts index 40460442..ff790eb3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -49,8 +49,10 @@ export function punctuate(description: string): string { export function helpFromDescription(description: string): string { return description - .split(EOL) - .slice(1) - .join(EOL) - .trim(); + ? description + .split(EOL) + .slice(1) + .join(EOL) + .trim() + : ''; } diff --git a/templates/cli_reference_topic.hbs b/templates/cli_reference_topic.hbs index e04a20e3..84fe51b2 100644 --- a/templates/cli_reference_topic.hbs +++ b/templates/cli_reference_topic.hbs @@ -1,7 +1,7 @@ - +