Rename add_module to add_submodule, documentation fixes.

This commit is contained in:
Sebastian Pütz 2020-09-04 09:02:49 +02:00
parent 795c054511
commit 4aae523e54
2 changed files with 6 additions and 6 deletions

View file

@ -73,7 +73,7 @@ fn submodule(_py: Python, module: &PyModule) -> PyResult<()> {
#[pymodule]
fn supermodule(_py: Python, module: &PyModule) -> PyResult<()> {
module.add_module(wrap_pymodule!(submodule))?;
module.add_submodule(wrap_pymodule!(submodule))?;
Ok(())
}

View file

@ -197,7 +197,7 @@ impl PyModule {
/// ```
///
/// **This function will be deprecated in the next release. Please use the specific
/// [add_function] and [add_module] functions instead.**
/// [add_function] and [add_submodule] functions instead.**
pub fn add_wrapped<'a, T>(&'a self, wrapper: &impl Fn(Python<'a>) -> T) -> PyResult<()>
where
T: IntoPyCallbackOutput<PyObject>,
@ -207,20 +207,20 @@ impl PyModule {
self.add(name.extract(self.py())?, function)
}
/// Adds a (sub)module to a module.
/// Add a submodule to a module.
///
/// Use this together with `#[pymodule]` and [wrap_pymodule!].
///
/// ```rust,ignore
/// m.add_module(wrap_pymodule!(utils));
/// m.add_submodule(wrap_pymodule!(utils));
/// ```
pub fn add_module<'a>(&'a self, wrapper: &impl Fn(Python<'a>) -> PyObject) -> PyResult<()> {
pub fn add_submodule<'a>(&'a self, wrapper: &impl Fn(Python<'a>) -> PyObject) -> PyResult<()> {
let module = wrapper(self.py());
let name = module.getattr(self.py(), "__name__")?;
self.add(name.extract(self.py())?, module)
}
/// Adds a function to a module, using the functions __name__ as name.
/// Add a function to a module.
///
/// Use this together with the`#[pyfunction]` and [wrap_pyfunction!].
///