Skip to content

[api-documenter] Add support for deeply linked types #1326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
322 changes: 267 additions & 55 deletions apps/api-documenter/src/documenters/YamlDocumenter.ts

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions apps/api-documenter/src/yaml/IYamlApiFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@ export interface IYamlParameter {
* declared in a separate YAML file.
*/
export interface IYamlReference {
uid?: string;
name?: string;
'name.typeScript'?: string;
'fullName.typeScript'?: string;
'spec.typeScript'?: IYamlReferenceSpec[];
}

/**
* Part of the IYamlApiFile structure. Represents a text specification for a reference.
*/
export interface IYamlReferenceSpec {
uid?: string;
name?: string;
fullName?: string;
}

/**
Expand Down
27 changes: 27 additions & 0 deletions apps/api-documenter/src/yaml/typescript.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,38 @@
"type": "object",
"additionalProperties": false,
"properties": {
"uid": {
"type": "string"
},
"name": {
"type": "string"
},
"name.typeScript": {
"type": "string"
},
"fullName.typeScript": {
"type": "string"
},
"spec.typeScript": {
"type": "array",
"items": {
"$ref": "#/definitions/spec"
}
}
}
},
"spec": {
"type": "object",
"additionalProperties": false,
"properties": {
"uid": {
"type": "string"
},
"name": {
"type": "string"
},
"fullName": {
"type": "string"
}
}
},
Expand Down
261 changes: 261 additions & 0 deletions build-tests/api-documenter-test/etc/api-documenter-test.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,144 @@
"releaseTag": "Public",
"name": "IDocInterface6",
"members": [
{
"kind": "MethodSignature",
"canonicalReference": "(genericReferenceMethod:0)",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "genericReferenceMethod"
},
{
"kind": "Content",
"text": "<"
},
{
"kind": "Reference",
"text": "T"
},
{
"kind": "Content",
"text": ">("
},
{
"kind": "Reference",
"text": "x"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Reference",
"text": "T"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Reference",
"text": "T"
},
{
"kind": "Content",
"text": ";"
}
],
"returnTypeTokenRange": {
"startIndex": 8,
"endIndex": 9
},
"releaseTag": "Public",
"overloadIndex": 0,
"parameters": [
{
"parameterName": "x",
"parameterTypeTokenRange": {
"startIndex": 6,
"endIndex": 7
}
}
],
"typeParameters": [
{
"typeParameterName": "T"
}
],
"name": "genericReferenceMethod"
},
{
"kind": "PropertySignature",
"canonicalReference": "arrayProperty",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "arrayProperty"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Reference",
"text": "IDocInterface1"
},
{
"kind": "Content",
"text": "[]"
},
{
"kind": "Content",
"text": ";"
}
],
"releaseTag": "Public",
"name": "arrayProperty",
"propertyTypeTokenRange": {
"startIndex": 2,
"endIndex": 4
}
},
{
"kind": "PropertySignature",
"canonicalReference": "intersectionProperty",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "intersectionProperty"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Reference",
"text": "IDocInterface1"
},
{
"kind": "Content",
"text": " & "
},
{
"kind": "Reference",
"text": "IDocInterface2"
},
{
"kind": "Content",
"text": ";"
}
],
"releaseTag": "Public",
"name": "intersectionProperty",
"propertyTypeTokenRange": {
"startIndex": 2,
"endIndex": 5
}
},
{
"kind": "PropertySignature",
"canonicalReference": "regularProperty",
Expand Down Expand Up @@ -1297,6 +1435,129 @@
"startIndex": 2,
"endIndex": 3
}
},
{
"kind": "PropertySignature",
"canonicalReference": "tupleProperty",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "tupleProperty"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Content",
"text": "["
},
{
"kind": "Reference",
"text": "IDocInterface1"
},
{
"kind": "Content",
"text": ", "
},
{
"kind": "Reference",
"text": "IDocInterface2"
},
{
"kind": "Content",
"text": "]"
},
{
"kind": "Content",
"text": ";"
}
],
"releaseTag": "Public",
"name": "tupleProperty",
"propertyTypeTokenRange": {
"startIndex": 2,
"endIndex": 7
}
},
{
"kind": "PropertySignature",
"canonicalReference": "typeReferenceProperty",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "typeReferenceProperty"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Reference",
"text": "Generic"
},
{
"kind": "Content",
"text": "<"
},
{
"kind": "Reference",
"text": "IDocInterface1"
},
{
"kind": "Content",
"text": ">"
},
{
"kind": "Content",
"text": ";"
}
],
"releaseTag": "Public",
"name": "typeReferenceProperty",
"propertyTypeTokenRange": {
"startIndex": 2,
"endIndex": 6
}
},
{
"kind": "PropertySignature",
"canonicalReference": "unionProperty",
"docComment": "",
"excerptTokens": [
{
"kind": "Reference",
"text": "unionProperty"
},
{
"kind": "Content",
"text": ": "
},
{
"kind": "Reference",
"text": "IDocInterface1"
},
{
"kind": "Content",
"text": " | "
},
{
"kind": "Reference",
"text": "IDocInterface2"
},
{
"kind": "Content",
"text": ";"
}
],
"releaseTag": "Public",
"name": "unionProperty",
"propertyTypeTokenRange": {
"startIndex": 2,
"endIndex": 5
}
}
],
"extendsTokenRanges": []
Expand Down
16 changes: 16 additions & 0 deletions build-tests/api-documenter-test/etc/api-documenter-test.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ export interface IDocInterface6 {
regularProperty: number;
}

// @public
export interface IDocInterface6 {
// (undocumented)
arrayProperty: IDocInterface1[];
// (undocumented)
genericReferenceMethod<T>(x: T): T;
// (undocumented)
intersectionProperty: IDocInterface1 & IDocInterface2;
// (undocumented)
tupleProperty: [IDocInterface1, IDocInterface2];
// (undocumented)
typeReferenceProperty: Generic<IDocInterface1>;
// (undocumented)
unionProperty: IDocInterface1 | IDocInterface2;
}

// @public
export namespace OuterNamespace {
export namespace InnerNamespace {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [api-documenter-test](./api-documenter-test.md) &gt; [IDocInterface6](./api-documenter-test.idocinterface6.md) &gt; [arrayProperty](./api-documenter-test.idocinterface6.arrayproperty.md)

## IDocInterface6.arrayProperty property

<b>Signature:</b>

```typescript
arrayProperty: IDocInterface1[];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [api-documenter-test](./api-documenter-test.md) &gt; [IDocInterface6](./api-documenter-test.idocinterface6.md) &gt; [genericReferenceMethod](./api-documenter-test.idocinterface6.genericreferencemethod.md)

## IDocInterface6.genericReferenceMethod() method

<b>Signature:</b>

```typescript
genericReferenceMethod<T>(x: T): T;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| x | <code>T</code> | |

<b>Returns:</b>

`T`

Loading