Skip to content

Commit

Permalink
prettier . --write
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Jun 9, 2020
1 parent f7ad5d1 commit e7e9429
Show file tree
Hide file tree
Showing 814 changed files with 12,359 additions and 11,784 deletions.
4 changes: 2 additions & 2 deletions apps/api-documenter/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require("@rushstack/eslint-config/patch-eslint6");
require('@rushstack/eslint-config/patch-eslint6');

module.exports = {
extends: [ "@rushstack/eslint-config" ],
extends: ['@rushstack/eslint-config'],
parserOptions: { tsconfigRootDir: __dirname },
};
2 changes: 1 addition & 1 deletion apps/api-documenter/config/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@

"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts",
"untrimmedFilePath": "<projectFolder>/dist/rollup.d.ts"
}
}
2 changes: 1 addition & 1 deletion apps/api-documenter/config/jest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"isEnabled": true
}
}
8 changes: 5 additions & 3 deletions apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ export class ApiDocumenterCommandLine extends CommandLineParser {
public constructor() {
super({
toolFilename: 'api-documenter',
toolDescription: 'Reads *.api.json files produced by api-extractor, '
+ ' and generates API documentation in various output formats.'
toolDescription:
'Reads *.api.json files produced by api-extractor, ' +
' and generates API documentation in various output formats.',
});
this._populateActions();
}

protected onDefineParameters(): void { // override
protected onDefineParameters(): void {
// override
// No parameters
}

Expand Down
46 changes: 25 additions & 21 deletions apps/api-documenter/src/cli/BaseAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import * as path from 'path';
import * as tsdoc from '@microsoft/tsdoc';
import * as colors from 'colors';

import {
CommandLineAction,
CommandLineStringParameter
} from '@rushstack/ts-command-line';
import { CommandLineAction, CommandLineStringParameter } from '@rushstack/ts-command-line';
import { FileSystem } from '@rushstack/node-core-library';
import {
ApiModel,
ApiItem,
ApiItemContainerMixin,
ApiDocumentedItem,
IResolveDeclarationReferenceResult
IResolveDeclarationReferenceResult,
} from '@microsoft/api-extractor-model';

export abstract class BaseAction extends CommandLineAction {
Expand All @@ -25,22 +22,25 @@ export abstract class BaseAction extends CommandLineAction {
private _inputFolderParameter: CommandLineStringParameter;
private _outputFolderParameter: CommandLineStringParameter;

protected onDefineParameters(): void { // override
protected onDefineParameters(): void {
// override
this._inputFolderParameter = this.defineStringParameter({
parameterLongName: '--input-folder',
parameterShortName: '-i',
argumentName: 'FOLDER1',
description: `Specifies the input folder containing the *.api.json files to be processed.`
+ ` If omitted, the default is "./input"`
description:
`Specifies the input folder containing the *.api.json files to be processed.` +
` If omitted, the default is "./input"`,
});

this._outputFolderParameter = this.defineStringParameter({
parameterLongName: '--output-folder',
parameterShortName: '-o',
argumentName: 'FOLDER2',
description: `Specifies the output folder where the documentation will be written.`
+ ` ANY EXISTING CONTENTS WILL BE DELETED!`
+ ` If omitted, the default is "./${this.actionName}"`
description:
`Specifies the output folder where the documentation will be written.` +
` ANY EXISTING CONTENTS WILL BE DELETED!` +
` If omitted, the default is "./${this.actionName}"`,
});
}

Expand Down Expand Up @@ -72,28 +72,33 @@ export abstract class BaseAction extends CommandLineAction {
// to apply all @inheritDoc tags before the .api.json file is written.
// See DocCommentEnhancer._applyInheritDoc() for more info.
private _applyInheritDoc(apiItem: ApiItem, apiModel: ApiModel): void {

if (apiItem instanceof ApiDocumentedItem) {
if (apiItem.tsdocComment) {
const inheritDocTag: tsdoc.DocInheritDocTag | undefined = apiItem.tsdocComment.inheritDocTag;

if (inheritDocTag && inheritDocTag.declarationReference) {
// Attempt to resolve the declaration reference
const result: IResolveDeclarationReferenceResult
= apiModel.resolveDeclarationReference(inheritDocTag.declarationReference, apiItem);
const result: IResolveDeclarationReferenceResult = apiModel.resolveDeclarationReference(
inheritDocTag.declarationReference,
apiItem
);

if (result.errorMessage) {
console.log(colors.yellow(`Warning: Unresolved @inheritDoc tag for ${apiItem.displayName}: `
+ result.errorMessage));
console.log(
colors.yellow(
`Warning: Unresolved @inheritDoc tag for ${apiItem.displayName}: ` + result.errorMessage
)
);
} else {
if (result.resolvedApiItem instanceof ApiDocumentedItem
&& result.resolvedApiItem.tsdocComment
&& result.resolvedApiItem !== apiItem) {
if (
result.resolvedApiItem instanceof ApiDocumentedItem &&
result.resolvedApiItem.tsdocComment &&
result.resolvedApiItem !== apiItem
) {
this._copyInheritedDocs(apiItem.tsdocComment, result.resolvedApiItem.tsdocComment);
}
}
}

}
}

Expand Down Expand Up @@ -124,5 +129,4 @@ export abstract class BaseAction extends CommandLineAction {

targetDocComment.inheritDocTag = undefined;
}

}
17 changes: 12 additions & 5 deletions apps/api-documenter/src/cli/GenerateAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export class GenerateAction extends BaseAction {
super({
actionName: 'generate',
summary: 'EXPERIMENTAL',
documentation: 'EXPERIMENTAL - This action is a prototype of a new config file driven mode of operation for'
+ ' API Documenter. It is not ready for general usage yet. Its design may change in the future.'
documentation:
'EXPERIMENTAL - This action is a prototype of a new config file driven mode of operation for' +
' API Documenter. It is not ready for general usage yet. Its design may change in the future.',
});
}

protected onExecute(): Promise<void> { // override
protected onExecute(): Promise<void> {
// override
// Look for the config file under the current folder

let configFilePath: string = path.join(process.cwd(), DocumenterConfig.FILENAME);
Expand All @@ -32,7 +34,9 @@ export class GenerateAction extends BaseAction {
// Otherwise try the standard "config" subfolder
configFilePath = path.join(process.cwd(), 'config', DocumenterConfig.FILENAME);
if (!FileSystem.exists(configFilePath)) {
throw new Error(`Unable to find ${DocumenterConfig.FILENAME} in the current folder or in a "config" subfolder`);
throw new Error(
`Unable to find ${DocumenterConfig.FILENAME} in the current folder or in a "config" subfolder`
);
}
}

Expand All @@ -44,7 +48,10 @@ export class GenerateAction extends BaseAction {
const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter(apiModel, documenterConfig);
markdownDocumenter.generateFiles(this.outputFolder);
} else {
const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(apiModel, documenterConfig);
const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(
apiModel,
documenterConfig
);
yamlDocumenter.generateFiles(this.outputFolder);
}

Expand Down
8 changes: 5 additions & 3 deletions apps/api-documenter/src/cli/MarkdownAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export class MarkdownAction extends BaseAction {
super({
actionName: 'markdown',
summary: 'Generate documentation as Markdown files (*.md)',
documentation: 'Generates API documentation as a collection of files in'
+ ' Markdown format, suitable for example for publishing on a GitHub site.'
documentation:
'Generates API documentation as a collection of files in' +
' Markdown format, suitable for example for publishing on a GitHub site.',
});
}

protected onExecute(): Promise<void> { // override
protected onExecute(): Promise<void> {
// override
const apiModel: ApiModel = this.buildApiModel();

const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter(apiModel, undefined);
Expand Down
32 changes: 17 additions & 15 deletions apps/api-documenter/src/cli/YamlAction.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import {
CommandLineFlagParameter
} from '@rushstack/ts-command-line';
import { CommandLineFlagParameter } from '@rushstack/ts-command-line';

import { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine';
import { BaseAction } from './BaseAction';
Expand All @@ -20,34 +18,38 @@ export class YamlAction extends BaseAction {
super({
actionName: 'yaml',
summary: 'Generate documentation as universal reference YAML files (*.yml)',
documentation: 'Generates API documentation as a collection of files conforming'
+ ' to the universal reference YAML format, which is used by the docs.microsoft.com'
+ ' pipeline.'
documentation:
'Generates API documentation as a collection of files conforming' +
' to the universal reference YAML format, which is used by the docs.microsoft.com' +
' pipeline.',
});
}

protected onDefineParameters(): void { // override
protected onDefineParameters(): void {
// override
super.onDefineParameters();

this._officeParameter = this.defineFlagParameter({
parameterLongName: '--office',
description: `Enables some additional features specific to Office Add-ins`
description: `Enables some additional features specific to Office Add-ins`,
});
this._newDocfxNamespacesParameter = this.defineFlagParameter({
parameterLongName: '--new-docfx-namespaces',
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.`
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.`,
});
}

protected onExecute(): Promise<void> { // override
protected onExecute(): Promise<void> {
// override
const apiModel: ApiModel = this.buildApiModel();

const yamlDocumenter: YamlDocumenter = this._officeParameter.value
? new OfficeYamlDocumenter(apiModel, this.inputFolder, this._newDocfxNamespacesParameter.value)
: new YamlDocumenter(apiModel, this._newDocfxNamespacesParameter.value);
? new OfficeYamlDocumenter(apiModel, this.inputFolder, this._newDocfxNamespacesParameter.value)
: new YamlDocumenter(apiModel, this._newDocfxNamespacesParameter.value);

yamlDocumenter.generateFiles(this.outputFolder);
return Promise.resolve();
Expand Down
3 changes: 2 additions & 1 deletion apps/api-documenter/src/documenters/DocumenterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export class DocumenterConfig {
* The JSON Schema for API Extractor config file (api-extractor.schema.json).
*/
public static readonly jsonSchema: JsonSchema = JsonSchema.fromFile(
path.join(__dirname, '..', 'schemas', 'api-documenter.schema.json'));
path.join(__dirname, '..', 'schemas', 'api-documenter.schema.json')
);

/**
* The config file name "api-extractor.json".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {
let tocItem: IYamlTocItem;
if (apiItem.kind === ApiItemKind.Namespace && !this.newDocfxNamespaces) {
tocItem = {
name: this._getTocItemName(apiItem)
name: this._getTocItemName(apiItem),
};
} else {
if (this._shouldEmbed(apiItem.kind)) {
Expand All @@ -49,7 +49,7 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {

tocItem = {
name: this._getTocItemName(apiItem),
uid: this._getUid(apiItem)
uid: this._getUid(apiItem),
};

if (apiItem.kind !== ApiItemKind.Package) {
Expand Down Expand Up @@ -98,10 +98,9 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {

// First we attempt to filter by inline tag if provided.
if (apiItem instanceof ApiDocumentedItem) {
const docInlineTag: DocInlineTag | undefined =
categoryInlineTag
? this._findInlineTagByName(categoryInlineTag, apiItem.tsdocComment)
: undefined;
const docInlineTag: DocInlineTag | undefined = categoryInlineTag
? this._findInlineTagByName(categoryInlineTag, apiItem.tsdocComment)
: undefined;

const tagContent: string | undefined =
docInlineTag && docInlineTag.tagContent && docInlineTag.tagContent.trim();
Expand Down Expand Up @@ -134,7 +133,10 @@ export class ExperimentalYamlDocumenter extends YamlDocumenter {

// This is a direct copy of a @docCategory inline tag finder in office-ui-fabric-react,
// but is generic enough to be used for any inline tag
private _findInlineTagByName(tagName: string, docComment: DocComment | undefined): DocInlineTag | undefined {
private _findInlineTagByName(
tagName: string,
docComment: DocComment | undefined
): DocInlineTag | undefined {
const tagNameToCheck: string = `@${tagName}`;

if (docComment instanceof DocInlineTag) {
Expand Down
Loading

0 comments on commit e7e9429

Please sign in to comment.