Skip to content
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

Generate core API docs from TSDoc comments #32148

Merged
merged 46 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a3c0b59
Generate core API docs from TSDoc comments
rudolf Feb 27, 2019
ee431ce
Flesh out API docs a little bit
rudolf Feb 28, 2019
70e25d7
Ignore snake_case check for api-extractor.json
rudolf Feb 28, 2019
8bcc4a2
Ignore api-extractor's review file from pre-commit check
rudolf Feb 28, 2019
4cc5f34
Try to fix build failing by using masters yarn.lock
rudolf Mar 1, 2019
9926ab4
I'm being stupid
rudolf Mar 1, 2019
8a0db42
Found a better home for ignoring common/core_api_review/kibana.api.ts
rudolf Mar 1, 2019
57f56a3
Node script for detecting core API changes
rudolf Mar 1, 2019
a286fca
Fix tslint precommit hook ignore condition
rudolf Mar 4, 2019
5d536cd
Write tsdoc-metadata.json into ./build
rudolf Mar 4, 2019
02cc3ee
Add LogMeta and ElasticSearch to exported types & docs
rudolf Mar 5, 2019
3e26615
Merge branch 'master' into rm-core-api-docs
rudolf Mar 5, 2019
c343f80
Suppress logging when running api-extractor from script
rudolf Mar 5, 2019
720c729
Improve check_core_api_changes script and run as test
rudolf Mar 6, 2019
c7f45a9
Inline api-extractor.json config
rudolf Mar 6, 2019
d45d289
Merge branch 'master' into rm-core-api-docs
rudolf Mar 6, 2019
20384da
Fix check_core_api_changes --help flag
rudolf Mar 7, 2019
1797e1e
LogMeta TSDoc comments
rudolf Mar 7, 2019
dcefd8d
check_core_api_changes: fail if api-extractor produces warnings or er…
rudolf Mar 7, 2019
a738bc9
Merge branch 'master' into rm-core-api-docs
rudolf Mar 10, 2019
e397c9a
Move ignored ts files list into dev/file
rudolf Mar 10, 2019
f19380a
Merge branch 'master' into rm-core-api-docs
rudolf Mar 12, 2019
e73167d
Merge branch 'master' into rm-core-api-docs
rudolf Mar 19, 2019
a487c16
Add back build:types since api-exporter cannot operate on source files
rudolf Mar 19, 2019
77f0cb0
Upgrade api-exporter/documenter
rudolf Mar 21, 2019
2352343
api-extractor: independantly analyze core/public and core/server
rudolf Mar 21, 2019
969e2e3
Build types as part of build task
rudolf Mar 22, 2019
cb5ff8f
Include types in typescript browser compilation
rudolf Mar 22, 2019
0ad507e
Force inclusion of core/public for building types
rudolf Mar 22, 2019
9490881
Merge remote-tracking branch 'upstream/master' into rm-core-api-docs
rudolf Mar 22, 2019
5f6c583
Fix api review filename in api-exporter errors
rudolf Mar 22, 2019
463d13c
Update docs and API review files
rudolf Mar 22, 2019
d3665d8
Fix api-extractor warnings
rudolf Mar 22, 2019
0e15328
Merge branch 'master' into rm-core-api-docs
rudolf Mar 26, 2019
3df7d6b
chore(NA): merge and solve conflicts with last master.
mistic Mar 29, 2019
304e533
Remove ts file ignored list since it's no longer necessary
rudolf Mar 29, 2019
51b8bc1
Rename exported api package name
rudolf Mar 29, 2019
e6660ab
Review comments
rudolf Apr 2, 2019
c325a56
Export other missing types
rudolf Apr 2, 2019
21f5abf
Upgrade api-documenter to latest beta
rudolf Apr 2, 2019
c69c601
Export more missing types
rudolf Apr 2, 2019
74bc082
Fix warnings and add api-exporter to Jenkins tests
rudolf Apr 2, 2019
979c57a
Merge remote-tracking branch 'upstream/master' into rm-core-api-docs
rudolf Apr 3, 2019
0615c25
Correctly handle runBuildTypes() exceptions
rudolf Apr 3, 2019
f64751c
Fix another swallowed exception
rudolf Apr 3, 2019
cfcfb4e
Fix api-extractor warnings after master merge
rudolf Apr 3, 2019
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
72 changes: 72 additions & 0 deletions common/core_api_review/kibana.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// @public
rudolf marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorta conflicted on the choice to put this in the "common" directory at the root of the repository. I'm not sure why this directory exists in the first place, but could you help me understand why this placement makes sense?

I'm conflicted because I can't really think of a better place to put it, though I feel like we might be able to come up with something a little more self explanatory than "common".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't really like "common" either, it doesn't mean anything to me or describe to me what's inside of this folder. The common directory is the convention used by api-generator and Microsoft uses that convention in most of their projects. The graphql introspection files seem to follow the same convention, so I thought I'll stick to that in the absence of any better ideas.

We don't want to put this in /src cause it is a generated file, not a source file. We don't want it in /build cause it needs to get commited so that we can compare changes to the api signature. We could potentially put this is /dev or create a more descriptive top-level directory like api_signature which could also be the home for the GraphQL introspection files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps, we have one precedent in the repo today for committing a generated file, and that is under a dist directory at the root of that package: https:/elastic/kibana/tree/master/packages/kbn-pm/dist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api-extractor now creates a .md file so it's safe to put the API review file with the source code, so I've moved the review file into the /public /server directories.

interface CallAPIOptions {
wrap401Errors: boolean;
}

// @public
declare class ClusterClient {
// (undocumented)
constructor(config: ElasticsearchClientConfig, log: Logger);
spalger marked this conversation as resolved.
Show resolved Hide resolved
asScoped(req?: {
// (undocumented)
headers?: Headers;
}): ScopedClusterClient;
callAsInternalUser: (endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any>;
close(): void;
}

// @public
interface Logger {
debug(message: string, meta?: LogMeta): void;
error(errorOrMessage: string | Error, meta?: LogMeta): void;
fatal(errorOrMessage: string | Error, meta?: LogMeta): void;
info(message: string, meta?: LogMeta): void;
trace(message: string, meta?: LogMeta): void;
warn(errorOrMessage: string | Error, meta?: LogMeta): void;
}

// @public
interface LoggerFactory {
get(...contextParts: string[]): Logger;
}

// @public
interface LogMeta {
// (undocumented)
[key: string]: any;
}

// @public
interface PluginInitializerContext {
// (undocumented)
config: {
// (undocumented)
create: <Schema extends Type<any>, Config>(ConfigClass: ConfigWithSchema<Schema, Config>) => Observable<Config>;
// (undocumented)
createIfExists: <Schema extends Type<any>, Config>(ConfigClass: ConfigWithSchema<Schema, Config>) => Observable<Config | undefined>;
};
// (undocumented)
env: {
// (undocumented)
mode: EnvironmentMode;
};
// (undocumented)
logger: LoggerFactory;
}

// @public
declare type PluginName = string;

// @public
interface PluginStartContext {
// (undocumented)
elasticsearch: {
// (undocumented)
adminClient$: Observable<ClusterClient>;
// (undocumented)
dataClient$: Observable<ClusterClient>;
};
}


// (No @packageDocumentation comment for this package)
18 changes: 18 additions & 0 deletions docs/development/core/api/kibana.callapioptions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [CallAPIOptions](./kibana.callapioptions.md)

## CallAPIOptions interface

The set of options that defines how API call should be made and result be processed.

<b>Signature:</b>

```typescript
export interface CallAPIOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [wrap401Errors](./kibana.callapioptions.wrap401errors.md) | `boolean` | Indicates whether `401 Unauthorized` errors returned from the Elasticsearch API should be wrapped into `Boom` error instances with properly set `WWW-Authenticate` header that could have been returned by the API itself. If API didn't specify that then `Basic realm="Authorization Required"` is used as `WWW-Authenticate`<!-- -->. |

11 changes: 11 additions & 0 deletions docs/development/core/api/kibana.callapioptions.wrap401errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [CallAPIOptions](./kibana.callapioptions.md) &gt; [wrap401Errors](./kibana.callapioptions.wrap401errors.md)

## CallAPIOptions.wrap401Errors property

Indicates whether `401 Unauthorized` errors returned from the Elasticsearch API should be wrapped into `Boom` error instances with properly set `WWW-Authenticate` header that could have been returned by the API itself. If API didn't specify that then `Basic realm="Authorization Required"` is used as `WWW-Authenticate`<!-- -->.

<b>Signature:</b>

```typescript
wrap401Errors: boolean;
```
24 changes: 24 additions & 0 deletions docs/development/core/api/kibana.clusterclient.asscoped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [ClusterClient](./kibana.clusterclient.md) &gt; [asScoped](./kibana.clusterclient.asscoped.md)

## ClusterClient.asScoped() method

Creates an instance of `ScopedClusterClient` based on the configuration the current cluster client that exposes additional `callAsCurrentUser` method scoped to the provided . Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed.

<b>Signature:</b>

```typescript
asScoped(req?: {
headers?: Headers;
}): ScopedClusterClient;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| req | `{`<p/>` headers?: Headers;`<p/>` }` | |

<b>Returns:</b>

`ScopedClusterClient`

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [ClusterClient](./kibana.clusterclient.md) &gt; [callAsInternalUser](./kibana.clusterclient.callasinternaluser.md)

## ClusterClient.callAsInternalUser property

Calls specified with provided on behalf of the Kibana internal user.

<b>Signature:</b>

```typescript
callAsInternalUser: (endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any>;
```
15 changes: 15 additions & 0 deletions docs/development/core/api/kibana.clusterclient.close.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [ClusterClient](./kibana.clusterclient.md) &gt; [close](./kibana.clusterclient.close.md)

## ClusterClient.close() method

Closes the cluster client. After that client cannot be used and one should create a new client instance to be able to interact with Elasticsearch API.

<b>Signature:</b>

```typescript
close(): void;
```
<b>Returns:</b>

`void`

25 changes: 25 additions & 0 deletions docs/development/core/api/kibana.clusterclient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [ClusterClient](./kibana.clusterclient.md)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these docs mention an index file that doesn't exist, can we generate one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could create one, but not sure what we would put inside it? Perhaps we can create a symlink that points to ./kibana, then at least you don't click through to a page that doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was actually kinda hoping it would have a table of contents listing the existing docs or something like that. I think it'd be nice to see from a high level what is/isn't documented.


## ClusterClient class

Represents an Elasticsearch cluster API client and allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via `asScoped(...)`<!-- -->).

