FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: Highlight deprecated API components in "Table of Contents" by ilfroloff · Pull Request #7189 · nodejs/node · GitHub

/ node Public

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

Closed
ilfroloff wants to merge 1 commit into
nodejs:masterfrom
ilfroloff:docs-deprecated-highlight
Closed

doc: Highlight deprecated API components in "Table of Contents"#7189
ilfroloff wants to merge 1 commit into
nodejs:masterfrom
ilfroloff:docs-deprecated-highlight

Conversation

Copy link
Copy Markdown
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 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 commented Jun 7, 2016
edited
Loading

Copy link
Copy Markdown
Contributor

cc @nodejs/documentation @nodejs/website

mscdex added the doc Issues and PRs related to the documentations. label Jun 7, 2016
Comment thread tools/doc/html.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is this really the cleanest way to do this? Looks super hacky.

ilfroloff Jun 7, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
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!

Copy link
Copy Markdown
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

Comment thread tools/doc/html.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Unnecessary changes?

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

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

Comment thread tools/doc/html.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

can probably be a top-level variable, that way we don't need to pass it to parseAPIHeader

Copy link
Copy Markdown
Contributor

LGTM minus comments

Fishrock123 self-assigned this Jun 30, 2016

Copy link
Copy Markdown
Contributor

ping @ilfroloff

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Contributor Author

@Fishrock123 completed. I implemented your suggestions

Comment thread tools/doc/html.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

ilfroloff Aug 2, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

ping @ilfroloff

Copy link
Copy Markdown
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!

Copy link
Copy Markdown
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):

Also similar in punycode module.

Thanks for answers.

Copy link
Copy Markdown
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.

Copy link
Copy Markdown
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 commented Oct 9, 2016

Copy link
Copy Markdown
Member

This is how it looks for domain and punycode:

silverwind commented Oct 9, 2016
edited
Loading

Copy link
Copy Markdown
Contributor

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 commented Oct 9, 2016
edited
Loading

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
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:

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 commented Oct 10, 2016

Copy link
Copy Markdown
Member

@ilfroloff awesome, I love that. Thanks!

Copy link
Copy Markdown
Contributor

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

lpinca commented Oct 10, 2016

Copy link
Copy Markdown
Member

@silverwind works for me.

Copy link
Copy Markdown
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 commented Oct 10, 2016

Copy link
Copy Markdown
Member

@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

Copy link
Copy Markdown
Contributor

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

silverwind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM besides centering nit.

Comment thread doc/api_assets/style.css Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

ilfroloff Oct 10, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Contributor

@lpinca lgty?

lpinca commented Oct 12, 2016

Copy link
Copy Markdown
Member

@silverwind yes, I didn't sign off because I'm not very familiar with the doc build tools.

Comment thread tools/doc/html.js

module.exports = toHTML;

const STABILITY_TEXT_REG_EXP = /(.*:)\s(\d)([\s\S]*)/;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it be better to make the \s greedy, which is before the digits?

Comment thread tools/doc/html.js
tok.type === 'code') {
if (tok.text.match(/Stability:.*/g)) {
const stabilityMatch = tok.text.match(STABILITY_TEXT_REG_EXP);
const stability = +stabilityMatch[2];

silverwind Oct 12, 2016
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>

Copy link
Copy Markdown
Contributor

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

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 <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
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 <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
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 <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This was referenced Nov 22, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL