Skip to content

Commit

Permalink
add #[doc(hidden)] to the Rust module created by #[pymodule] (#4067)
Browse files Browse the repository at this point in the history
* add `#[doc(hidden)]` to the Rust module created by `#[pymodule]`

* add newsfragment
  • Loading branch information
Icxolu authored and davidhewitt committed Apr 16, 2024
1 parent e174a04 commit fd18955
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions newsfragments/4067.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fixes `missing_docs` lint to trigger on documented `#[pymodule]` functions
1 change: 1 addition & 0 deletions pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ pub fn pymodule_function_impl(mut function: syn::ItemFn) -> Result<TokenStream>

Ok(quote! {
#function
#[doc(hidden)]
#vis mod #ident {
#initialization
}
Expand Down
1 change: 1 addition & 0 deletions tests/test_compile_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
12 changes: 12 additions & 0 deletions tests/ui/pymodule_missing_docs.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit fd18955

Please sign in to comment.