Declarative modules: make sure to emit doc comments and other attributes (#4236)

* Declarative modules: make sure to emmit doc comments and other attributes

* Adds a test

* Apply suggestions from code review

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
This commit is contained in:
Thomas Tanon 2024-06-06 23:19:37 +02:00 committed by GitHub
parent c644c0b0b8
commit 74619143b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1 @@
Declarative modules: do not discard doc comments on the `mod` node.

View File

@ -287,6 +287,7 @@ pub fn pymodule_module_impl(mut module: syn::ItemMod) -> Result<TokenStream> {
let initialization = module_initialization(&name, ctx);
Ok(quote!(
#(#attrs)*
#vis mod #ident {
#(#items)*

View File

@ -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() {}