Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}
Loading