-
Notifications
You must be signed in to change notification settings - Fork 3.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
docs(markdown): parse :::note's text as MD elements #32510
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
5acc78d
to
cdd5bd5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cdd5bd5
to
3bbd7de
Compare
This comment has been minimized.
This comment has been minimized.
85b9b49
to
0d97fc4
Compare
This comment has been minimized.
This comment has been minimized.
utils/doclint/documentation.js
Outdated
@@ -802,12 +802,12 @@ function generateSourceCodeComment(spec) { | |||
node.codeLang = parseCodeLang(node.codeLang).highlighter; | |||
if (node.type === 'note') { | |||
// @ts-ignore | |||
node.type = 'text'; | |||
node.text = '**NOTE** ' + node.text; | |||
node.type = 'text' |
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.
Why no semicolons?
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.
its JS, we don't lint JS.
This comment has been minimized.
This comment has been minimized.
0d97fc4
to
1762fef
Compare
1762fef
to
e3368c8
Compare
This comment has been minimized.
This comment has been minimized.
} | ||
innerRenderMdNode(indent, textNode, lastNode, result, options); | ||
} else { | ||
result.push(`${indent}:::${node.noteType}`); |
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.
result.push(`${indent}:::${node.noteType}`); | |
result.push(options.notePrefix || `${indent}:::${node.noteType}`); |
const children = node.children ?? []; | ||
for (let i = 0; i < children.length; i++) | ||
innerRenderMdNode(indent, children[i], lastNode, result, options); | ||
result.push(`${indent}:::`); |
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.
result.push(`${indent}:::`); | |
result.push(options.noteSuffix || `${indent}:::`); |
* renderCodeBlockTitlesInHeader?: boolean | ||
* flattenText?: boolean, | ||
* renderCodeBlockTitlesInHeader?: boolean, | ||
* renderNoteAsText?: boolean, |
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'd recommend notePrefix?: string, noteSuffix?: string
. This way, you can render code blocks or lists inside notes, even for typescript comments.
for (let i = 0; i < children.length; i++) | ||
innerRenderMdNode(indent, children[i], lastNode, result, options); |
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.
for (let i = 0; i < children.length; i++) | |
innerRenderMdNode(indent, children[i], lastNode, result, options); | |
for (const child of children) { | |
innerRenderMdNode(indent, child, lastNode, result, options); | |
lastNode = child; | |
} |
Test results for "tests 1"1 failed 1 flaky36325 passed, 743 skipped Merge workflow run. |
Two ways of fixing it, either:
a) Pass
flattenText: falase
towrapText
's options, but it seems to come from high up and overriding it only for:::note
seems not great.b) Parse the
:::note
's children as real MarkdownNotes and render them as real notesI did b) in this case, which seems more reasonable.
Fixes #32505
Preview of the rolled docs: microsoft/playwright.dev#1503