Skip to content

Commit

Permalink
fix: ensure unique ids
Browse files Browse the repository at this point in the history
  • Loading branch information
amphro committed Oct 1, 2020
1 parent 34b1240 commit d51f193
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
18 changes: 8 additions & 10 deletions src/ditamap/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;

Expand All @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
: '';
}
2 changes: 1 addition & 1 deletion templates/cli_reference_topic.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN"
"concept.dtd">
<concept id="cli_reference_force" xml:lang="en-us">
<concept id="cli_reference_{{topic}}" xml:lang="en-us">
<!--
NOTE TO WRITERS:
Expand Down
2 changes: 1 addition & 1 deletion templates/command.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">
<reference id="cli_reference_{{full_name_with_underscores}}" xml:lang="en-us">
<reference id="cli_reference_{{commandWithUnderscores}}" xml:lang="en-us">
<!--
NOTE TO WRITERS:
Expand Down

0 comments on commit d51f193

Please sign in to comment.