Skip to content

Commit b2eb96c

Browse files
committed
finalize doc updates for new feature
1 parent d62904b commit b2eb96c

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## mdBook 0.4.43+ (tba)
4+
5+
### Fixed
6+
7+
- Allow doctests to use external crates by referencing a `Cargo.toml`
8+
39
## mdBook 0.4.43
410
[v0.4.42...v0.4.43](https://github.com/rust-lang/mdBook/compare/v0.4.42...v0.4.43)
511

guide/src/cli/test.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ For example,
77
of code samples that could become outdated as the language evolves.
88

99
MdBook supports a `test` command which runs code samples in your book as doc tests to verify they
10-
will compile, and, optionally, run correctly.
10+
will compile, and, optionally, run correctly.
11+
For details on how to specify the test to be done and outcome to be expected, see [Code Blocks](/format/mdbook.md#code-blocks).
12+
1113
At the moment, mdBook only supports doc *tests* written in Rust, although code samples can be written and *displayed* in many programming languages.
1214

1315
#### Specify a directory
@@ -36,7 +38,6 @@ book using the chapter name or the relative path to the chapter.
3638
***Note*** This argument is deprecated. Since Rust edition 2018, the compiler needs an explicit `--extern` argument for each external crate used in a doc test, it no longer simply scans the library path for likely-looking crates.
3739
New projects should list external crates as dependencies in a **Cargo.toml** file and reference that file in your ***book.toml***, as described in [rust configuration](/format/configuration/general.html#rust-options).
3840

39-
4041
The `--library-path` (`-L`) option allows you to add directories to the library
4142
search path used by `rustdoc` when it builds and tests the examples. Multiple
4243
directories can be specified with multiple options (`-L foo -L bar`) or with a

guide/src/format/mdbook.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# mdBook-specific features
22

3-
# Features for code blocks
3+
# Code blocks
44

5-
These capabilities primarily affect how the user sees or interacts with code samples in your book and are supported directly by mdBook. Some also affect documentation tests (for which mdBook invokes `rustdoc --test`): this is detailed in the sections below.
5+
These capabilities primarily affect how the user sees or interacts with code samples in your book and are supported directly by mdBook. Some also affect running the sample as a documentation test. (for which mdBook invokes `rustdoc --test`), so : this is detailed in the sections below.
66

77
## Hiding code lines
88

@@ -12,7 +12,7 @@ For the Rust language, you can use the `#` character as a prefix which will hide
1212

1313
[rustdoc-hide]: https://doc.rust-lang.org/stable/rustdoc/write-documentation/documentation-tests.html#hiding-portions-of-the-example
1414

15-
```bash
15+
```text
1616
# fn main() {
1717
let x = 5;
1818
let y = 6;
@@ -44,7 +44,7 @@ python = "~"
4444

4545
The prefix will hide any lines that begin with the given prefix. With the python prefix shown above, this:
4646

47-
```bash
47+
```text
4848
~hidden()
4949
nothidden():
5050
~ hidden()
@@ -155,6 +155,7 @@ interpreting them.
155155
````
156156

157157
## Including portions of a file
158+
158159
Often you only need a specific part of the file, e.g. relevant lines for an
159160
example. We support four different modes of partial includes:
160161

@@ -179,6 +180,7 @@ the regex `ANCHOR_END:\s*[\w_-]+`. This allows you to put anchors in
179180
any kind of commented line.
180181

181182
Consider the following file to include:
183+
182184
```rs
183185
/* ANCHOR: all */
184186

@@ -196,6 +198,7 @@ impl System for MySystem { ... }
196198
```
197199

198200
Then in the book, all you have to do is:
201+
199202
````hbs
200203
Here is a component:
201204
```rust,no_run,noplayground

guide/src/guide/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ This user guide provides an introduction to basic concepts of using mdBook.
44

55
- [Installation](installation.md)
66
- [Reading Books](reading.md)
7-
- [Creating a Book](creating.md)
8-
- [Writing Code Samples](writing.md)
7+
- [Creating a Book](creating.md)q

0 commit comments

Comments
 (0)