Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-export __doc__ in __init__.py for pure Rust project #639

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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