From de974f3d71b8f0b04b0eca24f96ca1a59b3bb70d Mon Sep 17 00:00:00 2001 From: Antonio Yang Date: Sat, 23 May 2026 18:02:26 +0800 Subject: [PATCH] test: add test case about hinden doc Developer still can use doc with // in the fields, and the doc will not be part of the exmaple. We make a testcase such that people can esier to know this. --- lib/src/lib.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 5b3d65f..961e758 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -265,6 +265,31 @@ a = 0 # Config.b should be a string b = "" +"# + ); + } + + #[test] + fn hinden_doc() { + #[derive(TomlExample, Deserialize, Default, PartialEq, Debug)] + #[allow(dead_code)] + struct Config { + /// Config.a should be a number + // This doc will be hiddend not in the example + a: usize, + + // NOTE: This note is only shown in the code + /// Config.b should be a string + b: String, + } + assert_eq!( + Config::toml_example(), + r#"# Config.a should be a number +a = 0 + +# Config.b should be a string +b = "" + "# ); }