From 3d6356223ed84d4908d6a3902d21c0af98389958 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Thu, 17 Dec 2020 03:00:48 +0000 Subject: [PATCH] docs: fix warnings --- .github/workflows/ci.yml | 3 +++ guide/src/class.md | 2 +- guide/src/exception.md | 1 + guide/src/function.md | 16 +++++++++------- src/types/module.rs | 2 +- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9491a15f..26ff6615 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/guide/src/class.md b/guide/src/class.md index bd3ad360..6e723ad2 100644 --- a/guide/src/class.md +++ b/guide/src/class.md @@ -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. diff --git a/guide/src/exception.md b/guide/src/exception.md index 20c21da7..c8f7df0f 100644 --- a/guide/src/exception.md +++ b/guide/src/exception.md @@ -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 diff --git a/guide/src/function.md b/guide/src/function.md index 9661d2bf..6266ceca 100644 --- a/guide/src/function.md +++ b/guide/src/function.md @@ -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)`. \ No newline at end of file +`#[pyfunction]` and a `PyModule`: `wrap_pyfunction!(rust_fun, module)`. diff --git a/src/types/module.rs b/src/types/module.rs index baa343f6..11d34f1c 100644 --- a/src/types/module.rs +++ b/src/types/module.rs @@ -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,