Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
config Update config files to use new schema Apr 11, 2019
src Fix more API Extractor warnings Apr 3, 2019
.npmignore Set up new project @microsoft/api-extractor-model Mar 10, 2019
CHANGELOG.json Deleting change files and updating change logs for package updates. Apr 16, 2019
CHANGELOG.md Deleting change files and updating change logs for package updates. Apr 16, 2019
LICENSE
README.md
gulpfile.js Set up new project @microsoft/api-extractor-model Mar 10, 2019
package.json Applying package updates. Apr 16, 2019
tsconfig.json Set up new project @microsoft/api-extractor-model Mar 10, 2019
tslint.json Set up new project @microsoft/api-extractor-model Mar 10, 2019

README.md

@microsoft/api-extractor-model

This library is used with the @microsoft/api-extractor. For documentation and other information about the API Extractor tool, please visit the web site.

The @microsoft/api-extractor-model library is used to read and write the *.api.json data file format, which stores information about the exported API signatures for a TypeScript project.

Example Usage

The following code sample shows how to load example.api.json, which would be generated by API Extractor when it analyzes a hypothetical NPM package called example:

import { ApiModel, ApiPackage } from '@microsoft/api-extractor-model';

const apiModel: ApiModel = new ApiModel();
const apiPackage: ApiPackage = apiModel.loadPackage('example.api.json');

for (const member of apiPackage.members) {
  console.log(member.displayName);
}

The ApiModel is acts as a container for various packages that are loaded and operated on as a group. For example, a documentation tool may need to resolve @link references across different packages. In this case we would load the various packages into the ApiModel, and then use the ApiModel.resolveDeclarationReference() to resolve the @link targets.

The data structure forms a tree of various classes that start with the Api prefix. The nesting hierarchy might look like this:

- ApiModel
  - ApiPackage
    - ApiEntryPoint
      - ApiClass
        - ApiMethod
        - ApiProperty
      - ApiEnum
        - ApiEnumMember
      - ApiInterface
        - ApiMethodSignature
        - ApiPropertySignature
      - ApiNamespace
        - (ApiClass, ApiEnum, ApiInterace, ...)

You can use the ApiItem.members property to traverse this tree.

Note that the non-abstract classes (e.g. ApiClass, ApiEnum, ApiInterface, etc.) use TypeScript "mixin" functions (e.g. ApiDeclaredItem, ApiItemContainerMixin, etc.) to add various features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components: the function that generates a subclass, an interface that describes the members of the subclass, and a namespace containing static members of the class.

For a complete example that shows how to uset these APIs to generate an API reference web site, see the @microsoft/api-documenter source code.

You can’t perform that action at this time.