Skip to content

Conversation

QuietMisdreavus
Copy link
Contributor

It's another misdreavus rustdoc PR, which means it's time for Bikeshed City once again! :3

In an effort to aid navigation in long documentation pages, this PR adds a listing of headings to the sidebars of pages where such headings exist. For example, for structs, links to their fields, inherent methods, and trait implementations are available where applicable.

Examples:

  • Modules/Crate roots
    image
  • Enums
    image
  • Primitives
    image
  • Traits
    image
  • Structs
    image

Open questions:

  • Right now, these kinds of pages (and also unions) are the only pages that will receive the name header - pages for functions, constants, macros, etc, won't have the corresponding name in their sidebar. Should I print the name regardless and only add table-of-contents links for pages that have them? This would make them match, for example, a struct with no public fields, no methods, and no trait implementations. The latter would still have a "Struct MyStruct" line above the module contents, with no header links to speak of, whereas a function wouldn't even have "Function my_function".
  • This is only a header listing, but there has been requests to include a more-complete listing of fields/methods/traits/etc, for example in Include a list of struct methods in reference sidebar on struct pages #41123.

@rust-highfive
Copy link
Contributor

r? @steveklabnik

(rust_highfive has picked a reviewer for you, use r? to override)

@erickt erickt added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Apr 13, 2017
@@ -292,7 +292,7 @@ impl Item {
self.type_() == ItemType::Struct
}
pub fn is_enum(&self) -> bool {
self.type_() == ItemType::Module
self.type_() == ItemType::Enum
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was so confused why enums weren't getting the sidebar stuff, until I decided to trace back through what is_enum was doing. Apparently it's been like this for a while, but there's also no other users for this method, so it's not harming anything.

Copy link
Member

Choose a reason for hiding this comment

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

But now it's working correctly, which is great.

@GuillaumeGomez
Copy link
Member

👍

@GuillaumeGomez
Copy link
Member

Oh and please clean your git history.

@QuietMisdreavus
Copy link
Contributor Author

Can do. I'll squash when this is ready to roll, in case there's some aesthetic commentary.

@GuillaumeGomez
Copy link
Member

Well, please put a whitespace after // please. (since we're at it...)

@QuietMisdreavus
Copy link
Contributor Author

Huh, the earlier commit failed Travis because the link-checker failed me for broken TOC links. Good job, link-checker! (^^)b

@Mark-Simulacrum Mark-Simulacrum added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 14, 2017
@carols10cents
Copy link
Member

Hm is this waiting on a squash by @QuietMisdreavus or a review from @steveklabnik?

@QuietMisdreavus
Copy link
Contributor Author

Probably mainly on me, but I was wanting to see if there were any remarks on the "open questions" I had on the bottom of the lead comment. If @steveklabnik and @GuillaumeGomez are fine with this as-is, though, I'll squash and carry on.

@GuillaumeGomez
Copy link
Member

Good for me.

@steveklabnik
Copy link
Contributor

Let's do it!

@GuillaumeGomez
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Apr 17, 2017

📌 Commit 27bfbd5 has been approved by GuillaumeGomez

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Apr 17, 2017
…laumeGomez

rustdoc: add a list of headings to the sidebar

It's another misdreavus rustdoc PR, which means it's time for Bikeshed City once again! `:3`

In an effort to aid navigation in long documentation pages, this PR adds a listing of headings to the sidebars of pages where such headings exist. For example, for structs, links to their fields, inherent methods, and trait implementations are available where applicable.

Examples:

* Modules/Crate roots
  ![image](https://cloud.githubusercontent.com/assets/5217170/25019930/1000fa3a-2052-11e7-98ff-ddf5af18b3e6.png)
* Enums
  ![image](https://cloud.githubusercontent.com/assets/5217170/25019954/33497f9e-2052-11e7-88cf-df46f1b3b8a3.png)
* Primitives
  ![image](https://cloud.githubusercontent.com/assets/5217170/25019978/4820bbc6-2052-11e7-8b5a-96a864eb2a5b.png)
* Traits
  ![image](https://cloud.githubusercontent.com/assets/5217170/25020093/bd1bc9f2-2052-11e7-9cd1-00a0ad8007bc.png)
* Structs
  ![image](https://cloud.githubusercontent.com/assets/5217170/25020145/d75206b0-2052-11e7-88cc-9e9525084775.png)

Open questions:

* Right now, these kinds of pages (and also unions) are the only pages that will receive the name header - pages for functions, constants, macros, etc, won't have the corresponding name in their sidebar. Should I print the name regardless and only add table-of-contents links for pages that have them? This would make them match, for example, a struct with no public fields, no methods, and no trait implementations. The latter would still have a "Struct MyStruct" line above the module contents, with no header links to speak of, whereas a function wouldn't even have "Function my\_function".
* This is only a header listing, but there has been requests to include a more-complete listing of fields/methods/traits/etc, for example in rust-lang#41123.
bors added a commit that referenced this pull request Apr 17, 2017
Rollup of 3 pull requests

- Successful merges: #41012, #41280, #41290
- Failed merges:
@bors bors merged commit 27bfbd5 into rust-lang:master Apr 17, 2017
@QuietMisdreavus QuietMisdreavus deleted the rustdoc-toc branch April 20, 2017 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants