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

tools, docs: fix stability index isssues #20731

Closed
wants to merge 1 commit into from
Closed

tools, docs: fix stability index isssues #20731

wants to merge 1 commit into from

Conversation

vsemozhetbyt
Copy link
Contributor

@vsemozhetbyt vsemozhetbyt commented May 14, 2018

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Change 1: do not autolink in doc stability section

Currently, stability index descriptions in documentation.html contain links to their very section which is redundant. This commit prevents tools/doc/html.js from adding this links.

Screenshots of "before" and "after" states:


Before:

st1

After:

st2

Change 2: do not add void wrapping elements to docs

Currently, all the TOC links are wrapped in span elements with class according to stability index of their sections. However, most doc sections have not any stability index, so these spans have useless class stability_undefined. This commit prevents tools/doc/html.js from wrapping TOC links in useless spans.

Screenshots of "before" and "after" states (no visible difference):


Before:

cls1

After:

cls2


This PR eliminates 4402 useless elements in docs and reduces doc size by ~ 176 KB.

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. tools Issues and PRs related to the tools directory. labels May 14, 2018
@vsemozhetbyt

This comment has been minimized.

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM but I suggest to use a shorter version.

'<a href="documentation.html#documentation_stability_index">' +
`${prefix} ${number}</a>${explication}</div>`
.replace(/\n/g, ' ');
}
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to change this to something like:

const link = filename === 'documentation' &&
  heading && heading.text === 'Stability Index' ?
    `${prefix} ${number}` :
    '<a href="documentation.html#documentation_stability_index">' +
      `${prefix} ${number}</a>`;
token.text = `<div class="api_stability api_stability_${number}">` +
  `${link}${explication}</div>`
    .replace(/\n/g, ' ');

It is just a bit shorter due to having less repetition.

} else {
toc += ' '.repeat((depth - 1) * 2) +
`* <a href="#${id}">${token.text}</a>\n`;
}
Copy link
Member

Choose a reason for hiding this comment

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

The same as above.

1. Do not autolink in doc stability section.
2. Do not add void wrapping elements to docs.
@vsemozhetbyt
Copy link
Contributor Author

I've reduced diff and repetitions, PTAL.

CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite/711/

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 15, 2018
vsemozhetbyt added a commit that referenced this pull request May 17, 2018
1. Do not autolink in doc stability section.
2. Do not add void wrapping elements to docs.

PR-URL: #20731
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@vsemozhetbyt
Copy link
Contributor Author

Landed in 2773de5
Thank you for the reviews.

@vsemozhetbyt vsemozhetbyt deleted the doc-stability-nits branch May 17, 2018 18:05
MylesBorins pushed a commit that referenced this pull request May 22, 2018
1. Do not autolink in doc stability section.
2. Do not add void wrapping elements to docs.

PR-URL: #20731
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@addaleax addaleax mentioned this pull request May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. tools Issues and PRs related to the tools directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants