about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-13 16:02:20 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-13 16:02:20 +0200
commitdc0707a4d85f44d2b714d02be0e78cb1f9cc8fbc (patch)
treeb7158e73da78f4d5daf0a22fe2dcde79ba7bd033
parenta6620a45bd29575cce67b6a0ab2956aef105e324 (diff)
downloadrust-dc0707a4d85f44d2b714d02be0e78cb1f9cc8fbc.tar.gz
rust-dc0707a4d85f44d2b714d02be0e78cb1f9cc8fbc.zip
Add another example for escaped `#` character in doctest in rustdoc book
-rw-r--r--src/doc/rustdoc/src/write-documentation/documentation-tests.md14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/write-documentation/documentation-tests.md b/src/doc/rustdoc/src/write-documentation/documentation-tests.md
index e6b15e0dbd3..4084c1d962a 100644
--- a/src/doc/rustdoc/src/write-documentation/documentation-tests.md
+++ b/src/doc/rustdoc/src/write-documentation/documentation-tests.md
@@ -191,6 +191,20 @@ We can document it by escaping the initial `#`:
 /// ## bar # baz";
 ```
 
+Here is an example with a macro rule which matches on tokens starting with `#`:
+
+`````rust,no_run
+/// ```
+/// macro_rules! ignore { (##tag) => {}; }
+/// ignore! {
+///     ###tag
+/// }
+/// ```
+# fn f() {}
+`````
+
+As you can see, the rule is expecting two `#`, so when calling it, we need to add an extra `#`
+because the first one is used as escape.
 
 ## Using `?` in doc tests