<b>Signature:</b>

```typescript
export declare class ClusterClient
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [callAsInternalUser](./kibana.clusterclient.callasinternaluser.md) | | `(endpoint: string, clientParams?: Record<string, unknown>, options?: CallAPIOptions | undefined) => Promise<any>` | Calls specified with provided on behalf of the Kibana internal user. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [asScoped(req)](./kibana.clusterclient.asscoped.md) | | Creates an instance of `ScopedClusterClient` based on the configuration the current cluster client that exposes additional `callAsCurrentUser` method scoped to the provided . Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed. |
| [close()](./kibana.clusterclient.close.md) | | Closes the cluster client. After that client cannot be used and one should create a new client instance to be able to interact with Elasticsearch API. |

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.debug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [debug](./kibana.logger.debug.md)

## Logger.debug() method

Log messages useful for debugging and interactive investigation

<b>Signature:</b>

```typescript
debug(message: string, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| message | `string` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [error](./kibana.logger.error.md)

## Logger.error() method

Logs abnormal or unexpected errors or messages that caused a failure in the application flow

<b>Signature:</b>

```typescript
error(errorOrMessage: string | Error, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| errorOrMessage | `string | Error` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.fatal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [fatal](./kibana.logger.fatal.md)

## Logger.fatal() method

Logs abnormal or unexpected errors or messages that caused an unrecoverable failure

<b>Signature:</b>

```typescript
fatal(errorOrMessage: string | Error, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| errorOrMessage | `string | Error` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [info](./kibana.logger.info.md)

## Logger.info() method

Logs messages related to general application flow

<b>Signature:</b>

```typescript
info(message: string, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| message | `string` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md)

## Logger interface

Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins.

<b>Signature:</b>

```typescript
export interface Logger
```

## Methods

| Method | Description |
| --- | --- |
| [debug(message, meta)](./kibana.logger.debug.md) | Log messages useful for debugging and interactive investigation |
| [error(errorOrMessage, meta)](./kibana.logger.error.md) | Logs abnormal or unexpected errors or messages that caused a failure in the application flow |
| [fatal(errorOrMessage, meta)](./kibana.logger.fatal.md) | Logs abnormal or unexpected errors or messages that caused an unrecoverable failure |
| [info(message, meta)](./kibana.logger.info.md) | Logs messages related to general application flow |
| [trace(message, meta)](./kibana.logger.trace.md) | Log messages at the most detailed log level |
| [warn(errorOrMessage, meta)](./kibana.logger.warn.md) | Logs abnormal or unexpected errors or messages |

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.trace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [trace](./kibana.logger.trace.md)

## Logger.trace() method

Log messages at the most detailed log level

<b>Signature:</b>

```typescript
trace(message: string, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| message | `string` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

23 changes: 23 additions & 0 deletions docs/development/core/api/kibana.logger.warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [Logger](./kibana.logger.md) &gt; [warn](./kibana.logger.warn.md)

## Logger.warn() method

Logs abnormal or unexpected errors or messages

<b>Signature:</b>

```typescript
warn(errorOrMessage: string | Error, meta?: LogMeta): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| errorOrMessage | `string | Error` | |
| meta | `LogMeta` | |

<b>Returns:</b>

`void`

22 changes: 22 additions & 0 deletions docs/development/core/api/kibana.loggerfactory.get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [LoggerFactory](./kibana.loggerfactory.md) &gt; [get](./kibana.loggerfactory.get.md)

## LoggerFactory.get() method

Returns a `Logger` instance for the specified context.

<b>Signature:</b>

```typescript
get(...contextParts: string[]): Logger;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| contextParts | `string[]` | |

<b>Returns:</b>

`Logger`

18 changes: 18 additions & 0 deletions docs/development/core/api/kibana.loggerfactory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Home](./index) &gt; [kibana](./kibana.md) &gt; [LoggerFactory](./kibana.loggerfactory.md)

## LoggerFactory interface

The single purpose of `LoggerFactory` interface is to define a way to retrieve a context-based logger instance.

<b>Signature:</b>

```typescript
export interface LoggerFactory
```

## Methods

| Method | Description |
| --- | --- |
| [get(contextParts)](./kibana.loggerfactory.get.md) | Returns a `Logger` instance for the specified context. |

Loading