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

Macros doc(cfg) workarounds #2225

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

dekellum
Copy link
Contributor

@dekellum dekellum commented Feb 6, 2020

Motivation

Attempted fix for #2075, see also #2075 (comment).

Solution

This tries to work within the 0.2 approach of using doc(cfg(feature = "…")) by adding an additional doc(cfg) to ensure the macros feature requirement is included in rustdoc.

Then it adds some plain-english rustdoc to the descriptions of test and main macro options to explain the feature dependencies on those. There was previously some mixup with what macros these options (and associated usage examples) were applied, so that is also fixed here.

To test this locally, one can use the following:

RUSTDOCFLAGS="--cfg docsrs" cargo doc --no-deps --open --all-features

Note that this results in the following rustdoc generated output on these macros:

This is supported on feature="rt-threaded" and feature="macros" only.

This is not entirely correct, but its better then what it is in current (0.2.11) docs:

This is supported on feature="rt-threaded" only.

I do not see a way to entirely override the doc(cfg) without unwinding the whole set of cfg_* macros which seems rather invasive. Perhaps this PR can improve 0.2 as a stopgap, and the approach of applying doc(cfg) can be more generally revisited for 0.3/1.0?

This is a workaround for the fact that the doc(cfg) from outer cfg_*
macros doesn't get applied correctly. Its included in the rt-threaded
branch only, which is what is used for doc.rs via all-features.
Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

Thanks

@carllerche carllerche merged commit a4c4ac2 into tokio-rs:master Feb 26, 2020
fl9 pushed a commit to fl9/tokio that referenced this pull request Dec 10, 2020
Darksonn pushed a commit that referenced this pull request Dec 19, 2020
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.

None yet

2 participants