[Canvas] Adds function reference docs generator#49402
[Canvas] Adds function reference docs generator#49402cqliu1 merged 20 commits intoelastic:masterfrom
Conversation
0609fc7 to
c256ab7
Compare
💚 Build Succeeded
|
c256ab7 to
41d8e23
Compare
1e54f15 to
59e3215
Compare
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
💔 Build Failed
|
fc1dcd5 to
b58b9eb
Compare
💔 Build Failed
|
1ddbd5a to
9add681
Compare
💔 Build Failed
|
💔 Build Failed
|
e5f6d12 to
b98f061
Compare
💔 Build Failed
|
💔 Build Failed
|
042377d to
f393201
Compare
💔 Build Failed
|
lukeelmers
left a comment
There was a problem hiding this comment.
@cqliu1 I know this is just in draft state, but I'll leave a few notes as a follow up from our offline conversations last week. If you are looking for a final review once this is out of draft, feel free to request me and I'd be happy to run it locally and test it out.
Overall I don't think it matters exactly how this is implemented right now, since the only use for these is Canvas autocomplete. If we were to officially expose this example data as part of the larger public expressions service, I'd want to think more about whether the function definition is the right place to introduce arbitrary metadata like this.
Functionally, this metadata exists solely for the purposes of displaying content in the UI... it doesn't have anything to do with how the function is handled by the interpreter. So on the one hand, I like the idea of trying to separate these concerns. But on the other hand, I don't know that a separate "examples registry" or whatever is the most elegant way to go about this longer term; this is something we'd need to explore further if we see more and more use cases like this popping up.
For the time being, I have no major concerns on my end as long as we are clearly marking this portion of the interface as "internal" and for use in Canvas only... that way we have flexibility to change things up later if needed.
cc @ppisljar I think this is in line with what we discussed too, feel free to add anything I've missed.
x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/join_rows.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/canvas/public/components/help_menu/help_menu.js
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/if.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/canvas/public/components/help_menu/function_reference_generator.tsx
Outdated
Show resolved
Hide resolved
f393201 to
3261b2c
Compare
💔 Build Failed
|
ffe344e to
c70fe29
Compare
poffdeluxe
left a comment
There was a problem hiding this comment.
overall stuff looks good -- I did find an issue with that str.contains stuff though and I have a few nits. Also, a functional test would be great if possible
...ugins/canvas/public/components/function_reference_generator/function_reference_generator.tsx
Outdated
Show resolved
Hide resolved
| ${createFunctionDocs(functionDictionary)}`; | ||
| }; | ||
|
|
||
| const createAlphabetLinks = (functionDictionary: FunctionDictionary) => { |
There was a problem hiding this comment.
nit: might make sense to put all these helper funcs into a lib or something somewhere. Feels a bit big for a component file
There was a problem hiding this comment.
I extract all the doc related functions into a separate file in the same component folder.
...ugins/canvas/public/components/function_reference_generator/function_reference_generator.tsx
Outdated
Show resolved
Hide resolved
Move FunctionGenerator component to lazy loaded bundle
…nto docs/function-ref-script
💚 Build SucceededBuild metricsasync chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
Summary
This adds a button to the global nav help menu in the Canvas app for developers to generate the function reference. This button only appears in development, so it's not a user-facing feature.
Once you click the button, the entire markdown content of the function reference docs will be stored to your clipboard, and then you'll have to navigate to
kibana/docs/canvas/canvas-function-reference.asciidocand paste in the generated content.Because all of our function definitions support i18n, we have to generate the docs while Kibana is running, so I couldn't create a nice script to generate the docs and write the changes to the asciidoc file directly. This is a clunky workflow, but since it's not user-facing, I think it works well enough to get the job done. I'm open to suggestions for a better UX.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers