Automatically generated Api documentation#86232
Automatically generated Api documentation#86232stacey-gammon merged 30 commits intoelastic:masterfrom
Conversation
a5d7318 to
5653c59
Compare
66817ef to
5736ed5
Compare
a88a24d to
13528c0
Compare
8608c87 to
5ac9c3e
Compare
e33a748 to
300e76a
Compare
…on/kibana into 2020-12-02-api-doc-generator
…12-02-api-doc-generator
Small refactor of extractImportReferences
| * 'src/plugin/data/server/file.ts' would return undefined. | ||
| * @param path | ||
| */ | ||
| export function getServiceForPath(path: string): string | undefined { |
There was a problem hiding this comment.
There's a bug with getServiceForPath if we have a path like "src/plugins/embed/server/routes/public/foo/index.ts". There's only one usage of getServiceForPath https://github.com/elastic/kibana/pull/86232/files#diff-d3ce0084b5713e36ab23a452ffe50380efc2b94fda541b83b502ab752b25ecabR47 and the scope is known. Perhaps we should just pass the scope to getServiceForPath and use this to create the regex?
There was a problem hiding this comment.
There are two usages, and the one in getPluginApiDocId doesn't have scope available. I added a test and refactored this. The code that has scope available is just part of that function now, and the other usage passes in the plugin directory.
packages/kbn-docs-utils/src/api_docs/build_api_declarations/utils.ts
Outdated
Show resolved
Hide resolved
…ils.ts Co-authored-by: Spencer <email@spalger.com>
💚 Build Succeeded
Metrics [docs]
History
To update your PR or re-run it, just comment with: |
* auto generated mdx api doc system * Fix README.md * update core api docs after master merge * clean up signature * Update packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts Co-authored-by: Spencer <email@spalger.com> * migrate to docs-util package * Remove bad links * fix ref to release-notes and add extra dats service folder * update name change * Update packages/kbn-docs-utils/src/api_docs/build_api_declarations/get_type_kind.ts Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> * Update packages/kbn-docs-utils/src/api_docs/utils.ts Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> * review updates 1 * review feedback updates round 1 * Small refactor of extractImportReferences * Review feedback updates 2 * Review update 3 plus support for links in class interface heritage clause * debug failing test on ci only * Escape regex directory path * Update packages/kbn-docs-utils/src/api_docs/build_api_declarations/utils.ts Co-authored-by: Spencer <email@spalger.com> * fix for commit suggestion Co-authored-by: Spencer <email@spalger.com> Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> Co-authored-by: kobelb <brandon.kobel@elastic.co>
* auto generated mdx api doc system * Fix README.md * update core api docs after master merge * clean up signature * Update packages/kbn-dev-utils/src/plugins/parse_kibana_platform_plugin.ts Co-authored-by: Spencer <email@spalger.com> * migrate to docs-util package * Remove bad links * fix ref to release-notes and add extra dats service folder * update name change * Update packages/kbn-docs-utils/src/api_docs/build_api_declarations/get_type_kind.ts Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> * Update packages/kbn-docs-utils/src/api_docs/utils.ts Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> * review updates 1 * review feedback updates round 1 * Small refactor of extractImportReferences * Review feedback updates 2 * Review update 3 plus support for links in class interface heritage clause * debug failing test on ci only * Escape regex directory path * Update packages/kbn-docs-utils/src/api_docs/build_api_declarations/utils.ts Co-authored-by: Spencer <email@spalger.com> * fix for commit suggestion Co-authored-by: Spencer <email@spalger.com> Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> Co-authored-by: kobelb <brandon.kobel@elastic.co> Co-authored-by: Spencer <email@spalger.com> Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Brandon Kobel <brandon.kobel@gmail.com> Co-authored-by: kobelb <brandon.kobel@elastic.co>
* master: (38 commits) Fixes Cypress flake by adding pipe, click, and should (elastic#92762) [Discover] Fix filtering selected sidebar fields (elastic#91828) [ML] Fixes positions of calendar arrow buttons in start datafeed modal (elastic#92625) [dev/build_ts_refs] check that commit in outDirs matches mergeBase (elastic#92513) add dep on `@kbn/config` so it is built first [Expressions] [Lens] Add id and copyMetaFrom arg to mapColumn fn + add configurable onError argument to math fn (elastic#90481) [Lens] Fix Workspace hidden when using Safari (elastic#92616) [Lens] Fixes vertical alignment validation messages (elastic#91878) forbid x-elastic-product-origin header in elasticsearch configuration (elastic#92359) [Security Solution][Detections] Set default indicator path to reduce friction with new filebeat modules (elastic#92081) [ILM][Accessibility] Added A11y test for ILM new policy form. (elastic#92570) [Security Solution][Exceptions] - Fixes exceptions builder UI where invalid values can cause overwrites of other values (elastic#90634) Automatically generated Api documentation (elastic#86232) Increase index pattern select limit to 1000 (elastic#92093) [core.logging] Add RewriteAppender for filtering LogMeta. (elastic#91492) [Security Solution][Detection Rules] Update prebuilt rule threats to match schema (elastic#92281) [Security Solutions][Detection Engine] Fixes bug with not being able to duplicate indicator matches (elastic#92565) [Dashboard] Export appropriate references from byValue panels (elastic#91567) [Upgrade Assistant] Align code between branches (elastic#91862) [Security Solution][Case] Fix alerts push (elastic#91638) ...
|
|
||
| [RFC](../../../rfcs/text/0014_api_documentation.md) | ||
|
|
||
| This is an experimental api documentation system that is managed by the Kibana Tech Leads until |
There was a problem hiding this comment.
@stacey-gammon Hi! I realize this is, like, 3 weeks old, but...
Temperate check? How has it been? Any flags so far?
There was a problem hiding this comment.
Hey @goodroot, thanks for asking! It's going well but there are a few issues that I suspect are causing folks to not adopt and use this:
-
Performance. The page may even pop up an error that says "page failed to respond within x seconds". https://github.com/elastic/elastic-docs/issues/274
-
Link scroll positions are off and the section is not auto-expanded. https://github.com/elastic/elastic-docs/issues/262
-
Usage tracking and analytics: https://github.com/elastic/elastic-docs/issues/309. I'll need this to be able to prove whether these API docs are valuable. If they aren't being used much, I can dig into the why.
There was a problem hiding this comment.
Very helpful -- thank you! I am gathering very broad information and will circle back. 🕺
| // Literal types are non primitives that aren't references to other types. We add them as a more | ||
| // defined node, with children. | ||
| // If we don't want the docs to be too deeply nested we could avoid this special handling. | ||
| if (param.getTypeNode() && param.getTypeNode()!.getKind() === SyntaxKind.TypeLiteral) { | ||
| acc.push( | ||
| buildApiDeclaration( | ||
| param.getTypeNode()!, | ||
| plugins, | ||
| log, | ||
| anchorLink.pluginName, | ||
| anchorLink.scope, | ||
| anchorLink.apiName, | ||
| label | ||
| ) | ||
| ); | ||
| } else { | ||
| acc.push({ | ||
| type: getTypeKind(param), | ||
| label, | ||
| isRequired: param.getType().isNullable() === false, | ||
| signature: extractImportReferences(param.getType().getText(), plugins, log), | ||
| description: jsDocs ? getJSDocParamComment(jsDocs, label) : [], | ||
| source: getSourceForNode(param), | ||
| }); | ||
| } | ||
| return acc; | ||
| }, [] as ApiDeclaration[]); | ||
| } |

An automated plugin API documentation system using ts-morph.
This effort is going to be broken into three PRs (of which this is the first):
yarn build:apidocsto see the generated docs. The folder will be ignored in the first iteration (added to.gitignore).This is to make it easier to review.
How to run locally
elastic-docs/config/sources.dev.jsonand add:elastic-docs/config/nav-kibana-dev.ts:Change
to
Note I did not add everything, but enough to get an idea.
yarn build:apidocsyarn jest build_apiyarn start) and navigate to localhost:8000RFC: #86704
blocked on https://github.com/elastic/elastic-docs/pull/224
Tasks
Features:
Bugs:
api_docsfolder if it doesn't exist, or the script will break.api_docsfolder every run so plugins that are deleted will have their docs deleted as well.TODO elastic-docs features: