@firebase/api-documenter 0.1.2-canary.233e117f0
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.
- package/CHANGELOG.md +10 -0
- package/README.md +16 -0
- package/dist/cli/ApiDocumenterCommandLine.d.ts +22 -0
- package/dist/cli/ApiDocumenterCommandLine.js +44 -0
- package/dist/cli/ApiDocumenterCommandLine.js.map +1 -0
- package/dist/cli/BaseAction.d.ts +37 -0
- package/dist/cli/BaseAction.js +125 -0
- package/dist/cli/BaseAction.js.map +1 -0
- package/dist/cli/MarkdownAction.d.ts +22 -0
- package/dist/cli/MarkdownAction.js +47 -0
- package/dist/cli/MarkdownAction.js.map +1 -0
- package/dist/cli/TocAction.d.ts +25 -0
- package/dist/cli/TocAction.js +67 -0
- package/dist/cli/TocAction.js.map +1 -0
- package/dist/documenters/DocumenterConfig.d.ts +45 -0
- package/dist/documenters/DocumenterConfig.js +63 -0
- package/dist/documenters/DocumenterConfig.js.map +1 -0
- package/dist/documenters/IConfigFile.d.ts +98 -0
- package/dist/documenters/IConfigFile.js +19 -0
- package/dist/documenters/IConfigFile.js.map +1 -0
- package/dist/documenters/MarkdownDocumenter.d.ts +75 -0
- package/dist/documenters/MarkdownDocumenter.js +750 -0
- package/dist/documenters/MarkdownDocumenter.js.map +1 -0
- package/dist/documenters/MarkdownDocumenterHelpers.d.ts +40 -0
- package/dist/documenters/MarkdownDocumenterHelpers.js +306 -0
- package/dist/documenters/MarkdownDocumenterHelpers.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/CustomMarkdownEmitter.d.ts +32 -0
- package/dist/markdown/CustomMarkdownEmitter.js +161 -0
- package/dist/markdown/CustomMarkdownEmitter.js.map +1 -0
- package/dist/markdown/MarkdownEmitter.d.ts +48 -0
- package/dist/markdown/MarkdownEmitter.js +243 -0
- package/dist/markdown/MarkdownEmitter.js.map +1 -0
- package/dist/markdown/test/CustomMarkdownEmitter.test.d.ts +17 -0
- package/dist/markdown/test/CustomMarkdownEmitter.test.js +205 -0
- package/dist/markdown/test/CustomMarkdownEmitter.test.js.map +1 -0
- package/dist/nodes/CustomDocNodeKind.d.ts +32 -0
- package/dist/nodes/CustomDocNodeKind.js +58 -0
- package/dist/nodes/CustomDocNodeKind.js.map +1 -0
- package/dist/nodes/DocEmphasisSpan.d.ts +35 -0
- package/dist/nodes/DocEmphasisSpan.js +39 -0
- package/dist/nodes/DocEmphasisSpan.js.map +1 -0
- package/dist/nodes/DocHeading.d.ts +38 -0
- package/dist/nodes/DocHeading.js +45 -0
- package/dist/nodes/DocHeading.js.map +1 -0
- package/dist/nodes/DocNoteBox.d.ts +33 -0
- package/dist/nodes/DocNoteBox.js +41 -0
- package/dist/nodes/DocNoteBox.js.map +1 -0
- package/dist/nodes/DocTable.d.ts +41 -0
- package/dist/nodes/DocTable.js +77 -0
- package/dist/nodes/DocTable.js.map +1 -0
- package/dist/nodes/DocTableCell.d.ts +31 -0
- package/dist/nodes/DocTableCell.js +37 -0
- package/dist/nodes/DocTableCell.js.map +1 -0
- package/dist/nodes/DocTableRow.d.ts +38 -0
- package/dist/nodes/DocTableRow.js +68 -0
- package/dist/nodes/DocTableRow.js.map +1 -0
- package/dist/plugin/IApiDocumenterPluginManifest.d.ts +85 -0
- package/dist/plugin/IApiDocumenterPluginManifest.js +19 -0
- package/dist/plugin/IApiDocumenterPluginManifest.js.map +1 -0
- package/dist/plugin/MarkdownDocumenterAccessor.d.ts +41 -0
- package/dist/plugin/MarkdownDocumenterAccessor.js +44 -0
- package/dist/plugin/MarkdownDocumenterAccessor.js.map +1 -0
- package/dist/plugin/MarkdownDocumenterFeature.d.ts +88 -0
- package/dist/plugin/MarkdownDocumenterFeature.js +66 -0
- package/dist/plugin/MarkdownDocumenterFeature.js.map +1 -0
- package/dist/plugin/PluginFeature.d.ts +61 -0
- package/dist/plugin/PluginFeature.js +76 -0
- package/dist/plugin/PluginFeature.js.map +1 -0
- package/dist/plugin/PluginLoader.d.ts +22 -0
- package/dist/plugin/PluginLoader.js +100 -0
- package/dist/plugin/PluginLoader.js.map +1 -0
- package/dist/schemas/api-documenter-template.json +92 -0
- package/dist/schemas/api-documenter.schema.json +42 -0
- package/dist/start.d.ts +18 -0
- package/dist/start.js +32 -0
- package/dist/start.js.map +1 -0
- package/dist/toc.d.ts +25 -0
- package/dist/toc.js +61 -0
- package/dist/toc.js.map +1 -0
- package/dist/utils/IndentedWriter.d.ts +116 -0
- package/dist/utils/IndentedWriter.js +213 -0
- package/dist/utils/IndentedWriter.js.map +1 -0
- package/dist/utils/Utilities.d.ts +28 -0
- package/dist/utils/Utilities.js +47 -0
- package/dist/utils/Utilities.js.map +1 -0
- package/dist/utils/test/IndentedWriter.test.d.ts +17 -0
- package/dist/utils/test/IndentedWriter.test.js +87 -0
- package/dist/utils/test/IndentedWriter.test.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* This is an internal part of the plugin infrastructure.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* This object is the constructor parameter for API Documenter plugin features.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare class PluginFeatureInitialization {
|
|
26
|
+
/** @internal */
|
|
27
|
+
_context: PluginFeatureContext;
|
|
28
|
+
/** @internal */
|
|
29
|
+
constructor();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Context object for {@link PluginFeature}.
|
|
33
|
+
* Exposes various services that can be used by a plugin.
|
|
34
|
+
*
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare class PluginFeatureContext {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The abstract base class for all API Documenter plugin features.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare abstract class PluginFeature {
|
|
44
|
+
/**
|
|
45
|
+
* Exposes various services that can be used by a plugin.
|
|
46
|
+
*/
|
|
47
|
+
context: PluginFeatureContext;
|
|
48
|
+
/**
|
|
49
|
+
* The subclass should pass the `initialization` through to the base class.
|
|
50
|
+
* Do not put custom initialization code in the constructor. Instead perform your initialization in the
|
|
51
|
+
* `onInitialized()` event function.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
constructor(initialization: PluginFeatureInitialization);
|
|
55
|
+
/**
|
|
56
|
+
* This event function is called after the feature is initialized, but before any processing occurs.
|
|
57
|
+
* @virtual
|
|
58
|
+
*/
|
|
59
|
+
onInitialized(): void;
|
|
60
|
+
static [Symbol.hasInstance](instance: object): boolean;
|
|
61
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2020 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.PluginFeature = exports.PluginFeatureContext = exports.PluginFeatureInitialization = void 0;
|
|
20
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
21
|
+
// See LICENSE in the project root for license information.
|
|
22
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
23
|
+
/**
|
|
24
|
+
* This is an internal part of the plugin infrastructure.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* This object is the constructor parameter for API Documenter plugin features.
|
|
28
|
+
*
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
class PluginFeatureInitialization {
|
|
32
|
+
/** @internal */
|
|
33
|
+
constructor() {
|
|
34
|
+
// reserved for future use
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.PluginFeatureInitialization = PluginFeatureInitialization;
|
|
38
|
+
/**
|
|
39
|
+
* Context object for {@link PluginFeature}.
|
|
40
|
+
* Exposes various services that can be used by a plugin.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
class PluginFeatureContext {
|
|
45
|
+
}
|
|
46
|
+
exports.PluginFeatureContext = PluginFeatureContext;
|
|
47
|
+
const uuidPluginFeature = '56876472-7134-4812-819e-533de0ee10e6';
|
|
48
|
+
/**
|
|
49
|
+
* The abstract base class for all API Documenter plugin features.
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
class PluginFeature {
|
|
53
|
+
/**
|
|
54
|
+
* The subclass should pass the `initialization` through to the base class.
|
|
55
|
+
* Do not put custom initialization code in the constructor. Instead perform your initialization in the
|
|
56
|
+
* `onInitialized()` event function.
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
constructor(initialization) {
|
|
60
|
+
// reserved for future expansion
|
|
61
|
+
this.context = initialization._context;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* This event function is called after the feature is initialized, but before any processing occurs.
|
|
65
|
+
* @virtual
|
|
66
|
+
*/
|
|
67
|
+
onInitialized() {
|
|
68
|
+
// (implemented by child class)
|
|
69
|
+
}
|
|
70
|
+
static [Symbol.hasInstance](instance) {
|
|
71
|
+
return node_core_library_1.TypeUuid.isInstanceOf(instance, uuidPluginFeature);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.PluginFeature = PluginFeature;
|
|
75
|
+
node_core_library_1.TypeUuid.registerClass(PluginFeature, uuidPluginFeature);
|
|
76
|
+
//# sourceMappingURL=PluginFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginFeature.js","sourceRoot":"","sources":["../../src/plugin/PluginFeature.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,4FAA4F;AAC5F,2DAA2D;AAE3D,oEAAwD;AAExD;;;;;;;GAOG;AACH,MAAa,2BAA2B;IAItC,gBAAgB;IAChB;QACE,0BAA0B;IAC5B,CAAC;CACF;AARD,kEAQC;AAED;;;;;GAKG;AACH,MAAa,oBAAoB;CAAG;AAApC,oDAAoC;AAEpC,MAAM,iBAAiB,GAAW,sCAAsC,CAAC;AAEzE;;;GAGG;AACH,MAAsB,aAAa;IAMjC;;;;;OAKG;IACH,YAAmB,cAA2C;QAC5D,gCAAgC;QAChC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,QAAQ,CAAC;IACzC,CAAC;IAED;;;OAGG;IACI,aAAa;QAClB,+BAA+B;IACjC,CAAC;IAEM,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAgB;QACjD,OAAO,4BAAQ,CAAC,YAAY,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IAC5D,CAAC;CACF;AA5BD,sCA4BC;AAED,4BAAQ,CAAC,aAAa,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { MarkdownDocumenterFeature, MarkdownDocumenterFeatureContext } from './MarkdownDocumenterFeature';
|
|
18
|
+
import { DocumenterConfig } from '../documenters/DocumenterConfig';
|
|
19
|
+
export declare class PluginLoader {
|
|
20
|
+
markdownDocumenterFeature: MarkdownDocumenterFeature | undefined;
|
|
21
|
+
load(documenterConfig: DocumenterConfig, createContext: () => MarkdownDocumenterFeatureContext): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2020 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.PluginLoader = void 0;
|
|
20
|
+
const tslib_1 = require("tslib");
|
|
21
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
22
|
+
// See LICENSE in the project root for license information.
|
|
23
|
+
const path = tslib_1.__importStar(require("path"));
|
|
24
|
+
const resolve = tslib_1.__importStar(require("resolve"));
|
|
25
|
+
const MarkdownDocumenterFeature_1 = require("./MarkdownDocumenterFeature");
|
|
26
|
+
const PluginFeature_1 = require("./PluginFeature");
|
|
27
|
+
class PluginLoader {
|
|
28
|
+
load(documenterConfig, createContext) {
|
|
29
|
+
const configFileFolder = path.dirname(documenterConfig.configFilePath);
|
|
30
|
+
for (const configPlugin of documenterConfig.configFile.plugins || []) {
|
|
31
|
+
try {
|
|
32
|
+
// Look for the package name in the same place as the config file
|
|
33
|
+
const resolvedEntryPointPath = resolve.sync(configPlugin.packageName, {
|
|
34
|
+
basedir: configFileFolder
|
|
35
|
+
});
|
|
36
|
+
// Load the package
|
|
37
|
+
const entryPoint = require(resolvedEntryPointPath);
|
|
38
|
+
if (!entryPoint) {
|
|
39
|
+
throw new Error('Invalid entry point');
|
|
40
|
+
}
|
|
41
|
+
if (!entryPoint.apiDocumenterPluginManifest) {
|
|
42
|
+
throw new Error(`The package is not an API documenter plugin;` +
|
|
43
|
+
` the "apiDocumenterPluginManifest" export was not found`);
|
|
44
|
+
}
|
|
45
|
+
const manifest = entryPoint.apiDocumenterPluginManifest;
|
|
46
|
+
if (manifest.manifestVersion !== 1000) {
|
|
47
|
+
throw new Error(`The plugin is not compatible with this version of API Documenter;` +
|
|
48
|
+
` unsupported manifestVersion`);
|
|
49
|
+
}
|
|
50
|
+
const loadedPlugin = {
|
|
51
|
+
packageName: configPlugin.packageName,
|
|
52
|
+
manifest
|
|
53
|
+
};
|
|
54
|
+
const featureDefinitionsByName = new Map();
|
|
55
|
+
for (const featureDefinition of manifest.features) {
|
|
56
|
+
featureDefinitionsByName.set(featureDefinition.featureName, featureDefinition);
|
|
57
|
+
}
|
|
58
|
+
for (const featureName of configPlugin.enabledFeatureNames) {
|
|
59
|
+
const featureDefinition = featureDefinitionsByName.get(featureName);
|
|
60
|
+
if (!featureDefinition) {
|
|
61
|
+
throw new Error(`The plugin ${loadedPlugin.packageName} does not have a feature with name "${featureName}"`);
|
|
62
|
+
}
|
|
63
|
+
if (featureDefinition.kind === 'MarkdownDocumenterFeature') {
|
|
64
|
+
if (this.markdownDocumenterFeature) {
|
|
65
|
+
throw new Error('A MarkdownDocumenterFeature is already loaded');
|
|
66
|
+
}
|
|
67
|
+
const initialization = new PluginFeature_1.PluginFeatureInitialization();
|
|
68
|
+
initialization._context = createContext();
|
|
69
|
+
let markdownDocumenterFeature = undefined;
|
|
70
|
+
try {
|
|
71
|
+
markdownDocumenterFeature = new featureDefinition.subclass(initialization);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
throw new Error(`Failed to construct feature subclass:\n` + e.toString());
|
|
75
|
+
}
|
|
76
|
+
if (!(markdownDocumenterFeature instanceof MarkdownDocumenterFeature_1.MarkdownDocumenterFeature)) {
|
|
77
|
+
throw new Error('The constructed subclass was not an instance of MarkdownDocumenterFeature');
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
markdownDocumenterFeature.onInitialized();
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
throw new Error('Error occurred during the onInitialized() event: ' +
|
|
84
|
+
e.toString());
|
|
85
|
+
}
|
|
86
|
+
this.markdownDocumenterFeature = markdownDocumenterFeature;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw new Error(`Unknown feature definition kind: "${featureDefinition.kind}"`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
throw new Error(`Error loading plugin ${configPlugin.packageName}: ` + e.message);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.PluginLoader = PluginLoader;
|
|
100
|
+
//# sourceMappingURL=PluginLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginLoader.js","sourceRoot":"","sources":["../../src/plugin/PluginLoader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAEH,4FAA4F;AAC5F,2DAA2D;AAE3D,mDAA6B;AAC7B,yDAAmC;AAMnC,2EAGqC;AACrC,mDAA8D;AAQ9D,MAAa,YAAY;IAGhB,IAAI,CACT,gBAAkC,EAClC,aAAqD;QAErD,MAAM,gBAAgB,GAAW,IAAI,CAAC,OAAO,CAC3C,gBAAgB,CAAC,cAAc,CAChC,CAAC;QACF,KAAK,MAAM,YAAY,IAAI,gBAAgB,CAAC,UAAU,CAAC,OAAO,IAAI,EAAE,EAAE;YACpE,IAAI;gBACF,iEAAiE;gBACjE,MAAM,sBAAsB,GAAW,OAAO,CAAC,IAAI,CACjD,YAAY,CAAC,WAAW,EACxB;oBACE,OAAO,EAAE,gBAAgB;iBAC1B,CACF,CAAC;gBAEF,mBAAmB;gBACnB,MAAM,UAAU,GAEA,OAAO,CAAC,sBAAsB,CAAC,CAAC;gBAEhD,IAAI,CAAC,UAAU,EAAE;oBACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;iBACxC;gBAED,IAAI,CAAC,UAAU,CAAC,2BAA2B,EAAE;oBAC3C,MAAM,IAAI,KAAK,CACb,8CAA8C;wBAC5C,yDAAyD,CAC5D,CAAC;iBACH;gBAED,MAAM,QAAQ,GACZ,UAAU,CAAC,2BAA2B,CAAC;gBAEzC,IAAI,QAAQ,CAAC,eAAe,KAAK,IAAI,EAAE;oBACrC,MAAM,IAAI,KAAK,CACb,mEAAmE;wBACjE,8BAA8B,CACjC,CAAC;iBACH;gBAED,MAAM,YAAY,GAAkB;oBAClC,WAAW,EAAE,YAAY,CAAC,WAAW;oBACrC,QAAQ;iBACT,CAAC;gBAEF,MAAM,wBAAwB,GAG1B,IAAI,GAAG,EAA8B,CAAC;gBAC1C,KAAK,MAAM,iBAAiB,IAAI,QAAQ,CAAC,QAAQ,EAAE;oBACjD,wBAAwB,CAAC,GAAG,CAC1B,iBAAiB,CAAC,WAAW,EAC7B,iBAAiB,CAClB,CAAC;iBACH;gBAED,KAAK,MAAM,WAAW,IAAI,YAAY,CAAC,mBAAmB,EAAE;oBAC1D,MAAM,iBAAiB,GAEP,wBAAwB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;oBAC1D,IAAI,CAAC,iBAAiB,EAAE;wBACtB,MAAM,IAAI,KAAK,CACb,cAAc,YAAY,CAAC,WAAW,uCAAuC,WAAW,GAAG,CAC5F,CAAC;qBACH;oBAED,IAAI,iBAAiB,CAAC,IAAI,KAAK,2BAA2B,EAAE;wBAC1D,IAAI,IAAI,CAAC,yBAAyB,EAAE;4BAClC,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;yBAClE;wBAED,MAAM,cAAc,GAAgC,IAAI,2CAA2B,EAAE,CAAC;wBACtF,cAAc,CAAC,QAAQ,GAAG,aAAa,EAAE,CAAC;wBAE1C,IAAI,yBAAyB,GAEb,SAAS,CAAC;wBAC1B,IAAI;4BACF,yBAAyB,GAAG,IAAI,iBAAiB,CAAC,QAAQ,CACxD,cAAc,CACf,CAAC;yBACH;wBAAC,OAAO,CAAC,EAAE;4BACV,MAAM,IAAI,KAAK,CACb,yCAAyC,GAAG,CAAC,CAAC,QAAQ,EAAE,CACzD,CAAC;yBACH;wBACD,IACE,CAAC,CAAC,yBAAyB,YAAY,qDAAyB,CAAC,EACjE;4BACA,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;yBACH;wBAED,IAAI;4BACF,yBAAyB,CAAC,aAAa,EAAE,CAAC;yBAC3C;wBAAC,OAAO,CAAC,EAAE;4BACV,MAAM,IAAI,KAAK,CACb,mDAAmD;gCACjD,CAAC,CAAC,QAAQ,EAAE,CACf,CAAC;yBACH;wBAED,IAAI,CAAC,yBAAyB,GAAG,yBAAyB,CAAC;qBAC5D;yBAAM;wBACL,MAAM,IAAI,KAAK,CACb,qCAAqC,iBAAiB,CAAC,IAAI,GAAG,CAC/D,CAAC;qBACH;iBACF;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,IAAI,KAAK,CACb,wBAAwB,YAAY,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,OAAO,CACjE,CAAC;aACH;SACF;IACH,CAAC;CACF;AA3HD,oCA2HC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file for API Documenter. For more info, please visit: https://api-extractor.com
|
|
3
|
+
*/
|
|
4
|
+
{
|
|
5
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-documenter.schema.json",
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Specifies the output target.
|
|
9
|
+
* Supported values are "docfx" or "markdown"
|
|
10
|
+
*/
|
|
11
|
+
// "outputTarget": "markdown",
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Specifies what type of newlines API Documenter should use when writing output files. By default, the output files
|
|
15
|
+
* will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead.
|
|
16
|
+
* To use the OS's default newline kind, specify "os".
|
|
17
|
+
*
|
|
18
|
+
* DEFAULT VALUE: "crlf"
|
|
19
|
+
*/
|
|
20
|
+
// "newlineKind": "crlf",
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* This enables an experimental feature that will be officially released with the next major version
|
|
24
|
+
* of API Documenter. It requires DocFX 2.46 or newer. It enables documentation for namespaces and
|
|
25
|
+
* adds them to the table of contents. This will also affect file layout as namespaced items will be nested
|
|
26
|
+
* under a directory for the namespace instead of just within the package.
|
|
27
|
+
*
|
|
28
|
+
* This setting currently only affects the 'docfx' output target. It is equivalent to the `--new-docfx-namespaces`
|
|
29
|
+
* command-line parameter.
|
|
30
|
+
*/
|
|
31
|
+
// "newDocfxNamespaces": false,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Describes plugin packages to be loaded, and which features to enable.
|
|
35
|
+
*/
|
|
36
|
+
"plugins": [
|
|
37
|
+
// {
|
|
38
|
+
// "packageName": "doc-plugin-example",
|
|
39
|
+
// "enabledFeatureNames": [ "example-feature" ]
|
|
40
|
+
// }
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Configures how the table of contents is generated.
|
|
45
|
+
*/
|
|
46
|
+
"tableOfContents": {
|
|
47
|
+
/**
|
|
48
|
+
* Allows hand-coded items to be injected into the table of contents.
|
|
49
|
+
*
|
|
50
|
+
* DEFAULT VALUE: (none)
|
|
51
|
+
*/
|
|
52
|
+
// "items": [
|
|
53
|
+
// { "name": "Example Node", "href": "~/homepage/homepage.md" },
|
|
54
|
+
// {
|
|
55
|
+
// "name": "API Reference",
|
|
56
|
+
// "items": [
|
|
57
|
+
// { "name": "References" }
|
|
58
|
+
// ]
|
|
59
|
+
// }
|
|
60
|
+
// ],
|
|
61
|
+
/**
|
|
62
|
+
* Optional category name that is recommended to include in the `tocConfig`,
|
|
63
|
+
* along with one of the filters: `filterByApiItemName` or `filterByInlineTag`.
|
|
64
|
+
* Any items that are not matched to the mentioned filters will be placed under this
|
|
65
|
+
* catchAll category. If none provided the items will not be included in the final toc.yml file.
|
|
66
|
+
*
|
|
67
|
+
* DEFAULT VALUE: (none)
|
|
68
|
+
*/
|
|
69
|
+
// "catchAllCategory": "References",
|
|
70
|
+
/**
|
|
71
|
+
* When loading more than one api.json files that might include the same API items,
|
|
72
|
+
* toggle either to show duplicates or not.
|
|
73
|
+
*
|
|
74
|
+
* DEFAULT VALUE: false
|
|
75
|
+
*/
|
|
76
|
+
// "noDuplicateEntries": true,
|
|
77
|
+
/**
|
|
78
|
+
* Toggle either sorting of the API items should be made based on category name presence
|
|
79
|
+
* in the API item's name.
|
|
80
|
+
*
|
|
81
|
+
* DEFAULT VALUE: false
|
|
82
|
+
*/
|
|
83
|
+
// "filterByApiItemName": false,
|
|
84
|
+
/**
|
|
85
|
+
* Filter that can be used to sort the API items according to an inline custom tag
|
|
86
|
+
* that is present on them.
|
|
87
|
+
*
|
|
88
|
+
* DEFAULT VALUE: (none)
|
|
89
|
+
*/
|
|
90
|
+
// "filterByInlineTag": "@docCategory"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "API Documenter Configuration",
|
|
3
|
+
"description": "Describes how the API Documenter tool will process a project.",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"$schema": {
|
|
7
|
+
"description": "Part of the JSON Schema standard, this optional keyword declares the URL of the schema that the file conforms to. Editors may download the schema and use it to perform syntax highlighting.",
|
|
8
|
+
"type": "string"
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"outputTarget": {
|
|
12
|
+
"description": "Specifies what type of documentation will be generated",
|
|
13
|
+
"type": "string",
|
|
14
|
+
"enum": ["docfx", "markdown"]
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
"newlineKind": {
|
|
18
|
+
"description": "Specifies what type of newlines API Documenter should use when writing output files. By default, the output files will be written with Windows-style newlines. To use POSIX-style newlines, specify \"lf\" instead. To use the OS's default newline kind, specify \"os\".",
|
|
19
|
+
"type": "string",
|
|
20
|
+
"enum": ["crlf", "lf", "os"],
|
|
21
|
+
"default": "crlf"
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
"newDocfxNamespaces": {
|
|
25
|
+
"description": "This enables an experimental feature that will be officially released with the next major version of API Documenter. It requires DocFX 2.46 or newer. It enables documentation for namespaces and adds them to the table of contents. This will also affect file layout as namespaced items will be nested under a directory for the namespace instead of just within the package.",
|
|
26
|
+
"type": "boolean"
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
"plugins": {
|
|
30
|
+
"description": "Specifies plugin packages to be loaded",
|
|
31
|
+
"type": "array"
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
"tableOfContents": {
|
|
35
|
+
"description": "Configures how the table of contents is generated.",
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": true
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
"additionalProperties": false
|
|
42
|
+
}
|
package/dist/start.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2020 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
package/dist/start.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* @license
|
|
5
|
+
* Copyright 2020 Google LLC
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
const tslib_1 = require("tslib");
|
|
21
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
22
|
+
// See LICENSE in the project root for license information.
|
|
23
|
+
const os = tslib_1.__importStar(require("os"));
|
|
24
|
+
const colors_1 = tslib_1.__importDefault(require("colors"));
|
|
25
|
+
const node_core_library_1 = require("@rushstack/node-core-library");
|
|
26
|
+
const ApiDocumenterCommandLine_1 = require("./cli/ApiDocumenterCommandLine");
|
|
27
|
+
const myPackageVersion = node_core_library_1.PackageJsonLookup.loadOwnPackageJson(__dirname)
|
|
28
|
+
.version;
|
|
29
|
+
console.log(os.EOL + colors_1.default.bold(`@firebase/api-documenter ${myPackageVersion} ` + os.EOL));
|
|
30
|
+
const parser = new ApiDocumenterCommandLine_1.ApiDocumenterCommandLine();
|
|
31
|
+
parser.execute().catch(console.error); // CommandLineParser.execute() should never reject the promise
|
|
32
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../src/start.ts"],"names":[],"mappings":";;AAEA;;;;;;;;;;;;;;;GAeG;;;AAEH,4FAA4F;AAC5F,2DAA2D;AAE3D,+CAAyB;AACzB,4DAA4B;AAE5B,oEAAiE;AAEjE,6EAA0E;AAE1E,MAAM,gBAAgB,GAAW,qCAAiB,CAAC,kBAAkB,CAAC,SAAS,CAAC;KAC7E,OAAO,CAAC;AAEX,OAAO,CAAC,GAAG,CACT,EAAE,CAAC,GAAG,GAAG,gBAAM,CAAC,IAAI,CAAC,4BAA4B,gBAAgB,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAC/E,CAAC;AAEF,MAAM,MAAM,GAA6B,IAAI,mDAAwB,EAAE,CAAC;AAExE,MAAM,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,8DAA8D"}
|
package/dist/toc.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2021 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { ApiModel } from 'api-extractor-model-me';
|
|
18
|
+
export interface ITocGenerationOptions {
|
|
19
|
+
apiModel: ApiModel;
|
|
20
|
+
g3Path: string;
|
|
21
|
+
outputFolder: string;
|
|
22
|
+
addFileNameSuffix: boolean;
|
|
23
|
+
jsSdk: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function generateToc({ apiModel, g3Path, outputFolder, addFileNameSuffix, jsSdk }: ITocGenerationOptions): void;
|
package/dist/toc.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2021 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.generateToc = void 0;
|
|
20
|
+
const tslib_1 = require("tslib");
|
|
21
|
+
const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
|
|
22
|
+
const MarkdownDocumenterHelpers_1 = require("./documenters/MarkdownDocumenterHelpers");
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const path_1 = require("path");
|
|
25
|
+
function generateToc({ apiModel, g3Path, outputFolder, addFileNameSuffix, jsSdk }) {
|
|
26
|
+
const toc = [];
|
|
27
|
+
if (jsSdk) {
|
|
28
|
+
const firebaseToc = {
|
|
29
|
+
title: 'firebase',
|
|
30
|
+
path: `${g3Path}/index`,
|
|
31
|
+
section: []
|
|
32
|
+
};
|
|
33
|
+
toc.push(firebaseToc);
|
|
34
|
+
}
|
|
35
|
+
generateTocRecursively(apiModel, g3Path, addFileNameSuffix, toc);
|
|
36
|
+
fs_1.writeFileSync(path_1.resolve(outputFolder, 'toc.yaml'), js_yaml_1.default.dump({ toc }, {
|
|
37
|
+
quotingType: '"'
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
exports.generateToc = generateToc;
|
|
41
|
+
function generateTocRecursively(apiItem, g3Path, addFileNameSuffix, toc) {
|
|
42
|
+
// generate toc item only for entry points
|
|
43
|
+
if (apiItem.kind === "EntryPoint" /* EntryPoint */) {
|
|
44
|
+
// Entry point
|
|
45
|
+
const entryPointName = apiItem.canonicalReference
|
|
46
|
+
.source.escapedPath.replace('@firebase/', '');
|
|
47
|
+
const entryPointToc = {
|
|
48
|
+
title: entryPointName,
|
|
49
|
+
path: `${g3Path}/${MarkdownDocumenterHelpers_1.getFilenameForApiItem(apiItem, addFileNameSuffix)}`,
|
|
50
|
+
section: []
|
|
51
|
+
};
|
|
52
|
+
toc.push(entryPointToc);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// travel the api tree to find the next entry point
|
|
56
|
+
for (const member of apiItem.members) {
|
|
57
|
+
generateTocRecursively(member, g3Path, addFileNameSuffix, toc);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=toc.js.map
|
package/dist/toc.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toc.js","sourceRoot":"","sources":["../src/toc.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;AAEH,8DAA2B;AAE3B,uFAAgF;AAEhF,2BAAmC;AACnC,+BAA+B;AAgB/B,SAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACiB;IACtB,MAAM,GAAG,GAAG,EAAE,CAAC;IAEf,IAAI,KAAK,EAAE;QACT,MAAM,WAAW,GAAa;YAC5B,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,GAAG,MAAM,QAAQ;YACvB,OAAO,EAAE,EAAE;SACZ,CAAC;QACF,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KACvB;IAED,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,CAAC,CAAC;IAEjE,kBAAa,CACX,cAAO,CAAC,YAAY,EAAE,UAAU,CAAC,EACjC,iBAAI,CAAC,IAAI,CACP,EAAE,GAAG,EAAE,EACP;QACE,WAAW,EAAE,GAAG;KACjB,CACF,CACF,CAAC;AACJ,CAAC;AA7BD,kCA6BC;AAED,SAAS,sBAAsB,CAC7B,OAAgB,EAChB,MAAc,EACd,iBAA0B,EAC1B,GAAe;IAEf,0CAA0C;IAC1C,IAAI,OAAO,CAAC,IAAI,kCAA2B,EAAE;QAC3C,cAAc;QACd,MAAM,cAAc,GAAI,OAAO,CAAC,kBAAkB;aAC/C,MAAwB,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAClE,MAAM,aAAa,GAAa;YAC9B,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,GAAG,MAAM,IAAI,iDAAqB,CAAC,OAAO,EAAE,iBAAiB,CAAC,EAAE;YACtE,OAAO,EAAE,EAAE;SACZ,CAAC;QAEF,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;KACzB;SAAM;QACL,mDAAmD;QACnD,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE;YACpC,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,GAAG,CAAC,CAAC;SAChE;KACF;AACH,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2020 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { IStringBuilder } from '@rushstack/node-core-library';
|
|
18
|
+
/**
|
|
19
|
+
* A utility for writing indented text.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
*
|
|
23
|
+
* Note that the indentation is inserted at the last possible opportunity.
|
|
24
|
+
* For example, this code...
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* writer.write('begin\n');
|
|
28
|
+
* writer.increaseIndent();
|
|
29
|
+
* writer.write('one\ntwo\n');
|
|
30
|
+
* writer.decreaseIndent();
|
|
31
|
+
* writer.increaseIndent();
|
|
32
|
+
* writer.decreaseIndent();
|
|
33
|
+
* writer.write('end');
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ...would produce this output:
|
|
37
|
+
*
|
|
38
|
+
* ```
|
|
39
|
+
* begin
|
|
40
|
+
* one
|
|
41
|
+
* two
|
|
42
|
+
* end
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class IndentedWriter {
|
|
46
|
+
/**
|
|
47
|
+
* The text characters used to create one level of indentation.
|
|
48
|
+
* Two spaces by default.
|
|
49
|
+
*/
|
|
50
|
+
defaultIndentPrefix: string;
|
|
51
|
+
private readonly _builder;
|
|
52
|
+
private _latestChunk;
|
|
53
|
+
private _previousChunk;
|
|
54
|
+
private _atStartOfLine;
|
|
55
|
+
private readonly _indentStack;
|
|
56
|
+
private _indentText;
|
|
57
|
+
constructor(builder?: IStringBuilder);
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the output that was built so far.
|
|
60
|
+
*/
|
|
61
|
+
getText(): string;
|
|
62
|
+
toString(): string;
|
|
63
|
+
/**
|
|
64
|
+
* Increases the indentation. Normally the indentation is two spaces,
|
|
65
|
+
* however an arbitrary prefix can optional be specified. (For example,
|
|
66
|
+
* the prefix could be "// " to indent and comment simultaneously.)
|
|
67
|
+
* Each call to IndentedWriter.increaseIndent() must be followed by a
|
|
68
|
+
* corresponding call to IndentedWriter.decreaseIndent().
|
|
69
|
+
*/
|
|
70
|
+
increaseIndent(indentPrefix?: string): void;
|
|
71
|
+
/**
|
|
72
|
+
* Decreases the indentation, reverting the effect of the corresponding call
|
|
73
|
+
* to IndentedWriter.increaseIndent().
|
|
74
|
+
*/
|
|
75
|
+
decreaseIndent(): void;
|
|
76
|
+
/**
|
|
77
|
+
* A shorthand for ensuring that increaseIndent()/decreaseIndent() occur
|
|
78
|
+
* in pairs.
|
|
79
|
+
*/
|
|
80
|
+
indentScope(scope: () => void, indentPrefix?: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Adds a newline if the file pointer is not already at the start of the line (or start of the stream).
|
|
83
|
+
*/
|
|
84
|
+
ensureNewLine(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Adds up to two newlines to ensure that there is a blank line above the current line.
|
|
87
|
+
*/
|
|
88
|
+
ensureSkippedLine(): void;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the last character that was written, or an empty string if no characters have been written yet.
|
|
91
|
+
*/
|
|
92
|
+
peekLastCharacter(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Returns the second to last character that was written, or an empty string if less than one characters
|
|
95
|
+
* have been written yet.
|
|
96
|
+
*/
|
|
97
|
+
peekSecondLastCharacter(): string;
|
|
98
|
+
/**
|
|
99
|
+
* Writes some text to the internal string buffer, applying indentation according
|
|
100
|
+
* to the current indentation level. If the string contains multiple newlines,
|
|
101
|
+
* each line will be indented separately.
|
|
102
|
+
*/
|
|
103
|
+
write(message: string): void;
|
|
104
|
+
/**
|
|
105
|
+
* A shorthand for writing an optional message, followed by a newline.
|
|
106
|
+
* Indentation is applied following the semantics of IndentedWriter.write().
|
|
107
|
+
*/
|
|
108
|
+
writeLine(message?: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Writes a string that does not contain any newline characters.
|
|
111
|
+
*/
|
|
112
|
+
private _writeLinePart;
|
|
113
|
+
private _writeNewLine;
|
|
114
|
+
private _write;
|
|
115
|
+
private _updateIndentText;
|
|
116
|
+
}
|