From 6166e9bcad9953f57db4dabfecfcbfc1743b94f9 Mon Sep 17 00:00:00 2001 From: Joris Kleiber Date: Sun, 16 Jul 2023 14:10:42 +0200 Subject: [PATCH] process: fix `raw_arg` not showing up in docs (#5865) --- tokio/src/macros/cfg.rs | 12 ++++++++++++ tokio/src/process/mod.rs | 29 +++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/tokio/src/macros/cfg.rs b/tokio/src/macros/cfg.rs index 52ffc102bf3..a80e323cf43 100644 --- a/tokio/src/macros/cfg.rs +++ b/tokio/src/macros/cfg.rs @@ -25,6 +25,18 @@ macro_rules! cfg_windows { } } +/// Enables unstable Windows-specific code. +/// Use this macro instead of `cfg(windows)` to generate docs properly. +macro_rules! cfg_unstable_windows { + ($($item:item)*) => { + $( + #[cfg(all(any(all(doc, docsrs), windows), tokio_unstable))] + #[cfg_attr(docsrs, doc(cfg(all(windows, tokio_unstable))))] + $item + )* + } +} + /// Enables enter::block_on. macro_rules! cfg_block_on { ($($item:item)*) => { diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index d68a68995ec..41353c04adf 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -400,20 +400,21 @@ impl Command { self } - /// Append literal text to the command line without any quoting or escaping. - /// - /// This is useful for passing arguments to `cmd.exe /c`, which doesn't follow - /// `CommandLineToArgvW` escaping rules. - /// - /// **Note**: This is an [unstable API][unstable] but will be stabilised once - /// tokio's MSRV is sufficiently new. See [the documentation on - /// unstable features][unstable] for details about using unstable features. - #[cfg(windows)] - #[cfg(tokio_unstable)] - #[cfg_attr(docsrs, doc(cfg(all(windows, tokio_unstable))))] - pub fn raw_arg>(&mut self, text_to_append_as_is: S) -> &mut Command { - self.std.raw_arg(text_to_append_as_is); - self + cfg_unstable_windows! { + /// Append literal text to the command line without any quoting or escaping. + /// + /// This is useful for passing arguments to `cmd.exe /c`, which doesn't follow + /// `CommandLineToArgvW` escaping rules. + /// + /// **Note**: This is an [unstable API][unstable] but will be stabilised once + /// tokio's MSRV is sufficiently new. See [the documentation on + /// unstable features][unstable] for details about using unstable features. + /// + /// [unstable]: crate#unstable-features + pub fn raw_arg>(&mut self, text_to_append_as_is: S) -> &mut Command { + self.std.raw_arg(text_to_append_as_is); + self + } } /// Inserts or updates an environment variable mapping.