Documentation
Docs should be written during development and accompany PRs when relevant. There are multiple types of documentation, and different places to add each.
User-facing features are documented in Markdown under docs/ and published to elastic.co/docs via the Elastic Docs v3 system. Authoring and syntax guidance lives in the contributor docs, and the tooling itself is documented at elastic.github.io/docs-builder.
To preview docs locally, install docs-builder and run it from the Kibana repo root.
Install:
curl -sL https://ela.st/docs-builder-install | sh
Run a one-off build to surface warnings and errors:
docs-builder
Start a live-preview server at http://localhost:3000:
docs-builder serve
REST APIs are documented via OpenAPI Spec (OAS) generated directly from the route registration code. Define your route schemas with @kbn/config-schema or @kbn/zod, and the generated OAS will flow through scripts/capture_oas_snapshot.js into the published bundles at elastic.co/docs/api/doc/kibana (ESS) and elastic.co/docs/api/doc/serverless (Serverless).
Start here:
- Generating OAS for HTTP APIs — how to register routes, attach schemas and examples, capture the OAS snapshot, and get your path included in the published bundle.
- Guidelines for HTTP API design in Kibana — schema patterns that produce clean OAS, plus documentation, security, and versioning requirements for public APIs.
Developer documentation can be segmented into two types: internal plugin details, and information on extending Kibana. This guide is meant to serve the latter.
Internal plugin details can be kept alongside the code it describes. Information about extending Kibana may go in the root of your plugin or package folder.
The high-level developer documentation located in the docs/extend folder attempts to follow divio documentation guidance. Getting started and Key concepts sections are explanation oriented, while Tutorials falls under both tutorials and how to.
Developers may choose to keep information that is specific to a particular plugin or package alongside the code.
A fresh pair of eyes are invaluable. Recruit new hires to read, review and update documentation. Leads should also periodically review documentation to ensure it stays up to date. File issues any time you notice documentation is outdated.
Documentation in the Kibana Developer Guide is targeted towards developers building Kibana plugins. Keep implementation details about internal plugin code out of these docs.
When a developer first lands in our docs, think about their journey. Introduce basic concepts before diving into details. The left navigation should be set up so documents on top are higher level than documents near the bottom.
It's easy to forget what it felt like to first write code in Kibana, but do your best to frame these docs "outside-in". Don't use esoteric, internal language unless a definition is documented and linked. The fresh eyes of a new hire can be a great asset.
Every function, class, interface, type, parameter and property that is exposed to other plugins should have a TSDoc-style comment.
- Use
@paramtags for every function parameter. - Use
@returnstags for return types. - Use
@throwswhen appropriate. - Use
@betaor@deprecatedwhen appropriate. - Use
@removeBy {version}on@deprecatedAPIs. The version should be the last version the API will work in. For example,@removeBy 7.15means the API will be removed in 7.16. This lets us avoid mid-release cycle coordination. The API can be removed as soon as the 7.15 branch is cut. - Use
@internalto indicate this API item is intended for internal use only, which will also remove it from the docs.
Prefer types and interfaces over complex inline objects. For example, prefer:
/**
* The SearchSpec interface contains settings for creating a new SearchService, like
* username and password.
*/
export interface SearchSpec {
/**
* Stores the username. Duh,
*/
username: string;
/**
* Stores the password. I hope it's encrypted!
*/
password: string;
}
/**
* Retrieve search services
* @param searchSpec Configuration information for initializing the search service.
* @returns the id of the search service
*/
export getSearchService: (searchSpec: SearchSpec) => string;
over:
/**
* Retrieve search services
* @param searchSpec Configuration information for initializing the search service.
* @returns the id of the search service
*/
export getSearchService: (searchSpec: { username: string; password: string }) => string;
In the former, consumers can navigate to the SearchSpec interface and read the documentation for the username and password properties. In the latter the object is inlined, without comments.
When a publicly exported API item references a private type, consumers cannot import or extend that type. The private type is, by proxy, part of your public API, and as such, should be exported.
Do:
export interface AnInterface { bar: string };
export type foo: string | AnInterface;
Don't:
interface AnInterface { bar: string };
export type foo: string | AnInterface;
Pick and other similarly complex types are of limited help in your IDE, so avoid them on your public API items. Using these semantics internally is fine.
Running Kibana with yarn start --run-examples will include all example plugins. These are tested examples of platform services in use. We strongly encourage anyone providing a platform level service or building block to include a tutorial that links to a tested example plugin. This is better than relying on copied code snippets, which can quickly get out of date.