Jij-Inc / pyo3-stub-gen

Stub file (*.pyi) generator for PyO3
Apache License 2.0
61 stars 12 forks source link

Generate Google-style docstring for struct fields/getters #70

Open op8867555 opened 3 months ago

op8867555 commented 3 months ago

Hi,

I'm trying to generate docs (with mkdocstrings + Griffe) for some Rust structs like the one below:

/// Some Object O
#[gen_stub_pyclass]
#[pyclass(get_all)]
struct O {
   /// Some value
   value: u32,
}

#[gen_stub_pymethods]
#[pymethods]
impl O {
   /// Extra value
   #[getter]
   pub fn extra(&self) -> u32 {0}
}

This generates something like:

class O:
    r'''
    Some Object O
    '''
    value: int
    extra: int

It would be helpful if we collect the documentation from fields/getter methods and aggregate them into one single docstring:

r'''
Some Object O

Attributes:
    value: Some value
    extra: Extra value
'''

I'm not sure if this feature would be out of scope of this crate or not, if so, please free feel to close this issue.

abrisco commented 3 months ago

This would be fantastic!