Skip to content

Commit

Permalink
Merge branch 'main' into feature/security-bulk-add-alerts-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
academo authored May 3, 2022
2 parents 3241cbd + 8a0890e commit 865610a
Show file tree
Hide file tree
Showing 219 changed files with 4,595 additions and 1,996 deletions.
5 changes: 5 additions & 0 deletions dev_docs/getting_started/hello_world_plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ and add the following:
"id": "helloWorld",
"version": "1.0.0",
"kibanaVersion": "kibana",
"owner": {
"name": "Kibana Core",
"githubTeam": "kibana-core"
},
"ui": true
}
```
Expand Down Expand Up @@ -77,6 +81,7 @@ And add the following to it:

```
$ mkdir public
$ cd public
$ touch plugin.tsx
```

Expand Down
2 changes: 1 addition & 1 deletion dev_docs/getting_started/setting_up_a_development_env.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ In another terminal tab/window you can start Kibana.
yarn start
```

If you include the `--run-examples` flag then all of the [developer examples](https://github.com/elastic/kibana/tree/{branch}/examples). Read more about the advanced options for [Running Kibana](https://www.elastic.co/guide/en/kibana/current/running-kibana-advanced.html).
Include developer examples](https://github.com/elastic/kibana/tree/main/examples) by adding an optional `--run-examples` flag. Read more about the advanced options for [Running Kibana](https://www.elastic.co/guide/en/kibana/current/running-kibana-advanced.html).

## Code away!

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@
"handlebars": "4.7.7",
"he": "^1.2.0",
"history": "^4.9.0",
"history-extra": "^5.0.1",
"hjson": "3.2.1",
"http-proxy-agent": "^2.1.0",
"https-proxy-agent": "^5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@ it('Test number primitive doc def', () => {
expect(def.type).toBe(TypeKind.NumberKind);
});

it('Test a constructor type declaration inside an interface', () => {
const node = nodes.find((n) => getNodeName(n) === 'ClassConstructorWithStaticProperties');
expect(node).toBeDefined();
const def = buildApiDeclarationTopNode(node!, {
plugins,
log,
currentPluginId: plugins[0].manifest.id,
scope: ApiScope.CLIENT,
captureReferences: false,
});

expect(def.type).toBe(TypeKind.InterfaceKind);
expect(def.children).toHaveLength(2);
expect(def.children![1].type).toBe(TypeKind.FunctionKind);
expect(def.children![1].label).toBe('new');
expect(def.children![1].id).toBe('def-public.ClassConstructorWithStaticProperties.new');
});

