Skip to content

Commit 221dca2

Browse files
committed
fix(#1904): update doc tests to use playground as the crate name
This updates the Documentation Testing (21.2) chapter to assume a crate name of `playground` instead of `doccomments`. This allows for the code contained within to be copy-pasted directly into play.rust-lang.org to run; anyone who would want to reproduce this locally would want to create a `playground` library. Fixes #1904.
1 parent 21f4e32 commit 221dca2

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

po/es.po

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14221,11 +14221,11 @@ msgid ""
1422114221
"///\n"
1422214222
"/// The next lines present detailed documentation. Code blocks start with\n"
1422314223
"/// triple backquotes and have implicit `fn main()` inside\n"
14224-
"/// and `extern crate <cratename>`. Assume we're testing `doccomments` "
14225-
"crate:\n"
14224+
"/// and `extern crate <cratename>`. Assume we're testing a `playground` library\n"
14225+
"/// crate or using the Playground's Test action:\n"
1422614226
"///\n"
1422714227
"/// ```\n"
14228-
"/// let result = doccomments::add(2, 3);\n"
14228+
"/// let result = playground::add(2, 3);\n"
1422914229
"/// assert_eq!(result, 5);\n"
1423014230
"/// ```\n"
1423114231
msgstr ""
@@ -14240,7 +14240,7 @@ msgid ""
1424014240
"/// # Examples\n"
1424114241
"///\n"
1424214242
"/// ```\n"
14243-
"/// let result = doccomments::div(10, 2);\n"
14243+
"/// let result = playground::div(10, 2);\n"
1424414244
"/// assert_eq!(result, 5);\n"
1424514245
"/// ```\n"
1424614246
"///\n"
@@ -14250,7 +14250,7 @@ msgid ""
1425014250
"///\n"
1425114251
"/// ```rust,should_panic\n"
1425214252
"/// // panics on division by zero\n"
14253-
"/// doccomments::div(10, 0);\n"
14253+
"/// playground::div(10, 0);\n"
1425414254
"/// ```\n"
1425514255
msgstr ""
1425614256

@@ -14285,7 +14285,7 @@ msgid ""
1428514285
"/// # // hidden lines start with `#` symbol, but they're still compilable!\n"
1428614286
"/// # fn try_main() -> Result<(), String> { // line that wraps the body "
1428714287
"shown in doc\n"
14288-
"/// let res = doccomments::try_div(10, 2)?;\n"
14288+
"/// let res = playground::try_div(10, 2)?;\n"
1428914289
"/// # Ok(()) // returning from try_main\n"
1429014290
"/// # }\n"
1429114291
"/// # fn main() { // starting main that'll unwrap()\n"

po/ja.po

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16185,11 +16185,11 @@ msgid ""
1618516185
"///\n"
1618616186
"/// The next lines present detailed documentation. Code blocks start with\n"
1618716187
"/// triple backquotes and have implicit `fn main()` inside\n"
16188-
"/// and `extern crate <cratename>`. Assume we're testing `doccomments` "
16189-
"crate:\n"
16188+
"/// and `extern crate <cratename>`. Assume we're testing a `playground` library\n"
16189+
"/// crate or using the Playground's Test action:\n"
1619016190
"///\n"
1619116191
"/// ```\n"
16192-
"/// let result = doccomments::add(2, 3);\n"
16192+
"/// let result = playground::add(2, 3);\n"
1619316193
"/// assert_eq!(result, 5);\n"
1619416194
"/// ```\n"
1619516195
msgstr ""
@@ -16198,10 +16198,10 @@ msgstr ""
1619816198
"/// 以降で詳細なドキュメンテーションを記述します。コードブロックは三重のバッ"
1619916199
"ククォートで始まり、\n"
1620016200
"/// 暗黙的に`fn main()`と`extern crate <クレート名>`で囲われます。\n"
16201-
"/// `doccomments`クレートをテストしたいときには、次のように記述します。\n"
16201+
"/// `playground`クレートをテストしたいときには、次のように記述します。\n"
1620216202
"///\n"
1620316203
"/// ```\n"
16204-
"/// let result = doccomments::add(2, 3);\n"
16204+
"/// let result = playground::add(2, 3);\n"
1620516205
"/// assert_eq!(result, 5);\n"
1620616206
"/// ```\n"
1620716207

@@ -16215,7 +16215,7 @@ msgid ""
1621516215
"/// # Examples\n"
1621616216
"///\n"
1621716217
"/// ```\n"
16218-
"/// let result = doccomments::div(10, 2);\n"
16218+
"/// let result = playground::div(10, 2);\n"
1621916219
"/// assert_eq!(result, 5);\n"
1622016220
"/// ```\n"
1622116221
"///\n"
@@ -16225,7 +16225,7 @@ msgid ""
1622516225
"///\n"
1622616226
"/// ```rust,should_panic\n"
1622716227
"/// // panics on division by zero\n"
16228-
"/// doccomments::div(10, 0);\n"
16228+
"/// playground::div(10, 0);\n"
1622916229
"/// ```\n"
1623016230
msgstr ""
1623116231
"/// 一般的に、ドキュメンテーションコメントは\n"
@@ -16236,7 +16236,7 @@ msgstr ""
1623616236
"/// # Examples\n"
1623716237
"///\n"
1623816238
"/// ```\n"
16239-
"/// let result = doccomments::div(10, 2);\n"
16239+
"/// let result = playground::div(10, 2);\n"
1624016240
"/// assert_eq!(result, 5);\n"
1624116241
"/// ```\n"
1624216242
"///\n"
@@ -16246,7 +16246,7 @@ msgstr ""
1624616246
"///\n"
1624716247
"/// ```rust,should_panic\n"
1624816248
"/// // ゼロで除算するとパニックします\n"
16249-
"/// doccomments::div(10, 0);\n"
16249+
"/// playground::div(10, 0);\n"
1625016250
"/// ```\n"
1625116251

1625216252
#: src/testing/doc_testing.md:52
@@ -16291,7 +16291,7 @@ msgid ""
1629116291
"/// # // hidden lines start with `#` symbol, but they're still compilable!\n"
1629216292
"/// # fn try_main() -> Result<(), String> { // line that wraps the body "
1629316293
"shown in doc\n"
16294-
"/// let res = doccomments::try_div(10, 2)?;\n"
16294+
"/// let res = playground::try_div(10, 2)?;\n"
1629516295
"/// # Ok(()) // returning from try_main\n"
1629616296
"/// # }\n"
1629716297
"/// # fn main() { // starting main that'll unwrap()\n"
@@ -16305,7 +16305,7 @@ msgstr ""
1630516305
"/// ```\n"
1630616306
"/// # // 行頭に `#` を置くと行が隠されるが、コンパイルには成功します。\n"
1630716307
"/// # fn try_main() -> Result<(), String> { // ドキュメントの本体を囲う行\n"
16308-
"/// let res = doccomments::try_div(10, 2)?;\n"
16308+
"/// let res = playground::try_div(10, 2)?;\n"
1630916309
"/// # Ok(()) // try_mainから値を返します\n"
1631016310
"/// # }\n"
1631116311
"/// # fn main() { // unwrap()を実行します。\n"

po/zh.po

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15454,22 +15454,22 @@ msgid ""
1545415454
"///\n"
1545515455
"/// The next lines present detailed documentation. Code blocks start with\n"
1545615456
"/// triple backquotes and have implicit `fn main()` inside\n"
15457-
"/// and `extern crate <cratename>`. Assume we're testing `doccomments` "
15458-
"crate:\n"
15457+
"/// and `extern crate <cratename>`. Assume we're testing a `playground` library\n"
15458+
"/// crate or using the Playground's Test action:\n"
1545915459
"///\n"
1546015460
"/// ```\n"
15461-
"/// let result = doccomments::add(2, 3);\n"
15461+
"/// let result = playground::add(2, 3);\n"
1546215462
"/// assert_eq!(result, 5);\n"
1546315463
"/// ```\n"
1546415464
msgstr ""
1546515465
"/// 第一行是函数的简要描述。\n"
1546615466
"///\n"
1546715467
"/// 接下来的几行是详细文档。代码块以三个反引号开始,\n"
1546815468
"/// 并隐含了 `fn main()` 函数和 `extern crate <cratename>` 声明。\n"
15469-
"/// 假设我们正在测试 `doccomments` crate:\n"
15469+
"/// 假设我们正在测试 `playground` crate:\n"
1547015470
"///\n"
1547115471
"/// ```\n"
15472-
"/// let result = doccomments::add(2, 3);\n"
15472+
"/// let result = playground::add(2, 3);\n"
1547315473
"/// assert_eq!(result, 5);\n"
1547415474
"/// ```\n"
1547515475

@@ -15483,7 +15483,7 @@ msgid ""
1548315483
"/// # Examples\n"
1548415484
"///\n"
1548515485
"/// ```\n"
15486-
"/// let result = doccomments::div(10, 2);\n"
15486+
"/// let result = playground::div(10, 2);\n"
1548715487
"/// assert_eq!(result, 5);\n"
1548815488
"/// ```\n"
1548915489
"///\n"
@@ -15493,7 +15493,7 @@ msgid ""
1549315493
"///\n"
1549415494
"/// ```rust,should_panic\n"
1549515495
"/// // panics on division by zero\n"
15496-
"/// doccomments::div(10, 0);\n"
15496+
"/// playground::div(10, 0);\n"
1549715497
"/// ```\n"
1549815498
msgstr ""
1549915499
"/// 文档注释通常包含"示例"、"异常"和"错误"等部分。\n"
@@ -15503,7 +15503,7 @@ msgstr ""
1550315503
"/// # 示例\n"
1550415504
"///\n"
1550515505
"/// ```\n"
15506-
"/// let result = doccomments::div(10, 2);\n"
15506+
"/// let result = playground::div(10, 2);\n"
1550715507
"/// assert_eq!(result, 5);\n"
1550815508
"/// ```\n"
1550915509
"///\n"
@@ -15513,7 +15513,7 @@ msgstr ""
1551315513
"///\n"
1551415514
"/// ```rust,should_panic\n"
1551515515
"/// // 除以零会触发异常\n"
15516-
"/// doccomments::div(10, 0);\n"
15516+
"/// playground::div(10, 0);\n"
1551715517
"/// ```\n"
1551815518

1551915519
#: src/testing/doc_testing.md:52
@@ -15549,7 +15549,7 @@ msgid ""
1554915549
"/// # // hidden lines start with `#` symbol, but they're still compilable!\n"
1555015550
"/// # fn try_main() -> Result<(), String> { // line that wraps the body shown "
1555115551
"in doc\n"
15552-
"/// let res = doccomments::try_div(10, 2)?;\n"
15552+
"/// let res = playground::try_div(10, 2)?;\n"
1555315553
"/// # Ok(()) // returning from try_main\n"
1555415554
"/// # }\n"
1555515555
"/// # fn main() { // starting main that'll unwrap()\n"
@@ -15563,7 +15563,7 @@ msgstr ""
1556315563
"/// ```\n"
1556415564
"/// # // 以 `#` 开头的行在文档中是隐藏的,但它们仍然可以编译!\n"
1556515565
"/// # fn try_main() -> Result<(), String> { // 这行包装了文档中显示的函数体\n"
15566-
"/// let res = doccomments::try_div(10, 2)?;\n"
15566+
"/// let res = playground::try_div(10, 2)?;\n"
1556715567
"/// # Ok(()) // 从 try_main 返回\n"
1556815568
"/// # }\n"
1556915569
"/// # fn main() { // 开始会调用 unwrap() 的 main 函数\n"

src/testing/doc_testing.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ as documentation tests.
1111
///
1212
/// The next lines present detailed documentation. Code blocks start with
1313
/// triple backquotes and have implicit `fn main()` inside
14-
/// and `extern crate <cratename>`. Assume we're testing `doccomments` crate:
14+
/// and `extern crate <cratename>`. Assume we're testing a `playground` library
15+
/// crate or using the Playground's Test action:
1516
///
1617
/// ```
17-
/// let result = doccomments::add(2, 3);
18+
/// let result = playground::add(2, 3);
1819
/// assert_eq!(result, 5);
1920
/// ```
2021
pub fn add(a: i32, b: i32) -> i32 {
@@ -28,7 +29,7 @@ pub fn add(a: i32, b: i32) -> i32 {
2829
/// # Examples
2930
///
3031
/// ```
31-
/// let result = doccomments::div(10, 2);
32+
/// let result = playground::div(10, 2);
3233
/// assert_eq!(result, 5);
3334
/// ```
3435
///
@@ -38,7 +39,7 @@ pub fn add(a: i32, b: i32) -> i32 {
3839
///
3940
/// ```rust,should_panic
4041
/// // panics on division by zero
41-
/// doccomments::div(10, 0);
42+
/// playground::div(10, 0);
4243
/// ```
4344
pub fn div(a: i32, b: i32) -> i32 {
4445
if b == 0 {
@@ -58,7 +59,7 @@ running 0 tests
5859

5960
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
6061

61-
Doc-tests doccomments
62+
Doc-tests playground
6263

6364
running 3 tests
6465
test src/lib.rs - add (line 7) ... ok
@@ -84,7 +85,7 @@ and `unwrap` it in hidden `main`. Sounds complicated? Here's an example:
8485
/// ```
8586
/// # // hidden lines start with `#` symbol, but they're still compilable!
8687
/// # fn try_main() -> Result<(), String> { // line that wraps the body shown in doc
87-
/// let res = doccomments::try_div(10, 2)?;
88+
/// let res = playground::try_div(10, 2)?;
8889
/// # Ok(()) // returning from try_main
8990
/// # }
9091
/// # fn main() { // starting main that'll unwrap()

0 commit comments

Comments
 (0)