-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
refactor: refactor code tab split #1369
Conversation
Deploy preview for docusaurus-2 ready! Built with commit 1a6897e |
a1d7b9d
to
1cbbef3
Compare
Deploy preview for docusaurus-preview ready! Built with commit a1d7b9d |
Deploy preview for docusaurus-preview ready! Built with commit 1a6897e |
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 seems to be a fix that changes the prev implementation to be more bug-less.
I am currently away so wont be able to test this out and review it carefully, but in the meantime do you mind to add comment on several places so that future contributor can understand your code intention ?
Thank you for the attempt, by the way 😊
1cbbef3
to
dc3a94e
Compare
@endiliey Added comments |
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.
Sorry for the delayed review.
LGTM. Awesome 🎉. However, there might be some edge cases that we might miss.
Would like to get the logic approved before getting too far into testing.
Use cases involving whitespace still need to be tested.
Are you going to write some unit test ? We can create fixtures to test out splitTabsToTitleAndContent
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.
Would be good to write tests for these. This is quite a brittle section.
Yeah, I'll create unit tests. |
372a1fe
to
371805c
Compare
@@ -9,3 +9,4 @@ website/ | |||
scripts | |||
packages/docusaurus-1.x/lib/core/metadata.js | |||
packages/docusaurus-1.x/lib/core/MetadataBlog.js | |||
packages/docusaurus-1.x/lib/core/__tests__/split-tab.test.js |
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.
Added because the lint fixer keeps removing @jest-environment jsdom
from my test file. I'm sure there's a workaround so this is just temporary.
it('renders content correctly', () => { | ||
const node = docPage().getDOMNode(); | ||
const firstContent = node.querySelector('[id$="-content-7"]').textContent; | ||
expect("console.log('Hello, world!');\n").toEqual(firstContent); |
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.
It might be okay to match the generated html from the highlighter.
}; | ||
beforeEach(() => { | ||
props = { | ||
content: ` |
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.
can we do content: fs.readFile('/some/path/to/fixtures/doc1.md') instead ?
20ba2f2
to
4996207
Compare
4996207
to
1a6897e
Compare
const contents = m.split('\n').filter(c => { | ||
if (!indents) { | ||
indents = ( | ||
c.match(/((\t|\s{4})+)<!--DOCUSAURUS_CODE_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.
Can remove redundant parentheses.
I like the fact that you put test on it. So far LGTM, I will test it out again locally tonight. cc @yangshun |
I just tried this out. This is awesome. Great job on fixing #1260 🎉 . However, the #1279 will only works if it's written with indentation For example, this does not work
What do you think ? |
@endiliey that might be an issue with remarkable. Adding a code block in between the list items on the online demo (https://jonschlinkert.github.io/remarkable/demo/) shows the same result. |
Motivation
Fix #1260 to allow html/xml comments in code tabs.
Unsure if this would be considered a
refactor
or afix
since it changes the way the tabs are parsed.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Only tested it locally, ensuring the code tabs on page
/docs/en/doc-markdown
still worked.Would like to get the logic approved before getting too far into testing.
Use cases involving whitespace still need to be tested.