-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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: use docusaurus-remark-plugin-tab-blocks
to format tabs with code examples
#12859
Conversation
@@ -25,9 +25,6 @@ import TOCInline from '@theme/TOCInline'; | |||
|
|||
## Reference | |||
|
|||
import Tabs from '@theme/Tabs'; |
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.
The plugin will add these too.
One more complex case has to stay. Tabs wrap two pieces of code here, have to think how to make it work. Probably that is alright for now? |
Deploy preview looks perfectly fine. Nice. |
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.
I like it! Landed the other PR first, but different files, so no conflict
Was thinking how improve this plugin. Here is the plan:
|
// eslint-disable-next-line consistent-return | ||
return index + tabs.length; |
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.
This return makes the visitor to skip traversing nodes which were just replaced with splice
. Lint is complaining, but seems like all is good here.
The lint rule is turned off for ts
and md
files. Should apply for js
only. It only prints a warning, so not sure if that is still useful. Perhaps?
console.log('this is second JS codeblock in a tab'); | ||
``` | ||
|
||
```ts tab={"span":2} |
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.
I went for span
, after considering group
, include
, next
and something else. Sounded alright, but can be renamed as well. In a way, it defines a tab which spans two (or more) code blocks.
Also note that the next code block does not need any tab related meta data. Everything is configured through the first one.
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.
this looks great! I'm not sure the plugin itself needs to live in this repo, tho?
@@ -0,0 +1,126 @@ | |||
/** |
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.
thoughts on publishing this outside of this repo?
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.
I was thinking this way. It became more universal than I though in the beginning. Sounds fun to publish it separately. Why not? I will do that ;D
docusaurus-remark-plugin-tab-blocks
to format tabs with code examples
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 nice!
Indeed. In the end this is simple and nice. Thanks for the idea! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
From #12848 (comment)
Summary
As mentioned in the comment, I wrote a Remark plugin which helps to avoid boilerplate for js/ts tabs in documentation.
This would be incredibly useful in configuration page. So perhaps, let‘s land this PR first? (If it does the job, of course.)
Todo
Tabs
andTabItem
elsewhere in docs.Test plan
Deploy preview.