@firebase/api-documenter 0.2.0 → 0.2.1-canary.4af28c1a4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli/MarkdownAction.d.ts +2 -0
  3. package/dist/cli/MarkdownAction.js +13 -1
  4. package/dist/cli/MarkdownAction.js.map +1 -1
  5. package/dist/cli/TocAction.js +1 -1
  6. package/dist/cli/TocAction.js.map +1 -1
  7. package/dist/documenters/MarkdownDocumenter.d.ts +2 -0
  8. package/dist/documenters/MarkdownDocumenter.js +158 -89
  9. package/dist/documenters/MarkdownDocumenter.js.map +1 -1
  10. package/dist/documenters/MarkdownDocumenterHelpers.js +25 -25
  11. package/dist/documenters/MarkdownDocumenterHelpers.js.map +1 -1
  12. package/dist/markdown/CustomMarkdownEmitter.js +4 -4
  13. package/dist/markdown/CustomMarkdownEmitter.js.map +1 -1
  14. package/dist/markdown/MarkdownEmitter.js +13 -13
  15. package/dist/markdown/MarkdownEmitter.js.map +1 -1
  16. package/dist/markdown/test/CustomMarkdownEmitter.test.js +2 -2
  17. package/dist/markdown/test/CustomMarkdownEmitter.test.js.map +1 -1
  18. package/dist/nodes/CustomDocNodeKind.js +12 -12
  19. package/dist/nodes/CustomDocNodeKind.js.map +1 -1
  20. package/dist/nodes/DocEmphasisSpan.js +1 -1
  21. package/dist/nodes/DocEmphasisSpan.js.map +1 -1
  22. package/dist/nodes/DocHeading.js +1 -1
  23. package/dist/nodes/DocHeading.js.map +1 -1
  24. package/dist/nodes/DocNoteBox.js +1 -1
  25. package/dist/nodes/DocNoteBox.js.map +1 -1
  26. package/dist/nodes/DocTable.js +1 -1
  27. package/dist/nodes/DocTable.js.map +1 -1
  28. package/dist/nodes/DocTableCell.js +1 -1
  29. package/dist/nodes/DocTableCell.js.map +1 -1
  30. package/dist/nodes/DocTableRow.js +1 -1
  31. package/dist/nodes/DocTableRow.js.map +1 -1
  32. package/dist/plugin/PluginLoader.js +3 -4
  33. package/dist/plugin/PluginLoader.js.map +1 -1
  34. package/dist/start.js +0 -0
  35. package/dist/toc.js +7 -8
  36. package/dist/toc.js.map +1 -1
  37. package/dist/utils/test/IndentedWriter.test.js +8 -8
  38. package/dist/utils/test/IndentedWriter.test.js.map +1 -1
  39. package/package.json +1 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @firebase/api-documenter
