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

Fix docs of derived Lens #1523

Merged
merged 1 commit into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ You can find its changes [documented below](#070---2021-01-01).

### Fixed

- Fixed docs of derived Lens ([(#1523)] by [@Maan2003])

### Visual

### Docs
Expand Down Expand Up @@ -590,6 +592,7 @@ Last release without a changelog :(
[#1448]: https://github.com/linebender/druid/pull/1448
[#1463]: https://github.com/linebender/druid/pull/1463
[#1452]: https://github.com/linebender/druid/pull/1452
[#1523]: https://github.com/linebender/druid/pull/1523

[Unreleased]: https://github.com/linebender/druid/compare/v0.6.0...master
[0.6.0]: https://github.com/linebender/druid/compare/v0.5.0...v0.6.0
Expand Down
7 changes: 5 additions & 2 deletions druid-derive/src/lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ fn derive_struct(input: &syn::DeriveInput) -> Result<proc_macro2::TokenStream, s
// Define lens types for each field
let defs = fields.iter().filter(|f| !f.attrs.ignore).map(|f| {
let field_name = &f.ident.unwrap_named();

let docs = format!(
"Lens for the field `{}` on [`{1}`](super::{1})",
field_name, ty
);
quote! {
/// Lens for the field on #ty
#[doc = #docs]
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone)]
pub struct #field_name;
Expand Down