-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
doc: fix stability 1.x links excluding the decimal digit #58783
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
doc: fix stability 1.x links excluding the decimal digit #58783
Conversation
Review requested:
|
0c3c90c
to
391b587
Compare
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.
LGTM!
@@ -325,7 +326,7 @@ export function preprocessElements({ filename }) { | |||
// Insert div with prefix and number | |||
node.children.unshift({ | |||
type: 'html', | |||
value: `<div class="api_stability api_stability_${number}">` + | |||
value: `<div class="api_stability api_stability_${parseInt(number)}">` + |
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.
parseInt will only grab the numeric pieces of "number" right?
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.
Yes, in the regex that the part for number
is /\d(?:\.\d)?
meaning that the number
matched value can be a single digit optionally followed by a dot followed by another digit, parseInt
run on such numbers/strings always returns the integer part of the number:
And that's the part we need based on the css classes we have:
Lines 324 to 338 in d7becc5
.api_stability_0 { | |
background-color: var(--red1); | |
} | |
.api_stability_1 { | |
background-color: var(--red3); | |
} | |
.api_stability_2 { | |
background-color: var(--green2); | |
} | |
.api_stability_3 { | |
background-color: var(--blue1); | |
} |
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 used the same trick in the web generator :-)
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 just wanted to confirm. I recall either parseInt or Number() parse the numeric parseable stuff until it finds something non-numeric.
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.
No, not until it finds something non-numeric. It parses the float since it's a valid number, and flattens it to an integer.
Note to web infra teams: this doesn't need to be ported to |
Thanks, I was about to ask someone at some point if this needed porting (as I haven't looked too much into the new tooling I must admit 😓) but you saved me the effort 🫶 |
Landed in d8de8f3 |
I wish I could have landed this haha; Ah how it sucks not being a collaborator anymore lol |
PR-URL: #58783 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Pretty minor, this is just addressing a minimal UI quirk I noticed with the
Stability 1.x
links where the decimal digits are not included in the hyperlinkPS: I've also moved the regex outside of the
preprocessElements
function, as there is no reason/benefit to have the regex rebuilt for every file (having it outside might save some precious nanoseconds when building the docs 😅).Before
After