add `#[doc(hidden)]` to the Rust module created by `#[pymodule]` (#4067)

* add `#[doc(hidden)]` to the Rust module created by `#[pymodule]`

* add newsfragment
This commit is contained in:
Icxolu 2024-04-12 08:34:08 +02:00 committed by David Hewitt
parent e174a04bb3
commit fd18955da8
4 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1 @@
fixes `missing_docs` lint to trigger on documented `#[pymodule]` functions

View File

@ -324,6 +324,7 @@ pub fn pymodule_function_impl(mut function: syn::ItemFn) -> Result<TokenStream>
Ok(quote! {
#function
#[doc(hidden)]
#vis mod #ident {
#initialization
}

View File

@ -53,4 +53,5 @@ fn test_compile_errors() {
#[cfg(feature = "experimental-async")]
#[cfg(any(not(Py_LIMITED_API), Py_3_10))] // to avoid PyFunctionArgument for &str
t.compile_fail("tests/ui/invalid_cancel_handle.rs");
t.pass("tests/ui/pymodule_missing_docs.rs");
}

View File

@ -0,0 +1,12 @@
#![deny(missing_docs)]
//! Some crate docs
use pyo3::prelude::*;
/// Some module documentation
#[pymodule]
pub fn python_module(_m: &Bound<'_, PyModule>) -> PyResult<()> {
Ok(())
}
fn main() {}