-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Automatically generated Api documentation #86232
Automatically generated Api documentation #86232
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
packages/kbn-docs-utils/src/api_docs/build_api_declarations/utils.ts
Outdated
Show resolved
Hide resolved
…ils.ts Co-authored-by: Spencer <[email protected]>
💚 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 protected]> * 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 <[email protected]> * Update packages/kbn-docs-utils/src/api_docs/utils.ts Co-authored-by: Brandon Kobel <[email protected]> * 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 protected]> * fix for commit suggestion Co-authored-by: Spencer <[email protected]> Co-authored-by: spalger <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Brandon Kobel <[email protected]> Co-authored-by: kobelb <[email protected]>
* 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 protected]> * 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 <[email protected]> * Update packages/kbn-docs-utils/src/api_docs/utils.ts Co-authored-by: Brandon Kobel <[email protected]> * 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 protected]> * fix for commit suggestion Co-authored-by: Spencer <[email protected]> Co-authored-by: spalger <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Brandon Kobel <[email protected]> Co-authored-by: kobelb <[email protected]> Co-authored-by: Spencer <[email protected]> Co-authored-by: spalger <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Brandon Kobel <[email protected]> Co-authored-by: kobelb <[email protected]>
* 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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[]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goodroot FYI for future.
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:apidocs
to 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.json
and add:elastic-docs/config/nav-kibana-dev.ts
:Change
to
Note I did not add everything, but enough to get an idea.
yarn build:apidocs
yarn jest build_api
yarn start
) and navigate to localhost:8000RFC: #86704
blocked on https://github.com/elastic/elastic-docs/pull/224
Tasks
Features:
Bugs:
api_docs
folder if it doesn't exist, or the script will break.api_docs
folder every run so plugins that are deleted will have their docs deleted as well.TODO elastic-docs features: