docs: fix warnings

This commit is contained in:
David Hewitt 2020-12-17 03:00:48 +00:00
parent e245f5239a
commit 3d6356223e
5 changed files with 15 additions and 9 deletions

View File

@ -84,6 +84,9 @@ jobs:
name: Prepare LD_LIBRARY_PATH (Ubuntu only)
run: echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
- name: Build docs
run: cargo doc --features "num-bigint num-complex" --verbose --target ${{ matrix.platform.rust-target }}
- name: Build without default features
run: cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}

View File

@ -136,7 +136,7 @@ The `#[pyclass]` macro accepts the following parameters:
The performance improvement applies to types that are often created and deleted in a row,
so that they can benefit from a freelist. `XXX` is a number of items for the free list.
* `gc` - Classes with the `gc` parameter participate in Python garbage collection.
If a custom class contains references to other Python objects that can be collected, the [`PyGCProtocol`] trait has to be implemented.
If a custom class contains references to other Python objects that can be collected, the [`PyGCProtocol`](https://docs.rs/pyo3/latest/pyo3/class/gc/trait.PyGCProtocol.html) trait has to be implemented.
* `weakref` - Adds support for Python weak references.
* `extends=BaseType` - Use a custom base class. The base `BaseType` must implement `PyTypeInfo`.
* `subclass` - Allows Python classes to inherit from this class.

View File

@ -225,3 +225,4 @@ defines exceptions for several standard library modules.
[`PyErr`]: https://docs.rs/pyo3/latest/pyo3/struct.PyErr.html
[`PyErr::from_instance`]: https://docs.rs/pyo3/latest/pyo3/struct.PyErr.html#method.from_instance
[`Python::is_instance`]: https://docs.rs/pyo3/latest/pyo3/struct.Python.html#method.is_instance
[`PyAny::is_instance`]: https://docs.rs/pyo3/latest/pyo3/struct.PyAny.html#method.is_instance

View File

@ -182,13 +182,13 @@ the following:
### Calling Python functions in Rust
You can pass Python `def`'d functions and built-in functions to Rust functions `[PyFunction]`
corresponds to regular Python functions while `[PyCFunction]` describes built-ins such as
You can pass Python `def`'d functions and built-in functions to Rust functions [`PyFunction`]
corresponds to regular Python functions while [`PyCFunction`] describes built-ins such as
`repr()`.
You can also use [`PyAny::is_callable`] to check if you have a callable object. `is_callable` will
return `true` for functions (including lambdas), methods and objects with a `__call__` method.
You can call the object with [`PyAny::call`] with the args as first parameter and the kwargs
You can also use [`PyAny::is_callable`] to check if you have a callable object. `is_callable` will
return `true` for functions (including lambdas), methods and objects with a `__call__` method.
You can call the object with [`PyAny::call`] with the args as first parameter and the kwargs
(or `None`) as second parameter. There are also [`PyAny::call0`] with no args and [`PyAny::call1`]
with only positional args.
@ -208,6 +208,8 @@ in Python code.
[`PyAny::call1`]: https://docs.rs/pyo3/latest/pyo3/struct.PyAny.html#tymethod.call1
[`PyObject`]: https://docs.rs/pyo3/latest/pyo3/type.PyObject.html
[`wrap_pyfunction!`]: https://docs.rs/pyo3/latest/pyo3/macro.wrap_pyfunction.html
[`PyFunction`]: https://docs.rs/pyo3/0.12.4/pyo3/types/struct.PyFunction.html
[`PyCFunction`]: https://docs.rs/pyo3/0.12.4/pyo3/types/struct.PyCFunction.html
### Accessing the module of a function
@ -255,7 +257,7 @@ fn module_with_fn(py: Python, m: &PyModule) -> PyResult<()> {
## Accessing the FFI functions
In order to make Rust functions callable from Python, PyO3 generates a
In order to make Rust functions callable from Python, PyO3 generates a
`extern "C" Fn(slf: *mut PyObject, args: *mut PyObject, kwargs: *mut PyObject) -> *mut Pyobject`
function and embeds the call to the Rust function inside this FFI-wrapper function. This
wrapper handles extraction of the regular arguments and the keyword arguments from the input
@ -263,4 +265,4 @@ wrapper handles extraction of the regular arguments and the keyword arguments fr
offers the `raw_pycfunction!()` macro to get the identifier of this generated wrapper.
The `wrap_pyfunction` macro can be used to directly get a `PyCFunction` given a
`#[pyfunction]` and a `PyModule`: `wrap_pyfunction!(rust_fun, module)`.
`#[pyfunction]` and a `PyModule`: `wrap_pyfunction!(rust_fun, module)`.

View File

@ -212,7 +212,7 @@ impl PyModule {
/// ```
///
/// **This function will be deprecated in the next release. Please use the specific
/// [add_function] and [add_submodule] functions instead.**
/// [PyModule::add_function] and [PyModule::add_submodule] functions instead.**
pub fn add_wrapped<'a, T>(&'a self, wrapper: &impl Fn(Python<'a>) -> T) -> PyResult<()>
where
T: IntoPyCallbackOutput<PyObject>,