Skip to content

Commit d51f193

Browse files
committed
fix: ensure unique ids
1 parent 34b1240 commit d51f193

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/ditamap/command.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { asString, Dictionary, ensureJsonMap, ensureObject, ensureString, JsonMap } from '@salesforce/ts-types';
99
import { join } from 'path';
10-
import { helpFromDescription, punctuate } from '../utils';
10+
import { events, helpFromDescription, punctuate } from '../utils';
1111
import { Ditamap } from './ditamap';
1212

1313
export type CommandHelpInfo = {
@@ -33,7 +33,12 @@ export class Command extends Ditamap {
3333
const description = punctuate(asString(command.longDescription) || asString(command.description));
3434
// Help are all the lines after the first line in the description. Before oclif, there was a 'help' property so continue to
3535
// support that.
36-
const help = this.formatParagraphs(asString(command.help) || helpFromDescription(asString(command.description)));
36+
37+
if (!description) {
38+
events.emit('warning', `Missing description for ${command.id}\n`);
39+
}
40+
41+
const help = this.formatParagraphs(asString(command.help) || helpFromDescription(description));
3742
let trailblazerCommunityUrl;
3843
let trailblazerCommunityName;
3944

@@ -43,17 +48,10 @@ export class Command extends Ditamap {
4348
trailblazerCommunityName = community.name;
4449
}
4550

46-
let fullName: string;
47-
if (subtopic) {
48-
fullName = commandWithUnderscores.replace(`${topic}_${subtopic}_`, '');
49-
} else {
50-
fullName = commandWithUnderscores.replace(`${topic}_`, '');
51-
}
5251
const state = command.state || commandMeta.state;
5352
this.data = Object.assign(command, {
5453
binary: 'sfdx',
55-
// The old style didn't have the topic or subtopic in the reference ID.
56-
full_name_with_underscores: fullName,
54+
commandWithUnderscores,
5755
help,
5856
description,
5957
parameters,

src/utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ export function punctuate(description: string): string {
4949

5050
export function helpFromDescription(description: string): string {
5151
return description
52-
.split(EOL)
53-
.slice(1)
54-
.join(EOL)
55-
.trim();
52+
? description
53+
.split(EOL)
54+
.slice(1)
55+
.join(EOL)
56+
.trim()
57+
: '';
5658
}

templates/cli_reference_topic.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"
33
"concept.dtd">
4-
<concept id="cli_reference_force" xml:lang="en-us">
4+
<concept id="cli_reference_{{topic}}" xml:lang="en-us">
55
<!--
66
77
NOTE TO WRITERS:

templates/command.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">
3-
<reference id="cli_reference_{{full_name_with_underscores}}" xml:lang="en-us">
3+
<reference id="cli_reference_{{commandWithUnderscores}}" xml:lang="en-us">
44
<!--
55
66
NOTE TO WRITERS:

0 commit comments

Comments
 (0)