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: fix word wrapping for api stability boxes #14809

Closed
wants to merge 3 commits into from
Closed

doc: fix word wrapping for api stability boxes #14809

wants to merge 3 commits into from

Conversation

saadq
Copy link
Contributor

@saadq saadq commented Aug 13, 2017

Checklist
Affected core subsystem(s)

doc


This is meant to fix the issue that was opened here originally.

Fixes: nodejs/nodejs.org#1337

Before:
screen shot 2017-08-13 at 12 21 52 pm

After:
screen shot 2017-08-13 at 12 22 02 pm

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Aug 13, 2017
Trott
Trott previously approved these changes Aug 13, 2017
@silverwind
Copy link
Contributor

silverwind commented Aug 13, 2017

Is there a reason why these boxes are <pre>? Doesn't seem semantically correct to me, and the fact that they inherit rules targeting code blocks isn't ideal either.

I'd change them to <div> and add padding: 1em to them.

@refack
Copy link
Contributor

refack commented Aug 13, 2017

Is there a reason why these boxes are <pre>? Doesn't seem semantically correct to me, and the fact that they inherit rules targeting code blocks isn't ideal either.

I think it's because it's rendered markdown. A simple style change might be to replace the ``` with >


image

or exclude pre[lang=txt] from the css

@silverwind
Copy link
Contributor

@refack nope, they are generated by our own code:

`<pre class="${classNames}"><a href="${docsUrl}">$1 $2</a>$3</pre>`

@refack
Copy link
Contributor

refack commented Aug 13, 2017

Mostly enjoying the new code line quoting 👐

@refack nope, they are generated by our own code:

AFAICT that's the header for each API endpoint:

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

node/tools/doc/html.js

Lines 397 to 406 in 314217f

function parseAPIHeader(text) {
const classNames = 'api_stability api_stability_$2';
const docsUrl = 'documentation.html#documentation_stability_index';
text = text.replace(
STABILITY_TEXT_REG_EXP,
`<pre class="${classNames}"><a href="${docsUrl}">$1 $2</a>$3</pre>`
);
return text;
}

That maps:

node/doc/api/crypto.md

Lines 678 to 684 in 2e7ccc2

### ecdh.setPublicKey(publicKey[, encoding])
<!-- YAML
added: v0.11.14
deprecated: v5.2.0
-->
> Stability: 0 - Deprecated

to:
image


Anyway let's do both: replace the markup and the rendering code

@silverwind
Copy link
Contributor

@refack I'm still pretty sure that <pre> comes from there, the changelog (.api_metadata) is generated elsewhere.

Anyways, my suggestion to @saadq would be to replace the <pre> with a <div> in html.js and add padding: 1em to .api_stability in CSS.

@saadq
Copy link
Contributor Author

saadq commented Aug 14, 2017

I agree that pre probably wasn't that semantically correct, so I changed it to div as you suggested. However, this cause some stylistic issues:

After changing pre -> div
screen shot 2017-08-13 at 11 32 29 pm

The font-weight became a lot bolder and the line-height became smaller, so I added a couple of styles to make it look like it did when it was still using pre.

After adding/removing some additional styles
screen shot 2017-08-13 at 11 31 02 pm

Does this look alright to everyone?

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.

Looking fine to me, thanks.

white-space: pre-wrap;
word-wrap: break-word;
padding: 1em;
line-height: 1.5;
Copy link
Member

Choose a reason for hiding this comment

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

Are these (esp. the font and wrapping ones) still necessary now that the container has been switched to a <div>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, you're right. Since it's not pre anymore, the wrapping is no longer an issue. The padding and line-height are still necessary though.

Copy link
Contributor Author

@saadq saadq Aug 14, 2017

Choose a reason for hiding this comment

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

I reverted the wrapping changes. Just to clarify, I don't know if the line-height is strictly "necessary", I just added it because that was what the pre had originally. I'm not sure if you all think it looks fine without it.

Without line-height:
screen shot 2017-08-14 at 5 18 42 am

With line-height:
screen shot 2017-08-14 at 5 18 53 am

Copy link
Contributor

@silverwind silverwind Aug 14, 2017

Choose a reason for hiding this comment

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

I think I like it more with the extra space. Another option would be to make it a <p> which already sets 1.5em line-height and a similar margin-bottom, so you save two declarations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thought, it might be unexpected to have <p> and those boxes share CSS. So, LGTM as-is.

@Trott Trott dismissed their stale review August 14, 2017 21:18

A bunch of other people are looking at this more closely and with more expertise than I bring to CSS etc. Plus, my review is from a version of this PR that is now several iterations old. Dismissing my review and letting the knowledgable folks handle it instead. Thanks!

white-space: pre-wrap;
word-wrap: break-word;
padding: 1em;
line-height: 1.5;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought, it might be unexpected to have <p> and those boxes share CSS. So, LGTM as-is.

@tniessen
Copy link
Member

Landed in eab2bea.

@tniessen tniessen closed this Aug 16, 2017
tniessen pushed a commit that referenced this pull request Aug 16, 2017
PR-URL: #14809
Fixes: nodejs/nodejs.org#1337
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MSLaguana pushed a commit to nodejs/node-chakracore that referenced this pull request Aug 21, 2017
PR-URL: nodejs/node#14809
Fixes: nodejs/nodejs.org#1337
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
PR-URL: #14809
Fixes: nodejs/nodejs.org#1337
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
PR-URL: #14809
Fixes: nodejs/nodejs.org#1337
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
MylesBorins pushed a commit that referenced this pull request Sep 20, 2017
PR-URL: #14809
Fixes: nodejs/nodejs.org#1337
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@MylesBorins MylesBorins mentioned this pull request Sep 20, 2017
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.

stability index wrapping