Skip to content

Commit

Permalink
Merge pull request #639 from messense/reexport-doc
Browse files Browse the repository at this point in the history
Re-export `__doc__` in `__init__.py` for pure Rust project
  • Loading branch information
messense authored Oct 1, 2021
2 parents f8be2b7 + 03e9c54 commit 87ed273
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* Fixed module documentation missing bug of pyo3 bindings in [#639](https://github.com/PyO3/maturin/pull/639)

## [0.11.4] - 2021-09-28

* Autodetect PyPy executables in [#617](https://github.com/PyO3/maturin/pull/617)
Expand Down
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 87ed273

Please sign in to comment.