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

TOC in details #36896

Closed
wants to merge 1 commit into from
Closed

TOC in details #36896

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 12, 2021

Fixes: #36885

Note: small change made via GitHub UI without ant locale testing.

@nodejs-github-bot nodejs-github-bot added the doc Issues and PRs related to the documentations. label Jan 12, 2021
doc/template.html Outdated Show resolved Hide resolved
@aduh95
Copy link
Contributor

aduh95 commented Jan 12, 2021

Also, we need to adjust the stylesheet to the new DOM structure. You should replace

#toc h2 {
margin: 1.5rem 0;
}

with

#toc > ul {
  margin-top: 1.5rem;
}

@aduh95
Copy link
Contributor

aduh95 commented Jan 12, 2021

This PR breaks the script that generates the all.html page. I'm suggesting changing

const match = /(<\/ul>\s*)?<\/div>\s*<div id="apicontent">/.exec(data);
contents += data.slice(0, match.index)
.replace(/[\s\S]*?<div id="toc">\s*<h2>.*?<\/h2>\s*(<ul>\s*)?/, '');

to

  const match = /(<\/ul>\s*)?<\/\w+>\s*<\w+ id="apicontent">/.exec(data);

  contents += data.slice(0, match.index)
    .replace(/[\s\S]*?id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*(<ul>\s*)?/, '')

and

const tocStart = /<div id="toc">\s*<h2>.*?<\/h2>\s*/.exec(all);

to

const tocStart = /<\w+ id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*/.exec(all);

@aduh95
Copy link
Contributor

aduh95 commented Jan 12, 2021

Keep Calm. Lets revert last One first.

I'm confused, why do you want to revert?

@aduh95
Copy link
Contributor

aduh95 commented Jan 12, 2021

Would it help if I push myself the changes I'm suggesting to your branch to make the CI content?

@aduh95
Copy link
Contributor

aduh95 commented Jan 12, 2021

@mattiapontonio you actually can add several files in one PR; if you want to do so from GitHub web UI, you need to visit the file on your branch (https://github.com/mattiapontonio/node/blob/patch-1/tools/doc/allhtml.js), click edit, and commit on the same patch-1 branch.
Don't worry about the number of commits in the branch either, our policy is to squash all of them in one commit when merging; and in order to merge a PR the last commit must have a green CI, it doesn't matter if there are red CI commits in the middle.

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

I stand by my original comment – repeating "Table of content" is not great, and we should have the open attribute so the TOC is not hidden by default.

You are going to need to update the allhtml.js file as described in my above comment, and also update the style.css before this can land.

@ghost ghost closed this Jan 13, 2021
@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

@mattiapontonio are you closing this because you don't want to work on it anymore or did you get block in the process? I hope my comments didn't discourage you, I'm convinced this PR could greatly improve our docs, especially for people browsing them on mobile, and I'm eager to help you land it – if you need or want any help.

@ghost ghost reopened this Jan 13, 2021
@ghost ghost closed this Jan 13, 2021
@ghost ghost deleted the patch-1 branch January 13, 2021 11:13
@ghost
Copy link
Author

ghost commented Jan 13, 2021

@mattiapontonio I hope my comments didn't discourage you

@aduh95
But can you do this fix by touching only one file?

@ghost ghost restored the patch-1 branch January 13, 2021 11:24
@ghost ghost reopened this Jan 13, 2021
@ghost ghost requested a review from aduh95 January 13, 2021 11:24
@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

But can you do this fix by touching only one file?

No, you need to change at least three files. But why is that stopping you? You can modify as many files as you want in one PR by adding more commits to the branch.

@ghost
Copy link
Author

ghost commented Jan 13, 2021

I'm from a smartphone...
That's why i opened the issue.
The first CI passed... It was a straight to the point edit, a simple wrapping...

@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

I'm from a smartphone...

You can do that from the GitHub web CI. I just added a commit to your branch using my smartphone. Try to follow this link and click the edit button: https://github.com/mattiapontonio/node/blob/patch-1/tools/doc/allhtml.js

@ghost
Copy link
Author

ghost commented Jan 13, 2021

Yes but i don't want to do that, i want to wrap the TOC in a details...

Lets wait CI for this commit.

@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

Yes but i don't want to do that, i want to wrap the TOC in a details...

What's the reason you don't want that? Do you think it would look worse or you just don't want to touch the other files because it's not easy to do from a smartphone?

@ghost
Copy link
Author

ghost commented Jan 13, 2021

The second one.

Side issue
Markdown should support <select /> and <input type=radio>.

@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

The second one

OK, so are you OK if I push those changes to your branch myself? I'm afraid that's the only way to get a green CI if you change this part of the HTML.

@ghost
Copy link
Author

ghost commented Jan 13, 2021

Yes but please let me see the change (for learning).
If You can merge merge no problem.
Keep the <details/> closed by default for me.

@aduh95
Copy link
Contributor

aduh95 commented Jan 13, 2021

Keep the <details/> closed by default for me.

You mean you'd prefer without the open attribute? I'm open to have my mind changed, but I'm afraid that might be a surprising change to the docs – there always has been a visible TOC on our docs, hiding it by default would be weird.

/cc @nodejs/documentation what are your thoughts on this?

@ghost
Copy link
Author

ghost commented Jan 13, 2021

@ghost
Copy link
Author

ghost commented Jan 13, 2021

You mean you'd prefer without the open attribute?

Yes

@ghost
Copy link
Author

ghost commented Jan 14, 2021

It's ok for me to leave this open but in the future i could open a new issue about this after testing as a user.

@aduh95
Copy link
Contributor

aduh95 commented Jan 14, 2021

It's ok for me to leave this open but in the future i could open a new issue about this after testing as a user.

I'd be fine with that too. I was thinking maybe we could add a tiny JS script that automatically removes the open attribute on the <details> element if the user is visiting from a mobile phone on a follow up PR (based on the assumption that scrolling past the TOC is more a concern on smaller screens, but let's see it in practice).

@aduh95
Copy link
Contributor

aduh95 commented Jan 14, 2021

@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 14, 2021
PR-URL: #36896
Fixes: #36885
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95
Copy link
Contributor

aduh95 commented Jan 14, 2021

Landed in 2ba8728

@aduh95 aduh95 closed this Jan 14, 2021
@ghost
Copy link
Author

ghost commented Jan 14, 2021

Screenshot_20210114-165934.png

This Is closed not merged 🤔

@ghost
Copy link
Author

ghost commented Jan 14, 2021

Landed in 2ba8728

What landed means? ✈️🛬🤔

Screenshot_20210114-170838.png

@ghost
Copy link
Author

ghost commented Jan 14, 2021

add a tiny JS script that automatically removes the open attribute on the <details> element if the user is visiting from a mobile phone

I think is better to be consistent between HTMLs

@RaisinTen
Copy link
Contributor

@mattiapontonio your patch has been applied on the HEAD of the master branch instead of performing a merge commit because merges break our tooling.

@ghost
Copy link
Author

ghost commented Jan 14, 2021

@mattiapontonio your patch has been applied on the HEAD of the master branch instead of performing a merge commit because merges break our tooling.

Weird. So it's not deployed. And It Will not be?
In never comes in this practice / case

I'm from a smartphone, i can only screeshot what I see here.

Screenshot_20210114-171404.png

I'm expecting something like this

Screenshot_20210114-171527.png

@aduh95
Copy link
Contributor

aduh95 commented Jan 14, 2021

So it's not deployed. And It Will not be?

It will be part of the next release (well not the next one, because v15.6.0 cut off date has already passed, so the one after that), and then the docs on nodejs.org will be updated with your change. You may use the build artefact from GitHub CI to see the result already: https://github.com/nodejs/node/suites/1829898807/artifacts/35314688

@ghost
Copy link
Author

ghost commented Jan 14, 2021

So it's not deployed. And It Will not be?

It will be part of the next release (well not the next one, because v15.6.0 cut off date has already passed, so the one after that), and then the docs on nodejs.org will be updated with your change. You may use the build artefact from GitHub CI to see the result already: https://github.com/nodejs/node/suites/1829898807/artifacts/35314688

Ok 👍

@Trott
Copy link
Member

Trott commented Jan 14, 2021

One small issue this creates is that the triangle symbol now means different things (or at least behaves differently) in nearby places in the page. It's different in the version picker drop-down than it is for the table of contents. We might want to think about modifying the version picker slightly.

@ghost
Copy link
Author

ghost commented Jan 14, 2021

https://github.com/nodejs/node/suites/1829898807/artifacts/35314688

Should be intresting to see this deployed not in nodejs.org

@ghost
Copy link
Author

ghost commented Jan 14, 2021

We might want to think about modifying the version picker slightly.

Where is the HTML of that?
Is a <details> tag?
I meant <details> tag for both.
Disclosure means open and close things, right?

ruyadorno pushed a commit that referenced this pull request Jan 22, 2021
PR-URL: #36896
Fixes: #36885
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@ruyadorno ruyadorno mentioned this pull request Jan 22, 2021
@Trott
Copy link
Member

Trott commented Feb 23, 2021

We might want to think about modifying the version picker slightly.

Where is the HTML of that?
Is a <details> tag?
I meant <details> tag for both.
Disclosure means open and close things, right?

No, it's not a details tag.

<a href="#">View another version <span></span></a>

@ghost
Copy link
Author

ghost commented Feb 23, 2021

We might want to think about modifying the version picker slightly.

Where is the HTML of that?
Is a <details> tag?
I meant <details> tag for both.
Disclosure means open and close things, right?

No, it's not a details tag.

<a href="#">View another version <span></span></a>

Apparently not even ToC.

@ghost ghost mentioned this pull request Feb 23, 2021
targos pushed a commit that referenced this pull request May 1, 2021
PR-URL: #36896
Fixes: #36885
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@danielleadams danielleadams mentioned this pull request May 3, 2021
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table of contents in a <details>
6 participants