Skip to content

Fix feature docs not showing up on docs.rs#136

Merged
HyperCodec merged 3 commits intodevfrom
copilot/fix-docs-not-showing-on-docs-rs
Mar 2, 2026
Merged

Fix feature docs not showing up on docs.rs#136
HyperCodec merged 3 commits intodevfrom
copilot/fix-docs-not-showing-on-docs-rs

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Feature-gated items were not appearing with their feature annotations on docs.rs because the docsrs cfg was never passed and not all features were enabled during doc builds.

Changes

  • All three crates (genetic-rs, genetic-rs-common, genetic-rs-macros): Added [package.metadata.docs.rs] with all-features = true and rustdoc-args = ["--cfg", "docsrs"]; added [lints.rust] unexpected_cfgs to suppress unknown-cfg warnings for docsrs
  • genetic-rs-common/Cargo.toml: Replaced the partial features = ["crossover", "speciation"] with all-features = true
  • All source files: Replaced #![cfg_attr(docsrs, feature(doc_cfg))] with #![cfg_attr(docsrs, feature(doc_auto_cfg))] and removed all manual #[cfg_attr(docsrs, doc(cfg(feature = "...")))] per-item annotations — doc_auto_cfg automatically infers cfg requirements from existing #[cfg(...)] attributes, requiring no per-item maintenance going forward
Original prompt

This section details on the original issue you should resolve

<issue_title>fix feature docs not showing up on docs.rs</issue_title>
<issue_description>Probably should use the new #![cfg_attr(docsrs, feature(doc_cfg)]. Also add the following to Cargo.toml:

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@HyperCodec</author><body>
note that the merged `doc_cfg` might not be updated on older crates and dependencies, so might have to fallback to older nightly + `doc_auto_cfg` instead.</body></comment_new>
</comments>

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix feature docs not showing up on docs.rs Fix feature docs not showing up on docs.rs Mar 2, 2026
@HyperCodec
Copy link
Owner

@copilot since the publish workflow already uses nightly, can you see if you can get auto_doc_cfg (I think it was merged into doc_cfg) working? on some other crates it wouldn't work because the dependencies still used the old feature name, but since this one has a light dependency footprint it might just work. much more convenient to maintain than throwing a bunch of #[cfg_attr(docsrs, doc(cfg(feature = "..."))] everywhere.

Co-authored-by: HyperCodec <72839119+HyperCodec@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 2, 2026

@copilot since the publish workflow already uses nightly, can you see if you can get auto_doc_cfg (I think it was merged into doc_cfg) working? on some other crates it wouldn't w...

Done in 953f264. Replaced feature(doc_cfg) + all the manual #[cfg_attr(docsrs, doc(cfg(feature = "...")))] annotations across all four source files with a single #![cfg_attr(docsrs, feature(doc_auto_cfg))] crate-level attribute. doc_auto_cfg picks up the existing #[cfg(feature = "...")] attributes automatically, so no per-item maintenance is needed going forward.

Copy link
Owner

@HyperCodec HyperCodec left a comment

Choose a reason for hiding this comment

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

LGTM, though can't properly test until I set up a codespace or check locally.

@HyperCodec HyperCodec marked this pull request as ready for review March 2, 2026 13:22
@HyperCodec HyperCodec merged commit 2100dba into dev Mar 2, 2026
3 checks passed
@HyperCodec HyperCodec deleted the copilot/fix-docs-not-showing-on-docs-rs branch March 2, 2026 13:22
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.

2 participants