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

Make readonly fields visible in rustdoc #2

Closed
dtolnay opened this issue Apr 20, 2019 · 1 comment
Closed

Make readonly fields visible in rustdoc #2

dtolnay opened this issue Apr 20, 2019 · 1 comment

Comments

@dtolnay
Copy link
Owner

dtolnay commented Apr 20, 2019

By making them pub in the case of #[cfg(rustdoc)].

For example with the invocation from the readme:

#[readonly::make]
pub struct S {
    pub n: i32,
}

we will need to generate:

  #[repr(C)]
  pub struct S {
+     #[cfg(not(rustdoc))]
      n: i32,
+     #[cfg(rustdoc)]
+     pub n: i32,
  }

  #[repr(C)]
  pub struct ReadOnlyS {
      pub n: i32,
  }

  impl core::ops::Deref for S {
      type Target = ReadOnlyS;
      ...
  }

Currently blocked on rust-lang/rust#43781.

@dtolnay
Copy link
Owner Author

dtolnay commented Apr 21, 2019

Fixed in 11457e3 by requiring opt-in at the call site.

#[readonly::make(doc = mycratename_doc_cfg)]
pub struct MyStruct {...}

and in Cargo.toml:

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "mycratename_doc_cfg"]

@dtolnay dtolnay closed this as completed Apr 21, 2019
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

No branches or pull requests

1 participant