Skip to content

Commit

Permalink
Re-export __doc__ in __init__.py for pure Rust project
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Oct 1, 2021
1 parent 19a8b02 commit 031d23e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/module_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,11 @@ pub fn write_bindings_module(
// Reexport the shared library as if it were the top level module
writer.add_bytes(
&module.join("__init__.py"),
format!("from .{} import *\n", module_name).as_bytes(),
format!(
"from .{module_name} import *\n\n__doc__ = {module_name}.__doc__\n",
module_name = module_name
)
.as_bytes(),
)?;
let type_stub = rust_module.join(format!("{}.pyi", module_name));
if type_stub.exists() {
Expand Down
1 change: 1 addition & 0 deletions test-crates/pyo3-pure/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ impl DummyClass {
}
}

/// module level doc string
#[pymodule]
fn pyo3_pure(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<DummyClass>()?;
Expand Down

0 comments on commit 031d23e

Please sign in to comment.