2
+
3
+ ## 0.2.0
4
+ ### Minor Changes
5
+
6
+ - [#6449](https://github.com/firebase/firebase-js-sdk/pull/6449) Updates to work with devsite changes. Added a required `--project` flag for generating markdown docs.
7
+ ## 0.1.2
8
+ ### Patch Changes
9
+
10
+ - [#4931](https://github.com/firebase/firebase-js-sdk/pull/4931) Support toc generation for Firebase devsite.
11
+ ## 0.1.1
12
+ ### Patch Changes
13
+
14
+ - [#4869](https://github.com/firebase/firebase-js-sdk/pull/4869) Generate API docs for namespace members
@@ -17,6 +17,8 @@
17
17
  import { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine';
18
18
  import { BaseAction } from './BaseAction';
19
19
  export declare class MarkdownAction extends BaseAction {
20
+ private _sortFunctions;
20
21
  constructor(parser: ApiDocumenterCommandLine);
22
+ protected onDefineParameters(): void;
21
23
  protected onExecute(): Promise<void>;
22
24
  }
@@ -29,10 +29,21 @@ class MarkdownAction extends BaseAction_1.BaseAction {
29
29
  ' Markdown format, suitable for example for publishing on a GitHub site.'
30
30
  });
31
31
  }
32
+ onDefineParameters() {
33
+ super.onDefineParameters();
34
+ this._sortFunctions = this.defineStringParameter({
35
+ parameterLongName: '--sort-functions',
36
+ argumentName: 'PRIORITY_PARAMS',
37
+ description: `Sorts functions tables and listings by first parameter. ` +
38
+ `Provide comma-separated strings for preferred params to be ` +
39
+ `ordered first. Alphabetical otherwise.`
40
+ });
41
+ }
32
42
  onExecute() {
33
43
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
44
  // override
35
45
  const { apiModel, outputFolder, addFileNameSuffix, projectName } = this.buildApiModel();
46
+ const sortFunctions = this._sortFunctions.value || '';
36
47
  if (!projectName) {
37
48
  throw new Error('No project name provided. Use --project.');
38
49
  }
@@ -41,7 +52,8 @@ class MarkdownAction extends BaseAction_1.BaseAction {
41
52
  documenterConfig: undefined,
42
53
  outputFolder,
43
54
  addFileNameSuffix,
44
- projectName
55
+ projectName,
56
+ sortFunctions
45
57
  });
46
58
  markdownDocumenter.generateFiles();
47
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownAction.js","sourceRoot":"","sources":["../../src/cli/MarkdownAction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAMH,6CAA0C;AAC1C,0EAAuE;AAEvE,MAAa,cAAe,SAAQ,uBAAU;IAC5C,YAAmB,MAAgC;QACjD,KAAK,CAAC;YACJ,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,iDAAiD;YAC1D,aAAa,EACX,yDAAyD;gBACzD,yEAAyE;SAC5E,CAAC,CAAC;IACL,CAAC;IAEe,SAAS;;YACvB,WAAW;YACX,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAC9D,IAAI,CAAC,aAAa,EAAE,CAAC;YAEvB,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;aAC7D;YAED,MAAM,kBAAkB,GAAuB,IAAI,uCAAkB,CAAC;gBACpE,QAAQ;gBACR,gBAAgB,EAAE,SAAS;gBAC3B,YAAY;gBACZ,iBAAiB;gBACjB,WAAW;aACZ,CAAC,CAAC;YACH,kBAAkB,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC;KAAA;CACF;AA7BD,wCA6BC"}
1
+ {"version":3,"file":"MarkdownAction.js","sourceRoot":"","sources":["../../src/cli/MarkdownAction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAMH,6CAA0C;AAC1C,0EAAuE;AAGvE,MAAa,cAAe,SAAQ,uBAAU;IAE5C,YAAmB,MAAgC;QACjD,KAAK,CAAC;YACJ,UAAU,EAAE,UAAU;YACtB,OAAO,EAAE,iDAAiD;YAC1D,aAAa,EACX,yDAAyD;gBACzD,yEAAyE;SAC5E,CAAC,CAAC;IACL,CAAC;IAES,kBAAkB;QAC1B,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAE3B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC;YAC/C,iBAAiB,EAAE,kBAAkB;YACrC,YAAY,EAAE,iBAAiB;YAC/B,WAAW,EACT,0DAA0D;gBAC1D,6DAA6D;gBAC7D,wCAAwC;SAC3C,CAAC,CAAC;IACL,CAAC;IAEe,SAAS;;YACvB,WAAW;YACX,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,GAC9D,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,MAAM,aAAa,GAAW,IAAI,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;YAE9D,IAAI,CAAC,WAAW,EAAE;gBAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;aAC7D;YAED,MAAM,kBAAkB,GAAuB,IAAI,uCAAkB,CAAC;gBACpE,QAAQ;gBACR,gBAAgB,EAAE,SAAS;gBAC3B,YAAY;gBACZ,iBAAiB;gBACjB,WAAW;gBACX,aAAa;aACd,CAAC,CAAC;YACH,kBAAkB,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC;KAAA;CACF;AA7CD,wCA6CC"}
@@ -53,7 +53,7 @@ class TocAction extends BaseAction_1.BaseAction {
53
53
  if (!g3Path) {
54
54
  throw new Error('--g3-path is a required to generate toc, but it is not provided');
55
55
  }
56
- toc_1.generateToc({
56
+ (0, toc_1.generateToc)({
57
57
  apiModel,
58
58
  outputFolder,
59
59
  addFileNameSuffix,
@@ -1 +1 @@
1
- {"version":3,"file":"TocAction.js","sourceRoot":"","sources":["../../src/cli/TocAction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAOH,6CAA0C;AAC1C,gCAAqC;AAErC,MAAa,SAAU,SAAQ,uBAAU;IAGvC,YAAmB,MAAgC;QACjD,KAAK,CAAC;YACJ,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,sDAAsD;YAC/D,aAAa,EAAE,sDAAsD;SACtE,CAAC,CAAC;IACL,CAAC;IAES,kBAAkB;QAC1B,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAE3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACjD,iBAAiB,EAAE,aAAa;YAChC,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,UAAU;YACxB,WAAW,EAAE;kDAC+B;SAC7C,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC9C,iBAAiB,EAAE,UAAU;YAC7B,kBAAkB,EAAE,IAAI;YACxB,WAAW,EACT,yCAAyC;gBACzC,6DAA6D;SAChE,CAAC,CAAC;IACL,CAAC;IAEe,SAAS;;YACvB,WAAW;YACX,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAC3E,MAAM,MAAM,GAAuB,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC/D,MAAM,KAAK,GAAY,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;YAElD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;aACH;YAED,iBAAW,CAAC;gBACV,QAAQ;gBACR,YAAY;gBACZ,iBAAiB;gBACjB,MAAM;gBACN,KAAK;aACN,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAnDD,8BAmDC"}
1
+ {"version":3,"file":"TocAction.js","sourceRoot":"","sources":["../../src/cli/TocAction.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAOH,6CAA0C;AAC1C,gCAAqC;AAErC,MAAa,SAAU,SAAQ,uBAAU;IAGvC,YAAmB,MAAgC;QACjD,KAAK,CAAC;YACJ,UAAU,EAAE,KAAK;YACjB,OAAO,EAAE,sDAAsD;YAC/D,aAAa,EAAE,sDAAsD;SACtE,CAAC,CAAC;IACL,CAAC;IAES,kBAAkB;QAC1B,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAE3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACjD,iBAAiB,EAAE,aAAa;YAChC,kBAAkB,EAAE,IAAI;YACxB,YAAY,EAAE,UAAU;YACxB,WAAW,EAAE;kDAC+B;SAC7C,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC;YAC9C,iBAAiB,EAAE,UAAU;YAC7B,kBAAkB,EAAE,IAAI;YACxB,WAAW,EACT,yCAAyC;gBACzC,6DAA6D;SAChE,CAAC,CAAC;IACL,CAAC;IAEe,SAAS;;YACvB,WAAW;YACX,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YAC3E,MAAM,MAAM,GAAuB,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAC/D,MAAM,KAAK,GAAY,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC;YAElD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;aACH;YAED,IAAA,iBAAW,EAAC;gBACV,QAAQ;gBACR,YAAY;gBACZ,iBAAiB;gBACjB,MAAM;gBACN,KAAK;aACN,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAnDD,8BAmDC"}
@@ -23,6 +23,7 @@ export interface IMarkdownDocumenterOptions {
23
23
  outputFolder: string;
24
24
  addFileNameSuffix: boolean;
25
25
  projectName: string;
26
+ sortFunctions: string;
26
27
  }
27
28
  /**
28
29
  * Renders API documentation in the Markdown file format.
@@ -37,6 +38,7 @@ export declare class MarkdownDocumenter {
37
38
  private readonly _pluginLoader;
38
39
  private readonly _addFileNameSuffix;
39
40
  private readonly _projectName;
41
+ private readonly _sortFunctions;
40
42
  constructor(options: IMarkdownDocumenterOptions);
41
43
  generateFiles(): void;
42
44
  _writeApiItemPage(apiItem: ApiItem): void;
@@ -47,6 +47,7 @@ class MarkdownDocumenter {
47
47
  this._outputFolder = options.outputFolder;
48
48
  this._addFileNameSuffix = options.addFileNameSuffix;
49
49
  this._projectName = options.projectName;
50
+ this._sortFunctions = options.sortFunctions;
50
51
  this._tsdocConfiguration = CustomDocNodeKind_1.CustomDocNodes.configuration;
51
52
  this._markdownEmitter = new CustomMarkdownEmitter_1.CustomMarkdownEmitter(this._apiModel);
52
53
  this._pluginLoader = new PluginLoader_1.PluginLoader();
@@ -59,7 +60,7 @@ class MarkdownDocumenter {
59
60
  outputFolder: this._outputFolder,
60
61
  documenter: new MarkdownDocumenterAccessor_1.MarkdownDocumenterAccessor({
61
62
  getLinkForApiItem: (apiItem) => {
62
- return MarkdownDocumenterHelpers_1.getLinkForApiItem(apiItem, this._addFileNameSuffix);
63
+ return (0, MarkdownDocumenterHelpers_1.getLinkForApiItem)(apiItem, this._addFileNameSuffix);
63
64
  }
64
65
  })
65
66
  });
@@ -84,7 +85,7 @@ class MarkdownDocumenter {
84
85
  const pageWithoutHeading = nodes.slice(1);
85
86
  output.appendNodes(pageWithoutHeading);
86
87
  // write to file
87
- const filename = path.join(this._outputFolder, MarkdownDocumenterHelpers_1.getFilenameForApiItem(apiItem, this._addFileNameSuffix));
88
+ const filename = path.join(this._outputFolder, (0, MarkdownDocumenterHelpers_1.getFilenameForApiItem)(apiItem, this._addFileNameSuffix));
88
89
  const stringBuilder = new tsdoc_1.StringBuilder();
89
90
  // devsite headers
90
91
  stringBuilder.append(`Project: /docs/reference/${this._projectName}/_project.yaml
@@ -95,7 +96,7 @@ page_type: reference
95
96
  this._markdownEmitter.emit(stringBuilder, output, {
96
97
  contextApiItem: apiItem,
97
98
  onGetFilenameForApiItem: (apiItemForFilename) => {
98
- return MarkdownDocumenterHelpers_1.getLinkForApiItem(apiItemForFilename, this._addFileNameSuffix);
99
+ return (0, MarkdownDocumenterHelpers_1.getLinkForApiItem)(apiItemForFilename, this._addFileNameSuffix);
99
100
  }
100
101
  });
101
102
  let pageContent = stringBuilder.toString();
@@ -118,54 +119,54 @@ page_type: reference
118
119
  const output = [];
119
120
  const scopedName = apiItem.getScopedNameWithinPackage();
120
121
  switch (apiItem.kind) {
121
- case "Class" /* Class */:
122
+ case "Class" /* ApiItemKind.Class */:
122
123
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName} class` }));
123
124
  break;
124
- case "Enum" /* Enum */:
125
+ case "Enum" /* ApiItemKind.Enum */:
125
126
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
126
127
  break;
127
- case "Interface" /* Interface */:
128
+ case "Interface" /* ApiItemKind.Interface */:
128
129
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName} interface` }));
129
130
  break;
130
- case "Constructor" /* Constructor */:
131
- case "ConstructSignature" /* ConstructSignature */:
131
+ case "Constructor" /* ApiItemKind.Constructor */:
132
+ case "ConstructSignature" /* ApiItemKind.ConstructSignature */:
132
133
  output.push(new DocHeading_1.DocHeading({ configuration, title: scopedName }));
133
134
  break;
134
- case "Method" /* Method */:
135
- case "MethodSignature" /* MethodSignature */:
135
+ case "Method" /* ApiItemKind.Method */:
136
+ case "MethodSignature" /* ApiItemKind.MethodSignature */:
136
137
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
137
138
  break;
138
- case "Function" /* Function */:
139
+ case "Function" /* ApiItemKind.Function */:
139
140
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
140
141
  break;
141
- case "Model" /* Model */:
142
+ case "Model" /* ApiItemKind.Model */:
142
143
  output.push(new DocHeading_1.DocHeading({ configuration, title: `API Reference` }));
143
144
  break;
144
- case "Namespace" /* Namespace */:
145
+ case "Namespace" /* ApiItemKind.Namespace */:
145
146
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName} namespace` }));
146
147
  break;
147
- case "Package" /* Package */:
148
+ case "Package" /* ApiItemKind.Package */:
148
149
  const unscopedPackageName = node_core_library_1.PackageName.getUnscopedName(apiItem.displayName);
149
150
  output.push(new DocHeading_1.DocHeading({
150
151
  configuration,
151
152
  title: `${unscopedPackageName} package`
152
153
  }));
153
154
  break;
154
- case "EntryPoint" /* EntryPoint */:
155
+ case "EntryPoint" /* ApiItemKind.EntryPoint */:
155
156
  const packageName = apiItem.parent.displayName;
156
157
  output.push(new DocHeading_1.DocHeading({
157
158
  configuration,
158
159
  title: `${packageName}${apiItem.displayName && '/' + apiItem.displayName}`
159
160
  }));
160
161
  break;
161
- case "Property" /* Property */:
162
- case "PropertySignature" /* PropertySignature */:
162
+ case "Property" /* ApiItemKind.Property */:
163
+ case "PropertySignature" /* ApiItemKind.PropertySignature */:
163
164
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
164
165
  break;
165
- case "TypeAlias" /* TypeAlias */:
166
+ case "TypeAlias" /* ApiItemKind.TypeAlias */:
166
167
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
167
168
  break;
168
- case "Variable" /* Variable */:
169
+ case "Variable" /* ApiItemKind.Variable */:
169
170
  output.push(new DocHeading_1.DocHeading({ configuration, title: `${scopedName}` }));
170
171
  break;
171
172
  default:
@@ -173,7 +174,7 @@ page_type: reference
173
174
  }
174
175
  if (api_extractor_model_me_1.ApiReleaseTagMixin.isBaseClassOf(apiItem)) {
175
176
  if (apiItem.releaseTag === api_extractor_model_me_1.ReleaseTag.Beta) {
176
- output.push(MarkdownDocumenterHelpers_1.createBetaWarning(configuration));
177
+ output.push((0, MarkdownDocumenterHelpers_1.createBetaWarning)(configuration));
177
178
  }
178
179
  }
179
180
  if (apiItem instanceof api_extractor_model_me_1.ApiDocumentedItem) {
@@ -194,51 +195,51 @@ page_type: reference
194
195
  }
195
196
  }
196
197
  // render remark sections
197
- output.push(...MarkdownDocumenterHelpers_1.createRemarksSection(apiItem, configuration));
198
+ output.push(...(0, MarkdownDocumenterHelpers_1.createRemarksSection)(apiItem, configuration));
198
199
  if (apiItem instanceof api_extractor_model_me_1.ApiDeclaredItem) {
199
200
  output.push(...this._createSignatureSection(apiItem));
200
201
  }
201
202
  switch (apiItem.kind) {
202
- case "Class" /* Class */:
203
+ case "Class" /* ApiItemKind.Class */:
203
204
  output.push(...this._createClassTables(apiItem));
204
205
  break;
205
- case "Enum" /* Enum */:
206
- output.push(...MarkdownDocumenterHelpers_1.createEnumTables(apiItem, configuration));
206
+ case "Enum" /* ApiItemKind.Enum */:
207
+ output.push(...(0, MarkdownDocumenterHelpers_1.createEnumTables)(apiItem, configuration));
207
208
  break;
208
- case "Interface" /* Interface */:
209
+ case "Interface" /* ApiItemKind.Interface */:
209
210
  output.push(...this._createInterfaceTables(apiItem));
210
211
  break;
211
- case "Constructor" /* Constructor */:
212
- case "ConstructSignature" /* ConstructSignature */:
213
- case "Method" /* Method */:
214
- case "MethodSignature" /* MethodSignature */:
215
- case "Function" /* Function */:
212
+ case "Constructor" /* ApiItemKind.Constructor */:
213
+ case "ConstructSignature" /* ApiItemKind.ConstructSignature */:
214
+ case "Method" /* ApiItemKind.Method */:
215
+ case "MethodSignature" /* ApiItemKind.MethodSignature */:
216
+ case "Function" /* ApiItemKind.Function */:
216
217
  output.push(...this._createParameterTables(apiItem));
217
- output.push(...MarkdownDocumenterHelpers_1.createThrowsSection(apiItem, configuration));
218
+ output.push(...(0, MarkdownDocumenterHelpers_1.createThrowsSection)(apiItem, configuration));
218
219
  break;
219
- case "Namespace" /* Namespace */:
220
+ case "Namespace" /* ApiItemKind.Namespace */:
220
221
  output.push(...this._createEntryPointOrNamespace(apiItem));
221
222
  break;
222
- case "Model" /* Model */:
223
+ case "Model" /* ApiItemKind.Model */:
223
224
  output.push(...this._createModelTable(apiItem));
224
225
  break;
225
- case "Package" /* Package */:
226
+ case "Package" /* ApiItemKind.Package */:
226
227
  output.push(...this._createPackage(apiItem));
227
228
  break;
228
- case "EntryPoint" /* EntryPoint */:
229
+ case "EntryPoint" /* ApiItemKind.EntryPoint */:
229
230
  output.push(...this._createEntryPointOrNamespace(apiItem));
230
231
  break;
231
- case "Property" /* Property */:
232
- case "PropertySignature" /* PropertySignature */:
232
+ case "Property" /* ApiItemKind.Property */:
233
+ case "PropertySignature" /* ApiItemKind.PropertySignature */:
233
234
  break;
234
- case "TypeAlias" /* TypeAlias */:
235
+ case "TypeAlias" /* ApiItemKind.TypeAlias */:
235
236
  break;
236
- case "Variable" /* Variable */:
237
+ case "Variable" /* ApiItemKind.Variable */:
237
238
  break;
238
239
  default:
239
240
  throw new Error('Unsupported API item kind:2 ' + apiItem.kind);
240
241
  }
241
- output.push(...MarkdownDocumenterHelpers_1.createExampleSection(apiItem, configuration));
242
+ output.push(...(0, MarkdownDocumenterHelpers_1.createExampleSection)(apiItem, configuration));
242
243
  return output;
243
244
  }
244
245
  /**
@@ -271,40 +272,40 @@ page_type: reference
271
272
  const eventsDefinitions = [];
272
273
  for (const apiMember of apiClass.members) {
273
274
  switch (apiMember.kind) {
274
- case "Constructor" /* Constructor */: {
275
+ case "Constructor" /* ApiItemKind.Constructor */: {
275
276
  constructorsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
276
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
277
- MarkdownDocumenterHelpers_1.createModifiersCell(apiMember, configuration),
278
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
277
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
278
+ (0, MarkdownDocumenterHelpers_1.createModifiersCell)(apiMember, configuration),
279
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
279
280
  ]));
280
281
  constructorsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
281
282
  break;
282
283
  }
283
- case "Method" /* Method */: {
284
+ case "Method" /* ApiItemKind.Method */: {
284
285
  methodsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
285
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
286
- MarkdownDocumenterHelpers_1.createModifiersCell(apiMember, configuration),
287
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
286
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
287
+ (0, MarkdownDocumenterHelpers_1.createModifiersCell)(apiMember, configuration),
288
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
288
289
  ]));
289
290
  methodsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
290
291
  break;
291
292
  }
292
- case "Property" /* Property */: {
293
+ case "Property" /* ApiItemKind.Property */: {
293
294
  if (apiMember.isEventProperty) {
294
295
  eventsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
295
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
296
- MarkdownDocumenterHelpers_1.createModifiersCell(apiMember, configuration),
296
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
297
+ (0, MarkdownDocumenterHelpers_1.createModifiersCell)(apiMember, configuration),
297
298
  this._createPropertyTypeCell(apiMember),
298
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
299
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
299
300
  ]));
300
301
  eventsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
301
302
  }
302
303
  else {
303
304
  propertiesTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
304
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
305
- MarkdownDocumenterHelpers_1.createModifiersCell(apiMember, configuration),
305
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
306
+ (0, MarkdownDocumenterHelpers_1.createModifiersCell)(apiMember, configuration),
306
307
  this._createPropertyTypeCell(apiMember),
307
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
308
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
308
309
  ]));
309
310
  propertiesDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
310
311
  }
@@ -357,29 +358,29 @@ page_type: reference
357
358
  const eventsDefinitions = [];
358
359
  for (const apiMember of apiClass.members) {
359
360
  switch (apiMember.kind) {
360
- case "ConstructSignature" /* ConstructSignature */:
361
- case "MethodSignature" /* MethodSignature */: {
361
+ case "ConstructSignature" /* ApiItemKind.ConstructSignature */:
362
+ case "MethodSignature" /* ApiItemKind.MethodSignature */: {
362
363
  methodsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
363
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
364
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
364
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
365
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
365
366
  ]));
366
367
  methodsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
367
368
  break;
368
369
  }
369
- case "PropertySignature" /* PropertySignature */: {
370
+ case "PropertySignature" /* ApiItemKind.PropertySignature */: {
370
371
  if (apiMember.isEventProperty) {
371
372
  eventsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
372
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
373
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
373
374
  this._createPropertyTypeCell(apiMember),
374
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
375
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
375
376
  ]));
376
377
  eventsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
377
378
  }
378
379
  else {
379
380
  propertiesTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
380
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
381
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
381
382
  this._createPropertyTypeCell(apiMember),
382
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
383
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
383
384
  ]));
384
385
  propertiesDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
385
386
  }
@@ -473,7 +474,7 @@ page_type: reference
473
474
  // discard any newlines and let the renderer do normal word-wrapping.
474
475
  const unwrappedTokenText = token.text.replace(/[\r\n]+/g, ' ');
475
476
  // If it's hyperlinkable, then append a DocLinkTag
476
- if (token.kind === "Reference" /* Reference */ &&
477
+ if (token.kind === "Reference" /* ExcerptTokenKind.Reference */ &&
477
478
  token.canonicalReference) {
478
479
  const apiItemResult = this._apiModel.resolveDeclarationReference(token.canonicalReference, undefined);
479
480
  if (apiItemResult.resolvedApiItem) {
@@ -481,7 +482,7 @@ page_type: reference
481
482
  configuration,
482
483
  tagName: '@link',
483
484
  linkText: unwrappedTokenText,
484
- urlDestination: MarkdownDocumenterHelpers_1.getLinkForApiItem(apiItemResult.resolvedApiItem, this._addFileNameSuffix)
485
+ urlDestination: (0, MarkdownDocumenterHelpers_1.getLinkForApiItem)(apiItemResult.resolvedApiItem, this._addFileNameSuffix)
485
486
  }));
486
487
  continue;
487
488
  }
@@ -502,11 +503,11 @@ page_type: reference
502
503
  });
503
504
  for (const apiMember of apiModel.members) {
504
505
  const row = new DocTableRow_1.DocTableRow({ configuration }, [
505
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
506
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
506
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
507
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
507
508
  ]);
508
509
  switch (apiMember.kind) {
509
- case "Package" /* Package */:
510
+ case "Package" /* ApiItemKind.Package */:
510
511
  packagesTable.addRow(row);
511
512
  this._writeApiItemPage(apiMember);
512
513
  break;
@@ -535,8 +536,8 @@ page_type: reference
535
536
  });
536
537
  for (const entryPoint of apiContainer.entryPoints) {
537
538
  const row = new DocTableRow_1.DocTableRow({ configuration }, [
538
- MarkdownDocumenterHelpers_1.createEntryPointTitleCell(entryPoint, configuration, this._addFileNameSuffix),
539
- MarkdownDocumenterHelpers_1.createDescriptionCell(entryPoint, configuration)
539
+ (0, MarkdownDocumenterHelpers_1.createEntryPointTitleCell)(entryPoint, configuration, this._addFileNameSuffix),
540
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(entryPoint, configuration)
540
541
  ]);
541
542
  entryPointsTable.addRow(row);
542
543
  }
@@ -561,10 +562,11 @@ page_type: reference
561
562
  configuration,
562
563
  headerTitles: ['Enumeration', 'Description']
563
564
  });
564
- const functionsTable = new DocTable_1.DocTable({
565
+ const finalFunctionsTable = new DocTable_1.DocTable({
565
566
  configuration,
566
567
  headerTitles: ['Function', 'Description']
567
568
  });
569
+ const functionsRowGroup = {};
568
570
  const interfacesTable = new DocTable_1.DocTable({
569
571
  configuration,
570
572
  headerTitles: ['Interface', 'Description']
@@ -581,52 +583,119 @@ page_type: reference
581
583
  configuration,
582
584
  headerTitles: ['Type Alias', 'Description']
583
585
  });
584
- const functionsDefinitions = [];
586
+ const functionsDefinitionsGroup = {};
587
+ const finalFunctionsDefinitions = [];
585
588
  const variablesDefinitions = [];
586
589
  const typeAliasDefinitions = [];
587
590
  const enumsDefinitions = [];
588
- const apiMembers = apiContainer.kind === "EntryPoint" /* EntryPoint */
591
+ const apiMembers = apiContainer.kind === "EntryPoint" /* ApiItemKind.EntryPoint */
589
592
  ? apiContainer.members
590
593
  : apiContainer.members;
591
594
  for (const apiMember of apiMembers) {
592
595
  const row = new DocTableRow_1.DocTableRow({ configuration }, [
593
- MarkdownDocumenterHelpers_1.createTitleCell(apiMember, configuration, this._addFileNameSuffix),
594
- MarkdownDocumenterHelpers_1.createDescriptionCell(apiMember, configuration)
596
+ (0, MarkdownDocumenterHelpers_1.createTitleCell)(apiMember, configuration, this._addFileNameSuffix),
597
+ (0, MarkdownDocumenterHelpers_1.createDescriptionCell)(apiMember, configuration)
595
598
  ]);
596
599
  switch (apiMember.kind) {
597
- case "Class" /* Class */:
600
+ case "Class" /* ApiItemKind.Class */:
598
601
  classesTable.addRow(row);
599
602
  this._writeApiItemPage(apiMember);
600
603
  break;
601
- case "Enum" /* Enum */:
604
+ case "Enum" /* ApiItemKind.Enum */:
602
605
  enumerationsTable.addRow(row);
603
606
  enumsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
604
607
  break;
605
- case "Interface" /* Interface */:
608
+ case "Interface" /* ApiItemKind.Interface */:
606
609
  interfacesTable.addRow(row);
607
610
  this._writeApiItemPage(apiMember);
608
611
  break;
609
- case "Namespace" /* Namespace */:
612
+ case "Namespace" /* ApiItemKind.Namespace */:
610
613
  namespacesTable.addRow(row);
611
614
  this._writeApiItemPage(apiMember);
612
615
  break;
613
- case "Function" /* Function */:
614
- functionsTable.addRow(row);
615
- functionsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
616
+ case "Function" /* ApiItemKind.Function */:
617
+ /**
618
+ * If this option is set, group functions by first param.
619
+ * Organize using a map where the key is the first param.
620
+ */
621
+ if (this._sortFunctions) {
622
+ const firstParam = apiMember
623
+ .parameters[0] || { name: '' };
624
+ if (!functionsRowGroup[firstParam.name]) {
625
+ functionsRowGroup[firstParam.name] = [];
626
+ }
627
+ if (!functionsDefinitionsGroup[firstParam.name]) {
628
+ functionsDefinitionsGroup[firstParam.name] = [];
629
+ }
630
+ functionsRowGroup[firstParam.name].push(row);
631
+ functionsDefinitionsGroup[firstParam.name].push(...this._createCompleteOutputForApiItem(apiMember));
632
+ }
633
+ else {
634
+ finalFunctionsTable.addRow(row);
635
+ finalFunctionsDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
636
+ }
616
637
  break;
617
- case "TypeAlias" /* TypeAlias */:
638
+ case "TypeAlias" /* ApiItemKind.TypeAlias */:
618
639
  typeAliasesTable.addRow(row);
619
640
  typeAliasDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
620
641
  break;
621
- case "Variable" /* Variable */:
642
+ case "Variable" /* ApiItemKind.Variable */:
622
643
  variablesTable.addRow(row);
623
644
  variablesDefinitions.push(...this._createCompleteOutputForApiItem(apiMember));
624
645
  break;
625
646
  }
626
647
  }
627
- if (functionsTable.rows.length > 0) {
648
+ /**
649
+ * Sort the functions groups by first param. If priority params were
650
+ * provided to --sort-functions, will put them first in the order
651
+ * given.
652
+ */
653
+ if (this._sortFunctions) {
654
+ let priorityParams = [];
655
+ if (this._sortFunctions.includes(',')) {
656
+ priorityParams = this._sortFunctions.split(',');
657
+ }
658
+ else {
659
+ priorityParams = [this._sortFunctions];
660
+ }
661
+ const sortedFunctionsFirstParamKeys = Object.keys(functionsRowGroup).sort((a, b) => {
662
+ if (priorityParams.includes(a) && priorityParams.includes(b)) {
663
+ return priorityParams.indexOf(a) - priorityParams.indexOf(b);
664
+ }
665
+ else if (priorityParams.includes(a)) {
666
+ return -1;
667
+ }
668
+ else if (priorityParams.includes(b)) {
669
+ return 1;
670
+ }
671
+ return a.localeCompare(b);
672
+ });
673
+ for (const paramKey of sortedFunctionsFirstParamKeys) {
674
+ // Header for each group of functions grouped by first param.
675
+ // Doesn't make sense if there's only one group.
676
+ const headerText = paramKey ? `function(${paramKey}...)` : 'function()';
677
+ if (sortedFunctionsFirstParamKeys.length > 1) {
678
+ finalFunctionsTable.addRow(new DocTableRow_1.DocTableRow({ configuration }, [
679
+ new DocTableCell_1.DocTableCell({ configuration }, [
680
+ new tsdoc_1.DocParagraph({ configuration }, [
681
+ new DocEmphasisSpan_1.DocEmphasisSpan({ configuration, bold: true }, [
682
+ new tsdoc_1.DocPlainText({ configuration, text: headerText })
683
+ ])
684
+ ])
685
+ ])
686
+ ]));
687
+ }
688
+ for (const functionsRow of functionsRowGroup[paramKey]) {
689
+ finalFunctionsTable.addRow(functionsRow);
690
+ }
691
+ for (const functionDefinition of functionsDefinitionsGroup[paramKey]) {
692
+ finalFunctionsDefinitions.push(functionDefinition);
693
+ }
694
+ }
695
+ }
696
+ if (finalFunctionsTable.rows.length > 0) {
628
697
  output.push(new DocHeading_1.DocHeading({ configuration, title: 'Functions' }));
629
- output.push(functionsTable);
698
+ output.push(finalFunctionsTable);
630
699
  }
631
700
  if (classesTable.rows.length > 0) {
632
701
  output.push(new DocHeading_1.DocHeading({ configuration, title: 'Classes' }));
@@ -652,8 +721,8 @@ page_type: reference
652
721
  output.push(new DocHeading_1.DocHeading({ configuration, title: 'Type Aliases' }));
653
722
  output.push(typeAliasesTable);
654
723
  }
655
- if (functionsDefinitions.length > 0) {
656
- output.push(...functionsDefinitions);
724
+ if (finalFunctionsDefinitions.length > 0) {
725
+ output.push(...finalFunctionsDefinitions);
657
726
  }
658
727
  if (variablesDefinitions.length > 0) {
659
728
  output.push(...variablesDefinitions);