Skip to content

Commit fd18955

Browse files
Icxoludavidhewitt
authored andcommitted
add #[doc(hidden)] to the Rust module created by #[pymodule] (#4067)
* add `#[doc(hidden)]` to the Rust module created by `#[pymodule]` * add newsfragment
1 parent e174a04 commit fd18955

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

newsfragments/4067.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fixes `missing_docs` lint to trigger on documented `#[pymodule]` functions

pyo3-macros-backend/src/module.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ pub fn pymodule_function_impl(mut function: syn::ItemFn) -> Result<TokenStream>
324324

325325
Ok(quote! {
326326
#function
327+
#[doc(hidden)]
327328
#vis mod #ident {
328329
#initialization
329330
}

tests/test_compile_error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ fn test_compile_errors() {
5353
#[cfg(feature = "experimental-async")]
5454
#[cfg(any(not(Py_LIMITED_API), Py_3_10))] // to avoid PyFunctionArgument for &str
5555
t.compile_fail("tests/ui/invalid_cancel_handle.rs");
56+
t.pass("tests/ui/pymodule_missing_docs.rs");
5657
}

tests/ui/pymodule_missing_docs.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![deny(missing_docs)]
2+
//! Some crate docs
3+
4+
use pyo3::prelude::*;
5+
6+
/// Some module documentation
7+
#[pymodule]
8+
pub fn python_module(_m: &Bound<'_, PyModule>) -> PyResult<()> {
9+
Ok(())
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)