Skip to content
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

Closed
wants to merge 1 commit into from
Closed

doc: Highlight deprecated API components in "Table of Contents" #7189

wants to merge 1 commit into from

Conversation

ilfroloff
Copy link
Contributor

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.

@ilfroloff ilfroloff changed the title docs: Highlight deprecated API components in "Table of Contents" doc: Highlight deprecated API components in "Table of Contents" Jun 7, 2016
@stevemao
Copy link
Contributor

stevemao commented Jun 7, 2016

cc @nodejs/documentation @nodejs/website

@mscdex mscdex added the doc Issues and PRs related to the documentations. label Jun 7, 2016
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];
Copy link
Member

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.

Copy link
Contributor Author

@ilfroloff ilfroloff Jun 7, 2016

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'.

@Fishrock123
Copy link
Contributor

/Users/Jeremiah/Documents/node/.git/rebase-apply/patch:48: trailing whitespace.

/Users/Jeremiah/Documents/node/.git/rebase-apply/patch:54: trailing whitespace.

/Users/Jeremiah/Documents/node/.git/rebase-apply/patch:124: trailing whitespace.

warning: 3 lines applied after fixing whitespace errors.

Could you please set git config --global --add core.whitespace fix? thanks!

@Fishrock123
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary changes?

@Fishrock123
Copy link
Contributor

@ilfroloff I'll be willing to review more if you could change less where not necessary. :)

@Fishrock123
Copy link
Contributor

Also if you could run make -j4 lint that would be great!

@ilfroloff
Copy link
Contributor Author

Thanks for answer.
I'll revert all unnecessary change. Sorry for this

@ilfroloff
Copy link
Contributor Author

@Fishrock123 I removed unnecessary changes and resolved error from make -j4 lint command.

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]*)/;
Copy link
Contributor

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

@Fishrock123
Copy link
Contributor

LGTM minus comments

@Fishrock123 Fishrock123 self-assigned this Jun 30, 2016
@Fishrock123
Copy link
Contributor

ping @ilfroloff

@ilfroloff
Copy link
Contributor Author

@Fishrock123 pong)
I'll push corrections in soon.

@ilfroloff
Copy link
Contributor Author

@Fishrock123 completed. I implemented your suggestions

toc.push(new Array((depth - 1) * 2 + 1).join(' ') +
'* <a href="#' + id + '">' +
tok.text + '</a>');
'* %stability_' + tok.stability + '%' +
Copy link
Contributor

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?

Copy link
Contributor Author

@ilfroloff ilfroloff Aug 2, 2016

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.

@Fishrock123
Copy link
Contributor

@ilfroloff It doesn't look like the <li>'s are ever closed with a </li>?

@Fishrock123
Copy link
Contributor

ping @ilfroloff

@Fishrock123
Copy link
Contributor

@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!

@ilfroloff
Copy link
Contributor Author

@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)

Also, I still don't understand why my find/replace comment wouldn't work.. :(

new Array((depth - 1) * 2 + 1).join(' ')

This part works only with * because it provides intent of markdown's list. But you replaced * to <li> tag and markdown's parser built incorrect html.

In general, reason of adding was to set "class" attribute in <li> tag for restyling all <a> children. But after your question, I rethought and remade code without find/replace of <li>. Now, "class" attribute is set directly to <a> tag. You can check it in update. Thanks for advice)

Only one difference appeared after removing find/replace (it was one of reason why I added find/replace):
untitled-1

Also similar in punycode module.

Thanks for answers.

@silverwind
Copy link
Contributor

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 ::after element.

@silverwind
Copy link
Contributor

How about something like this?

#toc .stability_0:after {
  content: "deprecated";
  font-size: .8em;
  position: relative;
  top: -.1em;
  margin-left: .3em;
  background: #f44;
  color: #fff;
  padding: .1em .3em;
  border-radius: 3px;
}

@lpinca
Copy link
Member

lpinca commented Oct 9, 2016

This is how it looks for domain and punycode:

screen shot 2016-10-09 at 15 11 25

screen shot 2016-10-09 at 15 11 46

@silverwind
Copy link
Contributor

silverwind commented Oct 9, 2016

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).

@lpinca
Copy link
Member

lpinca commented Oct 9, 2016

@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
Copy link
Contributor Author

@lpinca

I prefer to only have the label and leave the link color unchanged as you originally suggested

Yep, I have changed deprecated color to original green. It looks like:
image

Also, one of reason, I have had the problem how to change color to red for all domain or punycode children links - it's pretty hard in current building of docs html.

@lpinca
Copy link
Member

lpinca commented Oct 10, 2016

@ilfroloff awesome, I love that. Thanks!

@silverwind
Copy link
Contributor

Can anyone test this? I just tried and can't see a difference. No classes seem to have been added.

@lpinca
Copy link
Member

lpinca commented Oct 10, 2016

@silverwind works for me.

screen shot 2016-10-10 at 19 34 38

@silverwind
Copy link
Contributor

Hmm strange, must be something about my setup then. I'm doing

apply-pr 7189 && ./configure && make doc-only && http-server out/doc/api

@lpinca
Copy link
Member

lpinca commented Oct 10, 2016

@silverwind that's what I did as well

curl -L https://github.com/nodejs/node/pull/7189.patch | git am
make doc-only

and opened the html files with the browser

@silverwind
Copy link
Contributor

Ah, was a bad build cache, rm -rf out/doc did help.

Copy link
Contributor

@silverwind silverwind left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why (em cascade?), but -.18em seems to center it better:

Copy link
Contributor Author

@ilfroloff ilfroloff Oct 10, 2016

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
@silverwind
Copy link
Contributor

@lpinca lgty?

@lpinca
Copy link
Member

lpinca commented Oct 12, 2016

@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]*)/;
Copy link
Contributor

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];
Copy link
Contributor

@silverwind silverwind Oct 12, 2016

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.

silverwind pushed a commit that referenced this pull request Oct 14, 2016
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 <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
@silverwind
Copy link
Contributor

Landed with greedy regex and number constructor in fcee4d4, thanks!

@silverwind silverwind closed this Oct 14, 2016
jasnell pushed a commit that referenced this pull request Oct 14, 2016
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 <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 11, 2016
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 <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 11, 2016
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 <[email protected]>
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
This was referenced Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants