diff --git a/newsfragments/4236.fixed.md b/newsfragments/4236.fixed.md new file mode 100644 index 00000000000..f87d16941c7 --- /dev/null +++ b/newsfragments/4236.fixed.md @@ -0,0 +1 @@ +Declarative modules: do not discard doc comments on the `mod` node. \ No newline at end of file diff --git a/pyo3-macros-backend/src/module.rs b/pyo3-macros-backend/src/module.rs index 71d776bf350..c1e46276544 100644 --- a/pyo3-macros-backend/src/module.rs +++ b/pyo3-macros-backend/src/module.rs @@ -287,6 +287,7 @@ pub fn pymodule_module_impl(mut module: syn::ItemMod) -> Result { let initialization = module_initialization(&name, ctx); Ok(quote!( + #(#attrs)* #vis mod #ident { #(#items)* diff --git a/tests/ui/pymodule_missing_docs.rs b/tests/ui/pymodule_missing_docs.rs index 1b196fa65e0..ed7d772fafd 100644 --- a/tests/ui/pymodule_missing_docs.rs +++ b/tests/ui/pymodule_missing_docs.rs @@ -9,4 +9,9 @@ pub fn python_module(_m: &Bound<'_, PyModule>) -> PyResult<()> { Ok(()) } +#[cfg(feature = "experimental-declarative-modules")] +/// Some module documentation +#[pymodule] +pub mod declarative_python_module {} + fn main() {}