Skip to content

Commit 43f8605

Browse files
committed
add jssdk flag
1 parent c600576 commit 43f8605

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

repo-scripts/api-documenter/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ and then generates files in [Markdown](https://en.wikipedia.org/wiki/Markdown) f
1111
Use `-i` to specify the folder that contains api.json files.
1212
Use `-p` to specify the g3 path that contains the reference docs.
1313

14-
By default, the command will create `toc.yaml` in folder `/toc`. To change the output folder, use the flag `-o`.
14+
By default, the command will create `toc.yaml` in folder `/toc`. To change the output folder, use the flag `-o`.
15+
16+
To generate toc for the Firebase JS SDK, also set the flag `-j` to create the top level `firebase` toc item.

repo-scripts/api-documenter/src/cli/TocAction.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { CommandLineStringParameter } from '@rushstack/ts-command-line';
18+
import {
19+
CommandLineFlagParameter,
20+
CommandLineStringParameter
21+
} from '@rushstack/ts-command-line';
1922
import { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine';
2023
import { BaseAction } from './BaseAction';
2124
import { generateToc } from '../toc';
2225

2326
export class TocAction extends BaseAction {
2427
private _g3PathParameter!: CommandLineStringParameter;
28+
private _jsSDKParameter!: CommandLineFlagParameter;
2529
public constructor(parser: ApiDocumenterCommandLine) {
2630
super({
2731
actionName: 'toc',
@@ -42,12 +46,21 @@ export class TocAction extends BaseAction {
4246
description: `Specifies the path where the reference docs will be written to in g3.
4347
Used to generate paths in the toc`
4448
});
49+
50+
this._jsSDKParameter = this.defineFlagParameter({
51+
parameterLongName: '--js-sdk',
52+
parameterShortName: '-j',
53+
description:
54+
`Generating toc for the Firebase JS SDK.` +
55+
`It will create an artificial top level toc item "firebase".`
56+
});
4557
}
4658

4759
protected async onExecute(): Promise<void> {
4860
// override
4961
const { apiModel, outputFolder, addFileNameSuffix } = this.buildApiModel();
5062
const g3Path: string | undefined = this._g3PathParameter.value;
63+
const jsSdk: boolean = this._jsSDKParameter.value;
5164

5265
if (!g3Path) {
5366
throw new Error(
@@ -59,7 +72,8 @@ export class TocAction extends BaseAction {
5972
apiModel,
6073
outputFolder,
6174
addFileNameSuffix,
62-
g3Path
75+
g3Path,
76+
jsSdk
6377
});
6478
}
6579
}

repo-scripts/api-documenter/src/toc.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface ITocGenerationOptions {
2727
g3Path: string;
2828
outputFolder: string;
2929
addFileNameSuffix: boolean;
30+
jsSdk: boolean;
3031
}
3132

3233
interface ITocItem {
@@ -39,14 +40,19 @@ export function generateToc({
3940
apiModel,
4041
g3Path,
4142
outputFolder,
42-
addFileNameSuffix
43+
addFileNameSuffix,
44+
jsSdk
4345
}: ITocGenerationOptions) {
44-
const js: ITocItem = {
45-
title: 'firebase',
46-
path: `${g3Path}/index`,
47-
section: []
48-
};
49-
const toc = [js];
46+
const toc = [];
47+
48+
if (jsSdk) {
49+
const firebaseToc: ITocItem = {
50+
title: 'firebase',
51+
path: `${g3Path}/index`,
52+
section: []
53+
};
54+
toc.push(firebaseToc);
55+
}
5056

5157
generateTocRecursively(apiModel, g3Path, addFileNameSuffix, toc);
5258

0 commit comments

Comments
 (0)