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

Document items behind feature flags #103

Merged
merged 2 commits into from
Oct 10, 2022
Merged

Conversation

ninevra
Copy link
Contributor

@ninevra ninevra commented Oct 9, 2022

Should cause docs.rs to build documentation for items behind feature flags, and to label them with the associated feature flags.

Uses the --all-features cargo option and the unstable doc_auto_cfg feature to achieve this. Places the doc_auto_cfg feature behind a cfg flag so that it's only used when running on docs.rs.

Includes a plan accounting for the (currently) expected stabilization path for doc_auto_cfg.

Unfortunately, I lack the setup required to run docs.rs locally, so I cannot test the docs.rs-specific configuration options at this time. I understand that may make this PR not very useful. For what it's worth, the configuration options are based on those used by tokio.

Sorry about the lack of testing; I just thought this was an interesting problem, went and read about it, and am offering this code containing what I learned, in case it is of any use.

Under this PR, docs can be built locally with cargo doc as usual, but observing the new features requires instead using cargo +nightly rustdoc --all-features -- --cfg docsrs.

Stable alternatives include just running cargo doc with --all-features; however, the docs produced this way do not indicate which items require feature flags.

Closes #102.

Use the unstable feature doc_auto_cfg to document items' feature flags,
and configure docs.rs runs to compile all features.

For now, using this locally requires running
`cargo +nightly rustdoc --all-features -- --cfg docsrs`.
Copy link
Collaborator

@jeff-hiner jeff-hiner left a comment

Choose a reason for hiding this comment

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

Looks like a good change to me. Thank you!

@jeff-hiner jeff-hiner merged commit 232aa63 into emberian:master Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tokio interface documentation isn't being generated
2 participants