Skip to content

Commit fec4e4f

Browse files
authored
Merge branch 'master' into add_option_remove_indentation
2 parents bc0f19c + c8db0c8 commit fec4e4f

File tree

33 files changed

+206
-129
lines changed

33 files changed

+206
-129
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- build: msrv
3333
os: ubuntu-latest
3434
# sync MSRV with docs: guide/src/guide/installation.md
35-
rust: 1.54.0
35+
rust: 1.56.0
3636
steps:
3737
- uses: actions/checkout@master
3838
- name: Install Rust

CHANGELOG.md

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

3+
## mdBook 0.4.21
4+
[92afe9b...8f01d02](https://github.com/rust-lang/mdBook/compare/92afe9b...8f01d02)
5+
6+
### Fixed
7+
- Fixed an issue where mdBook would fail to compile with Rust nightly-2022-07-22.
8+
[#1861](https://github.com/rust-lang/mdBook/pull/1861)
9+
310
## mdBook 0.4.20
411
[53055e0...da166e0](https://github.com/rust-lang/mdBook/compare/53055e0...da166e0)
512

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
22
name = "mdbook"
3-
version = "0.4.20"
3+
version = "0.4.21"
44
authors = [
55
"Mathieu David <[email protected]>",
66
"Michael-F-Bryan <[email protected]>",
77
"Matt Ickstadt <[email protected]>"
88
]
99
documentation = "http://rust-lang.github.io/mdBook/index.html"
10-
edition = "2018"
10+
edition = "2021"
1111
exclude = ["/guide/*"]
1212
keywords = ["book", "gitbook", "rustbook", "markdown"]
1313
license = "MPL-2.0"

guide/src/cli/test.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mdbook test path/to/book
4343
The `--library-path` (`-L`) option allows you to add directories to the library
4444
search path used by `rustdoc` when it builds and tests the examples. Multiple
4545
directories can be specified with multiple options (`-L foo -L bar`) or with a
46-
comma-delimited list (`-L foo,bar`). The path should point to the Cargo
46+
comma-delimited list (`-L foo,bar`). The path should point to the Cargo
4747
[build cache](https://doc.rust-lang.org/cargo/guide/build-cache.html) `deps` directory that
4848
contains the build output of your project. For example, if your Rust project's book is in a directory
4949
named `my-book`, the following command would include the crate's dependencies when running `test`:
@@ -61,3 +61,8 @@ The `--dest-dir` (`-d`) option allows you to change the output directory for the
6161
book. Relative paths are interpreted relative to the book's root directory. If
6262
not specified it will default to the value of the `build.build-dir` key in
6363
`book.toml`, or to `./book`.
64+
65+
#### --chapter
66+
67+
The `--chapter` (`-c`) option allows you to test a specific chapter of the
68+
book using the chapter name or the relative path to the chapter.

guide/src/continuous-integration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A simple approach would be to use the popular `curl` CLI tool to download the ex
2121

2222
```sh
2323
mkdir bin
24-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.20/mdbook-v0.4.20-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
24+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
2525
bin/mdbook build
2626
```
2727

guide/src/format/configuration/renderers.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ The following configuration options are available:
157157
Defaults to `404.md`.
158158
- **site-url:** The url where the book will be hosted. This is required to ensure
159159
navigation links and script/css imports in the 404 file work correctly, even when accessing
160-
urls in subdirectories. Defaults to `/`.
160+
urls in subdirectories. Defaults to `/`. If `site-url` is set,
161+
make sure to use document relative links for your assets, meaning they should not start with `/`.
161162
- **cname:** The DNS subdomain or apex domain at which your book will be hosted.
162163
This string will be written to a file named CNAME in the root of your site, as
163164
required by GitHub Pages (see [*Managing a custom domain for your GitHub Pages

src/book/book.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem};
88
use crate::config::BuildConfig;
99
use crate::errors::*;
1010
use crate::utils::bracket_escape;
11-
11+
use log::debug;
1212
use serde::{Deserialize, Serialize};
1313

1414
/// Load a book into memory from its `src/` directory.

src/book/init.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use super::MDBook;
66
use crate::config::Config;
77
use crate::errors::*;
88
use crate::theme;
9+
use log::{debug, error, info, trace};
910

1011
/// A helper for setting up a new book and its directory structure.
1112
#[derive(Debug, Clone, PartialEq)]

src/book/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub use self::book::{load_book, Book, BookItem, BookItems, Chapter};
1414
pub use self::init::BookBuilder;
1515
pub use self::summary::{parse_summary, Link, SectionNumber, Summary, SummaryItem};
1616

17+
use log::{debug, error, info, log_enabled, trace, warn};
1718
use std::io::Write;
1819
use std::path::PathBuf;
1920
use std::process::Command;
@@ -246,6 +247,13 @@ impl MDBook {
246247

247248
/// Run `rustdoc` tests on the book, linking against the provided libraries.
248249
pub fn test(&mut self, library_paths: Vec<&str>) -> Result<()> {
250+
// test_chapter with chapter:None will run all tests.
251+
self.test_chapter(library_paths, None)
252+
}
253+
254+
/// Run `rustdoc` tests on a specific chapter of the book, linking against the provided libraries.
255+
/// If `chapter` is `None`, all tests will be run.
256+
pub fn test_chapter(&mut self, library_paths: Vec<&str>, chapter: Option<&str>) -> Result<()> {
249257
let library_args: Vec<&str> = (0..library_paths.len())
250258
.map(|_| "-L")
251259
.zip(library_paths.into_iter())
@@ -254,6 +262,8 @@ impl MDBook {
254262

255263
let temp_dir = TempFileBuilder::new().prefix("mdbook-").tempdir()?;
256264

265+
let mut chapter_found = false;
266+
257267
// FIXME: Is "test" the proper renderer name to use here?
258268
let preprocess_context =
259269
PreprocessorContext::new(self.root.clone(), self.config.clone(), "test".to_string());
@@ -270,8 +280,16 @@ impl MDBook {
270280
_ => continue,
271281
};
272282

273-
let path = self.source_dir().join(&chapter_path);
274-
info!("Testing file: {:?}", path);
283+
if let Some(chapter) = chapter {
284+
if ch.name != chapter && chapter_path.to_str() != Some(chapter) {
285+
if chapter == "?" {
286+
info!("Skipping chapter '{}'...", ch.name);
287+
}
288+
continue;
289+
}
290+
}
291+
chapter_found = true;
292+
info!("Testing chapter '{}': {:?}", ch.name, chapter_path);
275293

276294
// write preprocessed file to tempdir
277295
let path = temp_dir.path().join(&chapter_path);
@@ -311,6 +329,11 @@ impl MDBook {
311329
if failed {
312330
bail!("One or more tests failed");
313331
}
332+
if let Some(chapter) = chapter {
333+
if !chapter_found {
334+
bail!("Chapter not found: {}", chapter);
335+
}
336+
}
314337
Ok(())
315338
}
316339

0 commit comments

Comments
 (0)