Skip to content

Commit

Permalink
Declarative modules: make sure to emit doc comments and other attribu…
Browse files Browse the repository at this point in the history
…tes (#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>
  • Loading branch information
Tpt and davidhewitt authored Jun 6, 2024
1 parent c644c0b commit 7461914
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/4236.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Declarative modules: do not discard doc comments on the `mod` node.
1 change: 1 addition & 0 deletions pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*

Expand Down
5 changes: 5 additions & 0 deletions tests/ui/pymodule_missing_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 7461914

Please sign in to comment.