Skip to content

Commit

Permalink
add more submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed Dec 1, 2023
1 parent 5f8767b commit 3d57dd0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@ use pyo3::prelude::*;
#[pymodule]
fn pdoc_pyo3_sample_library(py: Python<'_>, m: &PyModule) -> PyResult<()> {

let child_module = PyModule::new(py, "child_module")?;
child_module.add_function(wrap_pyfunction!(func, child_module)?)?;
m.add_submodule(child_module)?;
let submodule = PyModule::new(py, "submodule")?;
submodule.add_function(wrap_pyfunction!(func, submodule)?)?;
m.add_submodule(submodule)?;

let subsubmodule = PyModule::new(py, "subsubmodule")?;
subsubmodule.add_function(wrap_pyfunction!(func, subsubmodule)?)?;
submodule.add_submodule(subsubmodule)?;

let explicit_submodule = PyModule::new(py, "explicit_submodule")?;
explicit_submodule.add_function(wrap_pyfunction!(func, explicit_submodule)?)?;
m.add_submodule(explicit_submodule)?;
py.import("sys")?
.getattr("modules")?
.set_item("pdoc_pyo3_sample_library.explicit_submodule", explicit_submodule)?;

Ok(())
}
Expand Down

0 comments on commit 3d57dd0

Please sign in to comment.