-
Notifications
You must be signed in to change notification settings - Fork 87
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
docs: allow DocsShow
to automatically parse SFC's and display their source and output
#905
base: develop
Are you sure you want to change the base?
Conversation
Thanks a lot @EshaanAgg, I will review. Would you please clarify if and how we can override the code output, for example how to achieve code sample outputs like here It's something we do intentionally (and for larger components frequently) to prevent from overwhelming information. In the future, there will be a way to see the full via GitHub link, but documentation code samples are rather brief and to the point. During the course of this migration, I'd like to be sure we don't lose the flexibility in this area. |
Yes thank you, definitely. Basically DocsExample's final interface is planned to look like
I don't know when we will have it and I think it's fine to not be concerned as long as the approach take here is compatible enough so we can migrate it easily. |
Hi @MisRob! Using the new props introduced, we can't override the code sample as shown. As I see it, this should be used as an additional convenience helper: if we want to get the complete code for some components, we can migrate them to dedicated files and use the In case of custom behavior, we can continue using the documentation components as we currently do: <DocsShow>
<DocsShowCode language='html'>
<p>...partial code that we want to show </p>
</DocsShowCode>
</DocsShowCode>
Sure! That's why I have tried to only add some additional APIs, and not override any existing behaviour. |
I see. Yeah I think it'd be fine, even though perhaps we can brainstorm a bit? Since this is something we do often. I think it wouldn't need to be complicated and quite aligned with your thinking and all work here, for example having examples/example1.vue
and then loading it to the docs page
All How would something like that sound to you? |
Of course now the way to imagine
Also I am not sure if we need another component I also want to keep thinking whether we can make all these perspectives work with auto-generation as you suggest originally in this PR. Every approach has benefits, and perhaps we can make it all work nicely together. Please let me know any thoughts. |
I will return to this by the end of the week and try to think about these questions meanwhile too |
Yes! If the API contract for the same is not fixed, I would like for it to support three usages:
<DocsExample component="/examples/KComponent/FileName" />
<DocsExample component="/examples/KComponent/FileName">
<template #html>
<KCardGrid ...>
...
</KCardGrid>
</template>
<template #javascript>
export default {
...
}
</template>
<template #scss>
.class {
...
}
</template>
</DocsExample> In both the examples above, we can configure it to link to the complete example files through a GitHub link in the navigation bar. The slots here would have the highest priority.
<DocsExample>
<template #html>
<KCardGrid ...>
...
</KCardGrid>
</template>
<template #javascript>
export default {
...
}
</template>
</DocsExample> The output would be similar to (2), but no link to any GitHub documentation file. |
Nono, no fixed :) I am opening this discussion because I am suspicious you may be interested in it and pretty confident we will come up with something nice :) Thanks a lot for the comment, I will read it with fresh eyes on Thursday - I am just signing off and tomorrow am out for some errands. |
Most definitely :) While designing this interface, my main idea was to place only complete SFCs as examples in the
The same is more of a semantic choice for me. I would prefer the examples if they can be considered independent "drag & drop" SFCs that I can take inspiration from and use directly in my code from the GitHub files. Having these
I would like to have linting enabled for them as well, as it would ensure that the code we showcase in the documentation is properly formatted and "idiomatic". We can perhaps fine-tune the lining configuration for the A simple example of the same can be found in this PR itself: we have the kolibri-design-system/docs/examples/KTable/DisableBuiltinSorting.vue Lines 35 to 41 in a6f7a8d
It would make sense to turn this rule off for this directory to eliminate the Under typical usage, we would only need to disable linting when we provide custom display slots for the templates. In such cases, the developer can either:
I would also argue against it. I would prefer one component whose behavior I could customize to support all my use cases rather than having super-focused components for each related use case. The
Lost a bit of context here. Autogeneration as in that of the |
Description
The PR modifies the
DocsShow
component to accept two new arguments:loadExample
: The path to the component that needs to be shown to the user. When passed, the component is loaded dynamically, and its source code is parsed into three separateDocsShowCode
blocks.showOutput
: Controls whether the example component is to be rendered in the documentation. Defaults totrue
.All the examples must be in the
/docs/examples
directory to be loaded correctly.DocsShow
still accepts a default slot, so the user can use it to render a custom component with or without the example. This functionality should (probably) be migrated to theDocsExample
component when ready. TheloadExample
prop is set to benull
by default so that it does not cause any regressions or changes in it's existing usage across the documentation pages.I have also migrated the
KTable
documentation to use this new feature (as that is the component that I am most familiar with & believe could really benefit from this new API).Issue addressed
Fixes #861
Changelog
DocsShow
componentImplementation notes
At a high level, how did you implement this?
Used the
raw-loader
plugin with Webpack to configure the loading of components.Does this introduce any tech-debt items?
No
Testing checklist
Reviewer guidance