From b852142b8eb8dfa25ce648d0f975329e1f1e9bbe Mon Sep 17 00:00:00 2001 From: Jonas Bushart Date: Sat, 20 Sep 2025 00:10:11 +0200 Subject: [PATCH] Generate macro expansion in rustdoc A recent rust nightly added the ability to show macro expansions in the rustdoc output. Since this crate uses macros for many trait implementations, this is useful for users trying to understand the macro output. https://github.com/rust-lang/rust/pull/137229 --- serde_with/CHANGELOG.md | 5 +++++ serde_with/Cargo.toml | 5 ++++- serde_with_macros/CHANGELOG.md | 5 +++++ serde_with_macros/Cargo.toml | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/serde_with/CHANGELOG.md b/serde_with/CHANGELOG.md index b80861bc..a1e3a391 100644 --- a/serde_with/CHANGELOG.md +++ b/serde_with/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +* Show macro expansion in the docs.rs generated rustdoc. + Since macros are used to generate trait implementations, this is useful to understand the exact generated code. + ## [3.14.0] - 2025-06-30 ### Added diff --git a/serde_with/Cargo.toml b/serde_with/Cargo.toml index cc41df75..af4270d4 100644 --- a/serde_with/Cargo.toml +++ b/serde_with/Cargo.toml @@ -266,10 +266,13 @@ all-features = true rustdoc-args = [ # Enable doc_cfg showing the required features. "--cfg=docsrs", + "-Zunstable-options", # Generate links to definition in rustdoc source code pages # https://github.com/rust-lang/rust/pull/84176 - "-Zunstable-options", "--generate-link-to-definition", + # Generate buttons to show macro expansions in the rustdoc output. + # https://github.com/rust-lang/rust/pull/137229 + "--generate-macro-expansion", # Link to the stable documentation for core/alloc/std/proc_macro even though docs.rs uses nightly. # https://github.com/rust-lang/docs.rs/issues/506#issuecomment-2670501688 "--extern-html-root-url=core=https://doc.rust-lang.org", diff --git a/serde_with_macros/CHANGELOG.md b/serde_with_macros/CHANGELOG.md index 00f1b93a..d18add50 100644 --- a/serde_with_macros/CHANGELOG.md +++ b/serde_with_macros/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +* Show macro expansion in the docs.rs generated rustdoc. + Since macros are used to generate trait implementations, this is useful to understand the exact generated code. + ## [3.14.0] - 2025-06-30 ### Added diff --git a/serde_with_macros/Cargo.toml b/serde_with_macros/Cargo.toml index 3c0c4d28..ff3d3d9d 100644 --- a/serde_with_macros/Cargo.toml +++ b/serde_with_macros/Cargo.toml @@ -61,6 +61,23 @@ version-sync = "0.9.1" [package.metadata.docs.rs] all-features = true +rustdoc-args = [ + # Enable doc_cfg showing the required features. + "--cfg=docsrs", + "-Zunstable-options", + # Generate links to definition in rustdoc source code pages + # https://github.com/rust-lang/rust/pull/84176 + "--generate-link-to-definition", + # Generate buttons to show macro expansions in the rustdoc output. + # https://github.com/rust-lang/rust/pull/137229 + "--generate-macro-expansion", + # Link to the stable documentation for core/alloc/std/proc_macro even though docs.rs uses nightly. + # https://github.com/rust-lang/docs.rs/issues/506#issuecomment-2670501688 + "--extern-html-root-url=core=https://doc.rust-lang.org", + "--extern-html-root-url=alloc=https://doc.rust-lang.org", + "--extern-html-root-url=std=https://doc.rust-lang.org", + "--extern-html-root-url=proc_macro=https://doc.rust-lang.org", +] [package.metadata.release] pre-release-replacements = [