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_auto_cfg formatting is not that great #118615

Closed
ChrisDenton opened this issue Dec 4, 2023 · 2 comments · Fixed by #118677
Closed

doc_auto_cfg formatting is not that great #118615

ChrisDenton opened this issue Dec 4, 2023 · 2 comments · Fixed by #118677
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-bug Category: This is a bug. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

ChrisDenton commented Dec 4, 2023

cargo doc has a new doc_auto_cfg feature that finally seems to figure this out based on cfg attributes so we don't have to generate the redundant doc comments any longer. rust-lang/rust#43781

Unfortunately, formatting is not that great.

image

287736263-243c1c1b-2283-45ea-8174-437ccd14ad5f

originally posted by @kennykerr

@ChrisDenton ChrisDenton added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` labels Dec 4, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@GuillaumeGomez GuillaumeGomez added the A-rustdoc-ui Area: rustdoc UI (generated HTML) label Dec 4, 2023
@GuillaumeGomez
Copy link
Member

I'll try to change the display because it's really not great.

@tim-weis
Copy link

tim-weis commented Dec 4, 2023

I wonder whether the formatting is the issue rather than the algorithm used to discover the required features. The formatting goes awry in the example above due to the large number of (redundant) features:

  • Win32
  • Win32_System
  • Win32_System_Diagnostics
  • Win32_System_Diagnostics_Debug

That's technically correct, but not entirely helpful to a developer either. windows' Cargo.toml has the following entries in its [features] table:

[features]
Win32_System = ["Win32"]
Win32_System_Diagnostics = ["Win32_System"]
Win32_System_Diagnostics_Debug = ["Win32_System_Diagnostics"]

To use OutputDebugStringW, the only feature a client needs to enable is Win32_System_Diagnostics_Debug. The remaining features are automatically enabled recursively via the Cargo.toml. It would seem reasonable to prune the feature list by eliminating those features that are implicitly enabled. Doing this solves two issues:

  • It makes the formatting a non-issue (here).
  • It declutters the documentation, showing only information that clients can act upon.

I'm not aware of a way to cancel automatic enablement of dependent features, so dropping this information from the documentation should be inconsequential in practice.


If the formatting is being reworked nonetheless, here's what I'd like to see:

  • Enclose the feature names in ASCII double quotes (") for convenient copy-pasting. The windows crate uses backticks to prevent them from being converted to smart quotes.
  • Make the list comma-separated (again, for convenient copy-pasting). I understand that and (as used currently) carries semantic information that needs to be reflected elsewhere. If or is being used, it can remain as-is. We commonly don't need to copy-paste disjunct features.

@bors bors closed this as completed in fa724cc Dec 8, 2023
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 8, 2023
Rollup merge of rust-lang#118677 - GuillaumeGomez:doc_cfg-display, r=notriddle

[rustdoc] Fix display of features

Fixes rust-lang#118615.

It now looks like this:

![image](https://github.com/rust-lang/rust/assets/3050060/6e77204e-0706-44a3-89ae-2dbd1934ebbc)

We can't use flex without breaking the flow, meaning we can't vertically align items as we want. Because of that, the `min-height` was problematic as it rendered weirdly and therefore needed to be removed.

r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-bug Category: This is a bug. F-doc_auto_cfg `#![feature(doc_auto_cfg)]` T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants