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

rustdoc: Avoid duplicating macros in sidebar #94002

Merged
merged 2 commits into from
Feb 20, 2022

Conversation

GuillaumeGomez
Copy link
Member

Fixes #93912.

cc @jsha (for the GUI test)
r? @camelid

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Feb 14, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2022
@camelid camelid changed the title Duplicated sidebar macro rustdoc: Avoid duplicating macros in sidebar Feb 15, 2022
@camelid camelid removed the A-rustdoc-ui Area: Rustdoc UI (generated HTML) label Feb 15, 2022
@@ -250,6 +250,8 @@ impl<'tcx> Context<'tcx> {
fn build_sidebar_items(&self, m: &clean::Module) -> BTreeMap<String, Vec<NameDoc>> {
// BTreeMap instead of HashMap to get a sorted output
let mut map: BTreeMap<_, Vec<_>> = BTreeMap::new();
let mut inserted: FxHashMap<ItemType, FxHashSet<Symbol>> = FxHashMap::default();
Copy link
Member

Choose a reason for hiding this comment

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

Using a map to skip duplicates doesn't seem like the correct approach to me. We shouldn't have two macros with the same name in the module in the first place, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's possible because of reexports. Initially, I had rewrote using a BTreeMap but then I discovered that we had an option to keep the declaration order. So I had to revert that and instead using a Hashmap alongside...

Comment on lines +1 to +14
// This test ensures that there is no macro duplicates in the sidebar.
goto: file://|DOC_PATH|/test_docs/macro.a.html
// Waiting for the elements in the sidebar to be rendered.
wait-for: ".sidebar-elems .others .macro"
// Check there is only one macro named "a" listed in the sidebar.
assert-count: (
"//*[@class='sidebar-elems']//*[@class='others']/*[@class='block macro']//li/a[text()='a']",
1,
)
// Check there is only one macro named "b" listed in the sidebar.
assert-count: (
"//*[@class='sidebar-elems']//*[@class='others']/*[@class='block macro']//li/a[text()='b']",
1,
)
Copy link
Member

Choose a reason for hiding this comment

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

This should be a regular HTML test using @count, not a GUI test.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's generated by the JS, so can't do that. ^^'

Copy link
Member

Choose a reason for hiding this comment

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

It is? Somewhat off-topic, but why?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm wondering the same thing... Will need to dive into this to understand.

@camelid camelid added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2022
@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 16, 2022
@jsha
Copy link
Contributor

jsha commented Feb 16, 2022 via email

@GuillaumeGomez
Copy link
Member Author

Thanks for the explanation! :)

@camelid
Copy link
Member

camelid commented Feb 17, 2022

I guess this PR seems correct, but I don't have time to check further unfortunately. r? @jsha

@rust-highfive rust-highfive assigned jsha and unassigned camelid Feb 17, 2022
@GuillaumeGomez
Copy link
Member Author

@notriddle might know this area better. Well, we'll see. 😉

@notriddle
Copy link
Contributor

This looks like a reasonable choice to me.

@GuillaumeGomez
Copy link
Member Author

Then let's go!

@bors: r=notriddle rollup

@bors
Copy link
Contributor

bors commented Feb 18, 2022

📌 Commit d9ea7bc has been approved by notriddle

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2022
…acro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes rust-lang#93912.

cc `@jsha` (for the GUI test)
r? `@camelid`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2022
…acro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes rust-lang#93912.

cc ``@jsha`` (for the GUI test)
r? ``@camelid``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2022
…acro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes rust-lang#93912.

cc ```@jsha``` (for the GUI test)
r? ```@camelid```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2022
…acro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes rust-lang#93912.

cc ````@jsha```` (for the GUI test)
r? ````@camelid````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 19, 2022
…acro, r=notriddle

rustdoc: Avoid duplicating macros in sidebar

Fixes rust-lang#93912.

cc `````@jsha````` (for the GUI test)
r? `````@camelid`````
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 20, 2022
…askrgr

Rollup of 14 pull requests

Successful merges:

 - rust-lang#93580 (Stabilize pin_static_ref.)
 - rust-lang#93639 (Release notes for 1.59)
 - rust-lang#93686 (core: Implement ASCII trim functions on byte slices)
 - rust-lang#94002 (rustdoc: Avoid duplicating macros in sidebar)
 - rust-lang#94019 (removing architecture requirements for RustyHermit)
 - rust-lang#94023 (adapt static-nobundle test to use llvm-nm)
 - rust-lang#94091 (Fix rustdoc const computed value)
 - rust-lang#94093 (Fix pretty printing of enums without variants)
 - rust-lang#94097 (Add module-level docs for `rustc_middle::query`)
 - rust-lang#94112 (Optimize char_try_from_u32)
 - rust-lang#94113 (document rustc_middle::mir::Field)
 - rust-lang#94122 (Fix miniz_oxide types showing up in std docs)
 - rust-lang#94142 (rustc_typeck: adopt let else in more places)
 - rust-lang#94146 (Adopt let else in more places)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1ae00e0 into rust-lang:master Feb 20, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 20, 2022
@GuillaumeGomez GuillaumeGomez deleted the duplicated-sidebar-macro branch February 20, 2022 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exported macros appear twice in left sidebar (rustc 1.60.0 nightly, docsrs 0.6.0)
7 participants