Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 7, 2025

The crate's feature flags, particularly the internal any_impl and any_zlib markers, lacked documentation. This PR adds comprehensive feature documentation that appears in cargo doc output.

Changes

  • Added document-features integration: Uses document-features crate to auto-generate feature documentation from Cargo.toml comments
  • Documented internal markers:
    • any_impl: Marker ensuring a backend is selected (auto-enabled by all backends)
    • any_zlib: Marker for C-based zlib backends (auto-enabled by zlib, zlib-ng, zlib-ng-compat, cloudflare_zlib)
  • Documented all user-facing backends: Added descriptions for rust_backend, zlib-rs, zlib, zlib-ng, zlib-ng-compat, zlib-default, cloudflare_zlib, and miniz-sys

Result

Feature documentation now appears in the crate docs under a dedicated "Feature Flags" section:

Feature documentation

[dependencies]
# Choose the fastest pure Rust backend
flate2 = { version = "1.1", features = ["zlib-rs"], default-features = false }

# Or use the default safe Rust backend
flate2 = "1.1"  # Uses rust_backend (miniz_oxide)
Original prompt

Find out what the any_impl and any_zlib features mean, and document them in detail.
Use the https://crates.io/crates/document-features crate (and set it up) so that documentation for the feature toggles is build into the cargo doc build.
While at it, document all user facing features as well.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add documentation for any_impl and any_zlib features Document feature flags using document-features crate Dec 7, 2025
Copilot AI requested a review from Byron December 7, 2025 06:36
- Add document-features crate as dependency
- Document all user-facing features with detailed descriptions
- Document any_impl and any_zlib internal features with clear warnings
- Add feature flags section to lib.rs documentation
- Features now automatically documented in cargo doc output

Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
@Byron Byron force-pushed the copilot/document-feature-toggles branch from cfb8486 to c9ba5a6 Compare December 7, 2025 07:58
@Byron
Copy link
Member

Byron commented Dec 7, 2025

I made document-features optional and reordered the docs a bit. They now look like this:

Screenshot 2025-12-07 at 08 56 45

Could @folkertdev and @jongiddy take a look and double check the docs? With your corrections and improvements, I think we will get to the next step quickly, which is to find a way to ensure #517 doesn't happen again (and is fixed with the next release).

Thank you 🙏.

@Byron Byron marked this pull request as ready for review December 7, 2025 08:00
@Byron Byron requested a review from jongiddy December 7, 2025 08:01
Copy link
Member

@Byron Byron left a comment

Choose a reason for hiding this comment

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

Looks good to me now, and with the documentation of the internal features I think a follow-up could expand on that, namely to explain why the split of features into any_impl and any_zlib is needed.

(Maybe it's also expected that #517 doesn't expose certain types anymore with zlib-rs)

@jongiddy
Copy link
Contributor

jongiddy commented Dec 7, 2025

The doc changes look very nice.

One unusual aspect of the features is that you can select a different backend without setting default-features = false to disable the default backend. Last time I checked, you could actually select any number of backend features and there is a priority order for which backend will be selected. I believe the backend selected is the first selected of these:

  • zlib-ng
  • zlib-rs
  • cloudflare_zlib
  • miniz_oxide

Also, not completely related to the doc changes, now that we have 2 Rust backends, using miniz_oxide rather than rust_backend as the preferred feature name would seem less ambiguous. Maybe rust_backend should be documented to select a Rust backend, with no guarantee of which one?

- make `document-features` optional
- reorder cargo features to make desirable ones more obvious
@Byron Byron force-pushed the copilot/document-feature-toggles branch from c9ba5a6 to a6a47a5 Compare December 7, 2025 14:16
@Byron
Copy link
Member

Byron commented Dec 7, 2025

Thanks for sharing @jongiddy! I have incorporated your notes, or so I hope, and the docs now render like so:

Screenshot 2025-12-07 at 15 16 30

I probably shouldn't have force-pushed though, and will try to avoid it in future revisions.

@jongiddy If you would approve, I'd merge this, knowing that changes to the zlib-rs docs can be made later as @folkertdev and I tackle #520 .

@Byron Byron enabled auto-merge December 7, 2025 14:19
@Byron Byron merged commit 6e25a3f into main Dec 7, 2025
29 checks passed
@Byron Byron deleted the copilot/document-feature-toggles branch December 7, 2025 15:51
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