diff --git a/apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts b/apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts index db47cb5f62b..b56cbc8a1ae 100644 --- a/apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts +++ b/apps/api-documenter/src/cli/ApiDocumenterCommandLine.ts @@ -4,6 +4,7 @@ import { CommandLineParser } from '@microsoft/ts-command-line'; import { MarkdownAction } from './MarkdownAction'; import { YamlAction } from './YamlAction'; +import { GenerateAction } from './GenerateAction'; export class ApiDocumenterCommandLine extends CommandLineParser { constructor() { @@ -22,5 +23,6 @@ export class ApiDocumenterCommandLine extends CommandLineParser { private _populateActions(): void { this.addAction(new MarkdownAction(this)); this.addAction(new YamlAction(this)); + this.addAction(new GenerateAction(this)); } } diff --git a/apps/api-documenter/src/cli/GenerateAction.ts b/apps/api-documenter/src/cli/GenerateAction.ts new file mode 100644 index 00000000000..0a84c4c835b --- /dev/null +++ b/apps/api-documenter/src/cli/GenerateAction.ts @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import * as path from 'path'; + +import { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine'; +import { BaseAction } from './BaseAction'; +import { DocumenterConfig } from '../documenters/DocumenterConfig'; +import { ExperimentalYamlDocumenter } from '../documenters/ExperimentalYamlDocumenter'; +import { IConfigFile } from '../documenters/IConfigFile'; + +import { ApiModel } from '@microsoft/api-extractor-model'; +import { FileSystem } from '@microsoft/node-core-library'; + +export class GenerateAction extends BaseAction { + constructor(parser: ApiDocumenterCommandLine) { + 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.' + }); + } + + protected onExecute(): Promise { // override + // Look for the config file under the current folder + + let configFilePath: string = path.join(process.cwd(), DocumenterConfig.FILENAME); + + // First try the current folder + if (!FileSystem.exists(configFilePath)) { + // 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`); + } + } + + const configFile: IConfigFile = DocumenterConfig.loadFile(configFilePath); + + const apiModel: ApiModel = this.buildApiModel(); + + const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(apiModel, configFile); + yamlDocumenter.generateFiles(this.outputFolder); + return Promise.resolve(); + } +} diff --git a/apps/api-documenter/src/documenters/DocumenterConfig.ts b/apps/api-documenter/src/documenters/DocumenterConfig.ts new file mode 100644 index 00000000000..3f3b326e307 --- /dev/null +++ b/apps/api-documenter/src/documenters/DocumenterConfig.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import * as path from 'path'; +import { JsonSchema, JsonFile } from '@microsoft/node-core-library'; +import { IConfigFile } from './IConfigFile'; + +/** + * Helper for loading the api-documenter.json file format. Later when the schema is more mature, + * this class will be used to represent the validated and normalized configuration, whereas `IConfigFile` + * represents the raw JSON file structure. + */ +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')); + + /** + * The config file name "api-extractor.json". + */ + public static readonly FILENAME: string = 'api-documenter.json'; + + /** + * Load and validate an api-documenter.json file. + */ + public static loadFile(configFilePath: string): IConfigFile { + const configFile: IConfigFile = JsonFile.loadAndValidate(configFilePath, DocumenterConfig.jsonSchema); + + return configFile; + } +} diff --git a/apps/api-documenter/src/documenters/ExperimentalYamlDocumenter.ts b/apps/api-documenter/src/documenters/ExperimentalYamlDocumenter.ts new file mode 100644 index 00000000000..11a0f8d5262 --- /dev/null +++ b/apps/api-documenter/src/documenters/ExperimentalYamlDocumenter.ts @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import { PackageName } from '@microsoft/node-core-library'; +import { DocComment, DocInlineTag } from '@microsoft/tsdoc'; +import { ApiModel, ApiItem, ApiItemKind, ApiDocumentedItem } from '@microsoft/api-extractor-model'; + +import { IConfigFile, IConfigTableOfContents } from './IConfigFile'; +import { IYamlTocItem, IYamlTocFile } from '../yaml/IYamlTocFile'; +import { YamlDocumenter } from './YamlDocumenter'; + +/** + * EXPERIMENTAL - This documenter 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. + */ +export class ExperimentalYamlDocumenter extends YamlDocumenter { + private _config: IConfigTableOfContents; + private _tocPointerMap: { [key: string]: IYamlTocItem }; + private _catchAllPointer: IYamlTocItem; + + public constructor(apiModel: ApiModel, configFile: IConfigFile) { + super(apiModel); + this._config = configFile.tableOfContents!; + + this._tocPointerMap = {}; + + this._generateTocPointersMap(this._config.tocConfig); + } + + /** @override */ + protected buildYamlTocFile(apiItems: ReadonlyArray): IYamlTocFile { + this._buildTocItems2(apiItems); + return this._config.tocConfig; + } + + private _buildTocItems2(apiItems: ReadonlyArray): IYamlTocItem[] { + const tocItems: IYamlTocItem[] = []; + for (const apiItem of apiItems) { + let tocItem: IYamlTocItem; + + if (apiItem.kind === ApiItemKind.Namespace) { + // Namespaces don't have nodes yet + tocItem = { + name: apiItem.displayName + }; + } else { + if (this._shouldEmbed(apiItem.kind)) { + // Don't generate table of contents items for embedded definitions + continue; + } + + if (apiItem.kind === ApiItemKind.Package) { + tocItem = { + name: PackageName.getUnscopedName(apiItem.displayName), + uid: this._getUid(apiItem) + }; + } else { + tocItem = { + name: apiItem.displayName, + uid: this._getUid(apiItem) + }; + // Filtering out the api-items as we build the tocItems array. + if (apiItem instanceof ApiDocumentedItem) { + const docInlineTag: DocInlineTag | undefined = + (this._config && this._config.filterByInlineTag) + ? this._findInlineTagByName(this._config.filterByInlineTag, apiItem.tsdocComment) + : undefined; + + const tagContent: string | undefined = + docInlineTag && docInlineTag.tagContent && docInlineTag.tagContent.trim(); + + if (tagContent && this._tocPointerMap[tagContent]) { + // null assertion used because when pointer map was created we checked for presence of empty `items` array + this._tocPointerMap[tagContent].items!.push(tocItem); + } else { + if (this._catchAllPointer && this._catchAllPointer.items) { + this._catchAllPointer.items.push(tocItem); + } + } + } + + } + } + + tocItems.push(tocItem); + + let children: ReadonlyArray; + if (apiItem.kind === ApiItemKind.Package) { + // Skip over the entry point, since it's not part of the documentation hierarchy + children = apiItem.members[0].members; + } else { + children = apiItem.members; + } + + const childItems: IYamlTocItem[] = this._buildTocItems2(children); + if (childItems.length > 0) { + tocItem.items = childItems; + } + } + return tocItems; + } + + // Parses the tocConfig object to build a pointers map of nodes where we want to sort out the API items + private _generateTocPointersMap(tocConfig: IYamlTocFile | IYamlTocItem): void { + if (tocConfig.items) { + for (const tocItem of tocConfig.items) { + if (tocItem.items && tocItem.items.length > 0) { + this._generateTocPointersMap(tocItem); + } else { + // check for presence of the `catchAllCategory` config option + if (this._config && this._config.catchAllCategory && tocItem.name === this._config.catchAllCategory) { + this._catchAllPointer = tocItem; + } else { + this._tocPointerMap[tocItem.name] = tocItem; + } + } + } + } + } + + // 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 { + if (docComment instanceof DocInlineTag) { + if (docComment.tagName === tagName) { + return docComment; + } + } + if (docComment) { + for (const childNode of docComment.getChildNodes()) { + const result: DocInlineTag | undefined = this._findInlineTagByName(tagName, childNode as DocComment); + if (result !== undefined) { + return result; + } + } + } + return undefined; + } +} diff --git a/apps/api-documenter/src/documenters/IConfigFile.ts b/apps/api-documenter/src/documenters/IConfigFile.ts new file mode 100644 index 00000000000..983a694f775 --- /dev/null +++ b/apps/api-documenter/src/documenters/IConfigFile.ts @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. +// See LICENSE in the project root for license information. + +import { IYamlTocFile } from '../yaml/IYamlTocFile'; + +/** + * Typescript interface describing the config schema for toc.yml file format. + */ +export interface IConfigTableOfContents { + /** + * Represents the tree structure describing the toc.file format. + * Only the nodes that have an empty `items` array will be filled with API items + * that are matched with the filters provided. Everything else will be placed under a catchAll category + * that is highly recommended to be provided. + */ + tocConfig: IYamlTocFile; + + /** + * Optional category name that is recommended to include in the `tocConfig`, + * along with one of the filters: `filterByApiItemName` or `filterByInlineTag`. + * Any items that are not matched to the mentioned filters will be placed under this + * catchAll category. If none provided the items will not be included in the final toc.yml file. + */ + catchAllCategory?: string; + + /** + * When loading more than one api.json files that might include the same API items, + * toggle either to show duplicates or not. + */ + noDuplicateEntries?: boolean; + + /** + * Toggle either sorting of the API items should be made based on category name presence + * in the API item's name. + */ + filterByApiItemName?: boolean; + + /** + * Filter that can be used to sort the API items according to an inline custom tag + * that is present on them. + */ + filterByInlineTag?: string; +} + +/** + * This interface represents the api-extractor.json file format. + */ +export interface IConfigFile { + /** {@inheritDoc IConfigTableOfContents} */ + tableOfContents?: IConfigTableOfContents; +} diff --git a/apps/api-documenter/src/documenters/YamlDocumenter.ts b/apps/api-documenter/src/documenters/YamlDocumenter.ts index ac25bf71594..a9f052a64a5 100644 --- a/apps/api-documenter/src/documenters/YamlDocumenter.ts +++ b/apps/api-documenter/src/documenters/YamlDocumenter.ts @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. +// tslint:disable:member-ordering + import * as path from 'path'; import yaml = require('js-yaml'); @@ -184,6 +186,15 @@ export class YamlDocumenter { * Write the table of contents */ private _writeTocFile(apiItems: ReadonlyArray): void { + const tocFile: IYamlTocFile = this.buildYamlTocFile(apiItems); + + const tocFilePath: string = path.join(this._outputFolder, 'toc.yml'); + console.log('Writing ' + tocFilePath); + this._writeYamlFile(tocFile, tocFilePath, '', undefined); + } + + /** @virtual */ + protected buildYamlTocFile(apiItems: ReadonlyArray): IYamlTocFile { const tocFile: IYamlTocFile = { items: [ ] }; @@ -192,10 +203,7 @@ export class YamlDocumenter { tocFile.items.push(rootItem); rootItem.items!.push(...this._buildTocItems(apiItems)); - - const tocFilePath: string = path.join(this._outputFolder, 'toc.yml'); - console.log('Writing ' + tocFilePath); - this._writeYamlFile(tocFile, tocFilePath, '', undefined); + return tocFile; } private _buildTocItems(apiItems: ReadonlyArray): IYamlTocItem[] { @@ -245,7 +253,7 @@ export class YamlDocumenter { return tocItems; } - private _shouldEmbed(apiItemKind: ApiItemKind): boolean { + protected _shouldEmbed(apiItemKind: ApiItemKind): boolean { switch (apiItemKind) { case ApiItemKind.Class: case ApiItemKind.Package: @@ -511,7 +519,7 @@ export class YamlDocumenter { * Calculate the DocFX "uid" for the ApiItem * Example: node-core-library.JsonFile.load */ - private _getUid(apiItem: ApiItem): string { + protected _getUid(apiItem: ApiItem): string { let result: string = ''; for (const hierarchyItem of apiItem.getHierarchy()) { diff --git a/apps/api-documenter/src/schemas/api-documenter-template.json b/apps/api-documenter/src/schemas/api-documenter-template.json new file mode 100644 index 00000000000..7e83106ef00 --- /dev/null +++ b/apps/api-documenter/src/schemas/api-documenter-template.json @@ -0,0 +1,60 @@ +/** + * Config file for API Documenter. For more info, please visit: https://api-extractor.com + */ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-documenter.schema.json", + + /** + * Configures how the table of contents is generated. + */ + "tableOfContents": { + /** + * Allows hand-coded items to be injected into the table of contents. + * + * DEFAULT VALUE: (none) + */ + // "items": [ + // { "name": "Example Node", "href": "~/homepage/homepage.md" }, + // { + // "name": "API Reference", + // "items": [ + // { "name": "References" } + // ] + // } + // ], + + /** + * Optional category name that is recommended to include in the `tocConfig`, + * along with one of the filters: `filterByApiItemName` or `filterByInlineTag`. + * Any items that are not matched to the mentioned filters will be placed under this + * catchAll category. If none provided the items will not be included in the final toc.yml file. + * + * DEFAULT VALUE: (none) + */ + // "catchAllCategory": "References", + + /** + * When loading more than one api.json files that might include the same API items, + * toggle either to show duplicates or not. + * + * DEFAULT VALUE: false + */ + // "noDuplicateEntries": true, + + /** + * Toggle either sorting of the API items should be made based on category name presence + * in the API item's name. + * + * DEFAULT VALUE: false + */ + // "filterByApiItemName": false, + + /** + * Filter that can be used to sort the API items according to an inline custom tag + * that is present on them. + * + * DEFAULT VALUE: (none) + */ + // "filterByInlineTag": "@docCategory" + } +} diff --git a/apps/api-documenter/src/schemas/api-documenter.schema.json b/apps/api-documenter/src/schemas/api-documenter.schema.json new file mode 100644 index 00000000000..95e76696cbf --- /dev/null +++ b/apps/api-documenter/src/schemas/api-documenter.schema.json @@ -0,0 +1,18 @@ +{ + "title": "API Documenter Configuration", + "description": "Describes how the API Documenter tool will process a project.", + "type": "object", + "properties": { + "$schema": { + "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.", + "type": "string" + }, + + "tableOfContents": { + "description": "Configures how the table of contents is generated.", + "type": "object", + "additionalProperties": true + }, + }, + "additionalProperties": false +} diff --git a/build-tests/api-documenter-test/build.js b/build-tests/api-documenter-test/build.js index 23a2e94281c..c2bd5b29fd0 100644 --- a/build-tests/api-documenter-test/build.js +++ b/build-tests/api-documenter-test/build.js @@ -26,7 +26,7 @@ if (process.argv.indexOf('--production') >= 0) { // Run the API Documenter command-line executeCommand('node node_modules/@microsoft/api-documenter/lib/start ' - + 'yaml --input-folder etc --output-folder etc/yaml'); + + 'generate --input-folder etc --output-folder etc/yaml'); executeCommand('node node_modules/@microsoft/api-documenter/lib/start ' + 'markdown --input-folder etc --output-folder etc/markdown'); diff --git a/build-tests/api-documenter-test/config/api-documenter.json b/build-tests/api-documenter-test/config/api-documenter.json new file mode 100644 index 00000000000..fba39a2d549 --- /dev/null +++ b/build-tests/api-documenter-test/config/api-documenter.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-documenter.schema.json", + + "tableOfContents": { + "tocConfig": { + "items": [ + { "name": "Test api-documenter", "href": "~/homepage/homepage.md" }, + { + "name": "Test Sample for AD", + "href": "api-documenter-test", + "extended": true, + "items": [ + { + "name": "Classes", + "items": [ + { "name": "DocBaseClass", "items": [] }, + { "name": "DocClass1", "items": [] } + ] + }, + { "name": "References", "items": [] } + ] + } + ] + }, + "catchAllCategory": "References", + "noDuplicateEntries": true, + "filterByApiItemName": false, + "filterByInlineTag": "@docCategory" + } +} diff --git a/build-tests/api-documenter-test/config/api-extractor.json b/build-tests/api-documenter-test/config/api-extractor.json index 2e554d054fb..b1ce0f05a41 100644 --- a/build-tests/api-documenter-test/config/api-extractor.json +++ b/build-tests/api-documenter-test/config/api-extractor.json @@ -16,5 +16,13 @@ "enabled": false }, - "testMode": true + "testMode": true, + + "messages": { + "tsdocMessageReporting": { + "tsdoc-undefined-tag": { + "logLevel": "none" + } + } + } } diff --git a/build-tests/api-documenter-test/etc/api-documenter-test.api.json b/build-tests/api-documenter-test/etc/api-documenter-test.api.json index fa250f4f7f2..272ba683c18 100644 --- a/build-tests/api-documenter-test/etc/api-documenter-test.api.json +++ b/build-tests/api-documenter-test/etc/api-documenter-test.api.json @@ -17,7 +17,7 @@ { "kind": "Class", "canonicalReference": "(DocBaseClass:class)", - "docComment": "/**\n * Example base class\n *\n * @public\n */\n", + "docComment": "/**\n * Example base class\n *\n * {@docCategory DocBaseClass}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -40,7 +40,7 @@ { "kind": "Class", "canonicalReference": "(DocClass1:class)", - "docComment": "/**\n * This is an example class.\n *\n * @remarks\n *\n * These are some remarks.\n *\n * The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `DocClass1` class.\n *\n * @defaultValue\n *\n * a default value for this function\n *\n * @public\n */\n", + "docComment": "/**\n * This is an example class.\n *\n * @remarks\n *\n * These are some remarks.\n *\n * The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `DocClass1` class.\n *\n * @defaultValue\n *\n * a default value for this function\n *\n * {@docCategory DocClass1}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -513,7 +513,7 @@ { "kind": "Enum", "canonicalReference": "(DocEnum:enum)", - "docComment": "/**\n * Docs for DocEnum\n *\n * @public\n */\n", + "docComment": "/**\n * Docs for DocEnum\n *\n * {@docCategory SystemEvent}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -701,7 +701,7 @@ { "kind": "Interface", "canonicalReference": "(IDocInterface1:interface)", - "docComment": "/**\n * @public\n */\n", + "docComment": "/**\n * {@docCategory DocBaseClass}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -754,7 +754,7 @@ { "kind": "Interface", "canonicalReference": "(IDocInterface2:interface)", - "docComment": "/**\n * @public\n */\n", + "docComment": "/**\n * {@docCategory DocBaseClass}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -822,7 +822,7 @@ { "kind": "Interface", "canonicalReference": "(IDocInterface3:interface)", - "docComment": "/**\n * Some less common TypeScript declaration kinds.\n *\n * @public\n */\n", + "docComment": "/**\n * Some less common TypeScript declaration kinds.\n *\n * {@docCategory DocClass1}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -972,7 +972,7 @@ { "kind": "Interface", "canonicalReference": "(IDocInterface4:interface)", - "docComment": "/**\n * Type union in an interface.\n *\n * @public\n */\n", + "docComment": "/**\n * Type union in an interface.\n *\n * {@docCategory DocClass1}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", @@ -1262,7 +1262,7 @@ { "kind": "Class", "canonicalReference": "(SystemEvent:class)", - "docComment": "/**\n * A class used to exposed events.\n *\n * @public\n */\n", + "docComment": "/**\n * A class used to exposed events.\n *\n * {@docCategory SystemEvent}\n *\n * @public\n */\n", "excerptTokens": [ { "kind": "Content", diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docbaseclass.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docbaseclass.md index 359be92d38c..a1d44a28db9 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docbaseclass.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docbaseclass.md @@ -9,5 +9,5 @@ Example base class Signature: ```typescript -export declare class DocBaseClass +export declare class DocBaseClass ``` diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docenum.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docenum.md index c6721a947a4..08ce8f433d3 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docenum.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.docenum.md @@ -9,7 +9,7 @@ Docs for DocEnum Signature: ```typescript -export declare enum DocEnum +export declare enum DocEnum ``` ## Enumeration Members diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface3.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface3.md index 860468d1404..7abd0978cee 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface3.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface3.md @@ -9,5 +9,5 @@ Some less common TypeScript declaration kinds. Signature: ```typescript -export interface IDocInterface3 +export interface IDocInterface3 ``` diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface4.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface4.md index ba20de23b33..c0c1b972b96 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface4.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.idocinterface4.md @@ -9,7 +9,7 @@ Type union in an interface. Signature: ```typescript -export interface IDocInterface4 +export interface IDocInterface4 ``` ## Properties diff --git a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.systemevent.md b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.systemevent.md index 0c3383cf828..c73c20bf510 100644 --- a/build-tests/api-documenter-test/etc/markdown/api-documenter-test.systemevent.md +++ b/build-tests/api-documenter-test/etc/markdown/api-documenter-test.systemevent.md @@ -9,7 +9,7 @@ A class used to exposed events. Signature: ```typescript -export declare class SystemEvent +export declare class SystemEvent ``` ## Methods diff --git a/build-tests/api-documenter-test/etc/yaml/toc.yml b/build-tests/api-documenter-test/etc/yaml/toc.yml index f7a2d25ad08..6c4762ad691 100644 --- a/build-tests/api-documenter-test/etc/yaml/toc.yml +++ b/build-tests/api-documenter-test/etc/yaml/toc.yml @@ -1,28 +1,33 @@ items: - - name: SharePoint Framework reference - href: ~/overview/sharepoint.md + - name: Test api-documenter + href: ~/homepage/homepage.md + - name: Test Sample for AD + href: api-documenter-test + extended: true items: - - name: api-documenter-test - uid: api-documenter-test + - name: Classes items: - name: DocBaseClass - uid: api-documenter-test.DocBaseClass + items: + - name: DocBaseClass + uid: api-documenter-test.DocBaseClass + - name: IDocInterface1 + uid: api-documenter-test.IDocInterface1 + - name: IDocInterface2 + uid: api-documenter-test.IDocInterface2 - name: DocClass1 - uid: api-documenter-test.DocClass1 + items: + - name: DocClass1 + uid: api-documenter-test.DocClass1 + - name: IDocInterface3 + uid: api-documenter-test.IDocInterface3 + - name: IDocInterface4 + uid: api-documenter-test.IDocInterface4 + - name: References + items: - name: DocEnum uid: api-documenter-test.DocEnum - name: Generic uid: api-documenter-test.Generic - - name: IDocInterface1 - uid: api-documenter-test.IDocInterface1 - - name: IDocInterface2 - uid: api-documenter-test.IDocInterface2 - - name: IDocInterface3 - uid: api-documenter-test.IDocInterface3 - - name: IDocInterface4 - uid: api-documenter-test.IDocInterface4 - - name: OuterNamespace - items: - - name: InnerNamespace - name: SystemEvent uid: api-documenter-test.SystemEvent diff --git a/build-tests/api-documenter-test/src/DocClass1.ts b/build-tests/api-documenter-test/src/DocClass1.ts index 3e8e00858ec..a608f7dbd58 100644 --- a/build-tests/api-documenter-test/src/DocClass1.ts +++ b/build-tests/api-documenter-test/src/DocClass1.ts @@ -2,6 +2,7 @@ /** * A class used to exposed events. * @public + * {@docCategory SystemEvent} */ export class SystemEvent { /** @@ -14,12 +15,14 @@ export class SystemEvent { /** * Example base class * @public + * {@docCategory DocBaseClass} */ export class DocBaseClass { } /** * @public + * {@docCategory DocBaseClass} */ export interface IDocInterface1 { /** @@ -30,6 +33,7 @@ export interface IDocInterface1 { /** * @public + * {@docCategory DocBaseClass} */ export interface IDocInterface2 extends IDocInterface1 { /** @@ -41,6 +45,7 @@ export interface IDocInterface2 extends IDocInterface1 { /** * Some less common TypeScript declaration kinds. * @public + * {@docCategory DocClass1} */ export interface IDocInterface3 { /** @@ -70,6 +75,7 @@ export class Generic { } /** * Type union in an interface. * @public + * {@docCategory DocClass1} */ export interface IDocInterface4 { /** @@ -99,6 +105,7 @@ export interface IDocInterface4 { * These are some remarks. * @defaultValue a default value for this function * @public + * {@docCategory DocClass1} */ export class DocClass1 extends DocBaseClass implements IDocInterface1, IDocInterface2 { /** diff --git a/build-tests/api-documenter-test/src/DocEnums.ts b/build-tests/api-documenter-test/src/DocEnums.ts index a60df6d230d..7428c569f15 100644 --- a/build-tests/api-documenter-test/src/DocEnums.ts +++ b/build-tests/api-documenter-test/src/DocEnums.ts @@ -4,6 +4,7 @@ /** * Docs for DocEnum * @public + * {@docCategory SystemEvent} */ export enum DocEnum { /** diff --git a/common/changes/@microsoft/api-documenter/FabricDocumenter_2019-05-06-23-48.json b/common/changes/@microsoft/api-documenter/FabricDocumenter_2019-05-06-23-48.json new file mode 100644 index 00000000000..d9dcbd72d9d --- /dev/null +++ b/common/changes/@microsoft/api-documenter/FabricDocumenter_2019-05-06-23-48.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@microsoft/api-documenter", + "comment": "Add optional config file `api-documenter.json` to allow building custom Table of Contents for YamlDocumenter.", + "type": "minor" + } + ], + "packageName": "@microsoft/api-documenter", + "email": "vibraga@microsoft.com" +} \ No newline at end of file