about summary refs log tree commit diff
path: root/src/doc/rustdoc
diff options
context:
space:
mode:
authorBenjamin Sago <ogham@users.noreply.github.com>2018-05-29 11:31:14 +0200
committerGitHub <noreply@github.com>2018-05-29 11:31:14 +0200
commit9fcc61bf9f2148ede0e97537f4b1ecc80e675f09 (patch)
tree0a89808552c63196cc34edae27d8003fa5768fd7 /src/doc/rustdoc
parent4f6d9bf2099c83f365bb0b3cf02091b4737c2052 (diff)
downloadrust-9fcc61bf9f2148ede0e97537f4b1ecc80e675f09.tar.gz
rust-9fcc61bf9f2148ede0e97537f4b1ecc80e675f09.zip
Mention spec and indented blocks in doctest docs
This commit adds a new section to the Documentation Test docs, which briefly mentions indented code blocks, and links to the CommonMark specification for both.

I’m not sure about saying "fenced code blocks the more popular choice in the Rust community” because it seems like I’m speaking for everyone, but I can’t think of a better way to phrase it!
Diffstat (limited to 'src/doc/rustdoc')
-rw-r--r--src/doc/rustdoc/src/documentation-tests.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md
index fd7d1713ca5..61cfebb97e7 100644
--- a/src/doc/rustdoc/src/documentation-tests.md
+++ b/src/doc/rustdoc/src/documentation-tests.md
@@ -284,3 +284,27 @@ environment that has no network access.
 compiles, then the test will fail. However please note that code failing
 with the current Rust release may work in a future release, as new features
 are added.
+
+## Syntax reference
+
+The *exact* syntax for code blocks, including the edge cases, can be found
+in the [Fenced Code Blocks](https://spec.commonmark.org/0.28/#fenced-code-blocks)
+section of the CommonMark specification.
+
+Rustdoc also accepts *indented* code blocks as an alternative to fenced
+code blocks: instead of surrounding your code with three backticks, you
+can indent each line by four or more spaces.
+
+``````markdown
+    let foo = "foo";
+    assert_eq!(foo, "foo");
+``````
+
+These, too, are documented in the CommonMark specification, in the
+[Indented Code Blocks](https://spec.commonmark.org/0.28/#indented-code-blocks)
+section.
+
+However, it's preferable to use fenced code blocks over indented code blocks.
+Not only are fenced code blocks the more popular choice in the Rust community,
+but there is no way to use directives such as `ignore` or `should_panic` with
+indented code blocks.