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

[FEATURE REQUEST] Properties macro: Document properties better #1236

Open
sophie-h opened this issue Nov 29, 2023 · 1 comment
Open

[FEATURE REQUEST] Properties macro: Document properties better #1236

sophie-h opened this issue Nov 29, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@sophie-h
Copy link
Contributor

I'm using cargo docs online for people to work on Loupe and I'm sometimes using it myself.

With using the Properties macro the docs got a bit worse. Before, getters also had documentation. Now I have to lookup the field in the struct to see it's documentation.

Is it possible to either link to the field in getter/setter docs or do create an overview of all properties for the object or maybe both?

@sophie-h sophie-h added the enhancement New feature or request label Nov 29, 2023
@SeaDve
Copy link
Contributor

SeaDve commented Dec 1, 2023

I also have the same issue with exposing properties to a public object in a library. Specifically, I had to resort to manually implementing the properties in https://github.com/SeaDve/plotters-gtk4/blob/main/src/paintable.rs to improve the documentation.

I'm wondering if the field documentation on the imp struct can be forwarded to the generated setters and getters docs. For example,

#[derive(glib::Properties)]
#[properties(wrapper_type = Paintable)]
pub struct PaintableImp {
    /// The width of the paintable.
    #[property(get, set)]
    pub(super) width: OnceCell<u32>,
    /// The height of the paintable.
    #[property(get, set)]
    pub(super) height: OnceCell<u32>,
}

will generate the following getters:

impl Paintable {
    /// The width of the paintable.
    pub fn width(&self) -> u32 {
        ...
    }

    /// The height of the paintable.
    pub fn height(&self) -> u32 {
        ...
    }
}

Not sure though of a great API to specialize the documentation for the setters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants