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

codegen/enum: Do not generate doc(cfg) on match arms #994

Merged
merged 4 commits into from
Nov 19, 2020

Conversation

MarijnS95
Copy link
Contributor

Simplify some duplicate code around cfg and version handling, and fix the following warnings when compiling with the dox feature:

warning: unused doc comment
--> gstreamer/src/auto/enums.rs:761:41
    |
761 |             #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
762 |             66817 => EventType::InstantRateSyncTime,
    |             --------------------------------------- rustdoc does not generate documentation for match arms

Fixes: c63d1fa ("Generate doc cfg attributes for more beautiful docs")

    warning: unused doc comment
    --> gstreamer/src/auto/enums.rs:761:41
        |
    761 |             #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
        |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    762 |             66817 => EventType::InstantRateSyncTime,
        |             --------------------------------------- rustdoc does not generate documentation for match arms

Fixes: c63d1fa ("Generate doc cfg attributes for more beautiful docs")
@MarijnS95
Copy link
Contributor Author

Should this be dox to match not_version_condition_no_dox?

Solves warnings of the following kind in gtk-rs:

    warning: unused doc comment
       --> gtk/src/auto/window.rs:309:37
        |
    309 |           #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
        |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    310 | /         {
    311 | |             if let Some(ref focus_on_click) = self.focus_on_click {
    312 | |                 properties.push(("focus-on-click", focus_on_click));
    313 | |             }
    314 | |         }
        | |_________- rustdoc does not generate documentation for expressions

Also remove the surrounding expression block and convoluted indentation
logic: if {} is also an expression block that can take attributes.
@MarijnS95
Copy link
Contributor Author

Switching attributes to work directly on ifs was worth a shot, but that apparently only landed on 1.43 whereas gtk-rs's MSRV is https://github.com/gtk-rs/gtk-rs/runs/1420232906. If we can't bump this on the short term I'll push the long way around, which is still in local reflog 😉

@sdroege
Copy link
Member

sdroege commented Nov 19, 2020

Switching attributes to work directly on ifs was worth a shot, but that apparently only landed on 1.43 whereas gtk-rs's MSRV is https://github.com/gtk-rs/gtk-rs/runs/1420232906. If we can't bump this on the short term I'll push the long way around, which is still in local reflog wink

We're updating to 1.48 today or tomorrow, so feel free to add back that change if it makes anything nicer :)

@MarijnS95
Copy link
Contributor Author

We're updating to 1.48 today or tomorrow, so feel free to add back that change if it makes anything nicer :)

Awesome! The change is still here, I held off removing it until receiving this reply 😁. Wasn't expecting an immediate jump from 1.40 all the way to 1.48 though, but that definitely makes everything a lot nicer.

@sdroege
Copy link
Member

sdroege commented Nov 19, 2020

Then let's get this in here now, and regenerate everything later/tomorrow as part of moving to 1.48.

@sdroege sdroege merged commit 1ae9689 into gtk-rs:master Nov 19, 2020
@MarijnS95 MarijnS95 deleted the doc_cfg branch November 19, 2020 09:24
gstreamer-github pushed a commit to sdroege/gstreamer-rs that referenced this pull request Nov 19, 2020
This and earlier PRs enable generation doc(cfg()) attributes on symbols
to show cfg requirements directly in the documentation.
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