it('Function type is exported as type with signature', () => {
const node = nodes.find((n) => getNodeName(n) === 'FnWithGeneric');
expect(node).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ export function buildApiDeclaration(node: Node, opts: BuildApiDecOpts): ApiDecla
Node.isMethodSignature(node) ||
Node.isFunctionDeclaration(node) ||
Node.isMethodDeclaration(node) ||
Node.isConstructSignatureDeclaration(node) ||
Node.isConstructorDeclaration(node)
) {
return buildFunctionDec(node, {
...opts,
// Use "Constructor" if applicable, instead of the default "Unnamed"
name: Node.isConstructorDeclaration(node) ? 'Constructor' : node.getName() || 'Unnamed',
name: Node.isConstructSignatureDeclaration(node)
? 'new'
: Node.isConstructorDeclaration(node)
? 'Constructor'
: node.getName() || 'Unnamed',
});
} else if (
Node.isPropertySignature(node) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
MethodDeclaration,
ConstructorDeclaration,
MethodSignature,
ConstructSignatureDeclaration,
} from 'ts-morph';

import { buildApiDecsForParameters } from './build_parameter_decs';
Expand All @@ -23,7 +24,12 @@ import { BuildApiDecOpts } from './types';
* Takes the various function-like node declaration types and converts them into an ApiDeclaration.
*/
export function buildFunctionDec(
node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature,
node:
| ConstructSignatureDeclaration
| FunctionDeclaration
| MethodDeclaration
| ConstructorDeclaration
| MethodSignature,
opts: BuildApiDecOpts
): ApiDeclaration {
const fn = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export function buildParentApiId(parentName: string, parentsParentApiId?: string
}

export function getOptsForChild(node: Node, parentOpts: BuildApiDecOpts): BuildApiDecOpts {
const name = isNamedNode(node) ? node.getName() : 'Unnamed';
const name = Node.isConstructSignatureDeclaration(node)
? 'new'
: isNamedNode(node)
? node.getName()
: 'Unnamed';
return getOptsForChildWithName(name, parentOpts);
}

Expand Down
15 changes: 10 additions & 5 deletions packages/kbn-docs-utils/src/api_docs/build_api_docs_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,16 @@ export function runBuildApiDocsCli() {
// Delete all files except the README that warns about the auto-generated nature of
// the folder.
const files = Fs.readdirSync(outputFolder);
files.forEach((file) => {
if (file.indexOf('README.md') < 0) {
Fs.rmSync(Path.resolve(outputFolder, file));
}
});
await Promise.all(
files
.filter((file) => file.indexOf('README.md') < 0)
.map(
(file) =>
new Promise<void>((resolve, reject) =>
Fs.rm(Path.resolve(outputFolder, file), (err) => (err ? reject(err) : resolve()))
)
)
);
}
const collectReferences = flags.references as boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ beforeAll(() => {
});

test('foo service has all exports', () => {
expect(doc?.client.length).toBe(37);
expect(doc?.client.length).toBe(38);
const split = splitApisByFolder(doc);
expect(split.length).toBe(2);

Expand All @@ -47,5 +47,5 @@ test('foo service has all exports', () => {

expect(fooDoc?.common.length).toBe(1);
expect(fooDoc?.client.length).toBe(2);
expect(mainDoc?.client.length).toBe(35);
expect(mainDoc?.client.length).toBe(36);
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export interface InterfaceWithIndexSignature {
[key: string]: { foo: string };
}

export interface ClassConstructorWithStaticProperties {
staticProperty1: string;
new (config: { foo: string }): InterfaceWithIndexSignature;
}

export function plugin() {
return new PluginA();
}
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,67 @@
],
"initialIsOpen": false
},
{
"parentPluginId": "pluginA",
"id": "def-public.ClassConstructorWithStaticProperties",
"type": "Interface",
"tags": [],
"label": "ClassConstructorWithStaticProperties",
"description": [],
"path": "packages/kbn-docs-utils/src/api_docs/tests/__fixtures__/src/plugin_a/public/index.ts",
"deprecated": false,
"children": [
{
"parentPluginId": "pluginA",
"id": "def-public.ClassConstructorWithStaticProperties.staticProperty1",
"type": "string",
"tags": [],
"label": "staticProperty1",
"description": [],
"path": "packages/kbn-docs-utils/src/api_docs/tests/__fixtures__/src/plugin_a/public/index.ts",
"deprecated": false
},
{
"parentPluginId": "pluginA",
"id": "def-public.ClassConstructorWithStaticProperties.new",
"type": "Function",
"tags": [],
"label": "new",
"description": [],
"signature": [
"any"
],
"path": "packages/kbn-docs-utils/src/api_docs/tests/__fixtures__/src/plugin_a/public/index.ts",
"deprecated": false,
"children": [
{
"parentPluginId": "pluginA",
"id": "def-public.ClassConstructorWithStaticProperties.new.$1",
"type": "Object",
"tags": [],
"label": "config",
"description": [],
"path": "packages/kbn-docs-utils/src/api_docs/tests/__fixtures__/src/plugin_a/public/index.ts",
"deprecated": false,
"children": [
{
"parentPluginId": "pluginA",
"id": "def-public.ClassConstructorWithStaticProperties.new.$1.foo",
"type": "string",
"tags": [],
"label": "foo",
"description": [],
"path": "packages/kbn-docs-utils/src/api_docs/tests/__fixtures__/src/plugin_a/public/index.ts",
"deprecated": false
}
]
}
],
"returnComment": []
}
],
"initialIsOpen": false
},
{
"parentPluginId": "pluginA",
"id": "def-public.ExampleInterface",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ slug: /kibana-dev-docs/api/pluginA
title: "pluginA"
image: https://source.unsplash.com/400x175/?github
summary: API docs for the pluginA plugin
date: 2022-02-14
date: 2022-04-30
tags: ['contributor', 'dev', 'apidocs', 'kibana', 'pluginA']
warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info.
---
Expand All @@ -18,7 +18,7 @@ Contact Kibana Core for questions regarding this plugin.

| Public API count | Any count | Items lacking comments | Missing exports |
|-------------------|-----------|------------------------|-----------------|
| 131 | 1 | 71 | 2 |
| 136 | 1 | 76 | 2 |

## Client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ slug: /kibana-dev-docs/api/pluginA-foo
title: "pluginA.foo"
image: https://source.unsplash.com/400x175/?github
summary: API docs for the pluginA.foo plugin
date: 2022-02-14
date: 2022-04-30
tags: ['contributor', 'dev', 'apidocs', 'kibana', 'pluginA.foo']
warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info.
---
Expand All @@ -18,7 +18,7 @@ Contact Kibana Core for questions regarding this plugin.

| Public API count | Any count | Items lacking comments | Missing exports |
|-------------------|-----------|------------------------|-----------------|
| 131 | 1 | 71 | 2 |
| 136 | 1 | 76 | 2 |

## Client

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ slug: /kibana-dev-docs/api/pluginB
title: "pluginB"
image: https://source.unsplash.com/400x175/?github
summary: API docs for the pluginB plugin
date: 2022-02-14
date: 2022-04-30
tags: ['contributor', 'dev', 'apidocs', 'kibana', 'pluginB']
warning: This document is auto-generated and is meant to be viewed inside our experimental, new docs system. Reach out in #docs-engineering for more info.
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function annotationLayerConfigFunction(): ExpressionFunctionDefinition<
help: 'Show details',
},
annotations: {
types: ['manual_event_annotation'],
types: ['manual_point_event_annotation', 'manual_range_event_annotation'],
help: '',
multi: true,
},
Expand Down
Loading

0 comments on commit 865610a

Please sign in to comment.