-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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: Highlight deprecated API components in "Table of Contents" #7189
Conversation
cc @nodejs/documentation @nodejs/website |
if (tok.type === 'code' && tok.text.match(/Stability:.*/g)) { | ||
if(heading && (index - 1 === headingIndex || index - 2 === headingIndex)) { | ||
heading.stability = +tok.text.match(/.*:\s(\d)[\s\S]*/)[1]; |
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.
Is this really the cleanest way to do this? Looks super hacky.
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.
Yep, it's one of the cleanest solutions in this situation. I got regular expression from parseAPIHeader method which used below in code.
Code: https://github.com/nodejs/node/blob/master/tools/doc/html.js#L265
Note about (index - 1 === headingIndex || index - 2 === headingIndex)
:
I didn't find better solution for this moment.
It's small hack for detection place for marking stability in heading
block using tok.type === 'code'
.
Could you please set |
Seems to work. I like it. I was a bit conflicted at first about the strike through but I think that may be good for colorblind users. cc @nodejs/documentation |
var output = []; | ||
const output = []; | ||
let state = null; | ||
let depth = 0; |
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.
Unnecessary changes?
@ilfroloff I'll be willing to review more if you could change less where not necessary. :) |
Also if you could run |
Thanks for answer. |
@Fishrock123 I removed unnecessary changes and resolved error from |
if (tok.type === 'code' && tok.text.match(/Stability:.*/g)) { | ||
tok.text = parseAPIHeader(tok.text); | ||
output.push({ type: 'html', text: tok.text }); | ||
const stabilityTextRegExp = /(.*:)\s(\d)([\s\S]*)/; |
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 probably be a top-level variable, that way we don't need to pass it to parseAPIHeader
LGTM minus comments |
ping @ilfroloff |
@Fishrock123 pong) |
@Fishrock123 completed. I implemented your suggestions |
toc.push(new Array((depth - 1) * 2 + 1).join(' ') + | ||
'* <a href="#' + id + '">' + | ||
tok.text + '</a>'); | ||
'* %stability_' + tok.stability + '%' + |
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.
@ilfroloff Would this be better as
var toc_entry = tok.stability ? `<li class="${tok.stability}">` : '<li>';
toc_entry += `<a href="#' + id + '">${tok.text}</a>`;
toc.push(new Array((depth - 1) * 2 + 1).join(' ') + toc_entry);
That would get rid of the massive find/replace after the fact?
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.
@Fishrock123 sorry, but this code cannot be implemented, because <li>
html tag generated by this code.
Line 334
+ '* %stability_' + tok.stability + '%' +
need because I want to add class
attribute for <li>
after parsing.
Also, <li>
don't need to be closed, because </li>
tag generates by markdown parser.
@ilfroloff It doesn't look like the |
ping @ilfroloff |
@ilfroloff just tried to rebase and it didn't seem to work... If you have time could rebase? Also, I still don't understand why my find/replace comment wouldn't work.. :( If you don;t, mind if I take this PR over and make a new one (preserving your authorship)? I'd like to see something like this land! |
@Fishrock123 sorry, I didn't see that PR couldn't be rebased without conflicts. I fetched current master branch and adapted my code to new source)
new Array((depth - 1) * 2 + 1).join(' ') This part works only with In general, reason of adding was to set "class" attribute in Only one difference appeared after removing find/replace (it was one of reason why I added find/replace): Also similar in Thanks for answers. |
That strike-through style might be a bit too much imho, it conveys to me that the component has been removed, which isn't true. How about just adding a tag like GitHub issues have? Could be done through an |
The only concern I have with this is that the red link might give the impression that the target is not there. (like red links on Wikipedia). |
@silverwind I agree, read my comment above, I prefer to only have the label and leave the link color unchanged as you originally suggested. It's slick and effective imo. |
@ilfroloff awesome, I love that. Thanks! |
Can anyone test this? I just tried and can't see a difference. No classes seem to have been added. |
@silverwind works for me. |
Hmm strange, must be something about my setup then. I'm doing
|
@silverwind that's what I did as well
and opened the html files with the browser |
Ah, was a bad build cache, |
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 besides centering nit.
content: "deprecated"; | ||
font-size: .8em; | ||
position: relative; | ||
top: -.1em; |
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.
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.
Yep, agreed. I have changed top to .18em
Highlight deprecated API methods/prorepties in "Table of Contents" for increasing understandable Adapted code to eslint standarts
@lpinca lgty? |
@silverwind yes, I didn't sign off because I'm not very familiar with the doc build tools. |
@@ -9,6 +9,8 @@ const typeParser = require('./type-parser.js'); | |||
|
|||
module.exports = toHTML; | |||
|
|||
const STABILITY_TEXT_REG_EXP = /(.*:)\s(\d)([\s\S]*)/; |
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 it be better to make the \s
greedy, which is before the digits?
@@ -167,6 +172,17 @@ function parseLists(input) { | |||
if ((tok.type === 'paragraph' && state === 'MAYBE_STABILITY_BQ') || | |||
tok.type === 'code') { | |||
if (tok.text.match(/Stability:.*/g)) { | |||
const stabilityMatch = tok.text.match(STABILITY_TEXT_REG_EXP); | |||
const stability = +stabilityMatch[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.
Nit: Number(stabilityMatch[2])
might be cleaner.
Highlight deprecated API methods/properties in "Table of Contents" for increasing understandability. Adapted code to eslint standards. PR-URL: #7189 Fixes: nodejs/nodejs.org#772 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Landed with greedy regex and number constructor in fcee4d4, thanks! |
Highlight deprecated API methods/properties in "Table of Contents" for increasing understandability. Adapted code to eslint standards. PR-URL: #7189 Fixes: nodejs/nodejs.org#772 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Highlight deprecated API methods/properties in "Table of Contents" for increasing understandability. Adapted code to eslint standards. PR-URL: #7189 Fixes: nodejs/nodejs.org#772 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Highlight deprecated API methods/properties in "Table of Contents" for increasing understandability. Adapted code to eslint standards. PR-URL: #7189 Fixes: nodejs/nodejs.org#772 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Hi All!
Issue rolled up from nodejs/nodejs.org#772 topic.
P.S. I didn't change the color to grey as it's a bit unnoticeable when used with the green color of items.