Skip to content

Commit

Permalink
Merge pull request #68 from ehuss/mdbook-upstream-fixes
Browse files Browse the repository at this point in the history
Fix some issues with the rust-lang/rust upstream.
  • Loading branch information
JoelMarcey authored Jul 11, 2024
2 parents 656ef39 + 0eb71d6 commit 1cbd564
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions mdbook-spec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## mdbook-spec 0.1.2

- Fixed some issues with rust-lang/rust build integration.

## mdbook-spec 0.1.1

- Moved code to a library to support upstream integration.
Expand Down
4 changes: 2 additions & 2 deletions mdbook-spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mdbook-spec"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "An mdBook preprocessor to help with the Rust specification."
Expand All @@ -13,7 +13,7 @@ anyhow = "1.0.79"
mdbook = { version = "0.4.36", default-features = false }
once_cell = "1.19.0"
pathdiff = "0.2.1"
regex = "1.10.3"
regex = "1.9.4"
semver = "1.0.21"
serde_json = "1.0.113"
tempfile = "3.10.1"
6 changes: 3 additions & 3 deletions mdbook-spec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Spec {
let source_path = chapter.source_path.clone().unwrap_or_default();
let path = chapter.path.clone().unwrap_or_default();
RULE_RE
.replace_all(&chapter.content, |caps: &Captures| {
.replace_all(&chapter.content, |caps: &Captures<'_>| {
let rule_id = &caps[1];
if let Some((old, _)) =
found_rules.insert(rule_id.to_string(), (source_path.clone(), path.clone()))
Expand Down Expand Up @@ -127,7 +127,7 @@ impl Spec {
/// file.
fn admonitions(&self, chapter: &Chapter) -> String {
ADMONITION_RE
.replace_all(&chapter.content, |caps: &Captures| {
.replace_all(&chapter.content, |caps: &Captures<'_>| {
let lower = caps["admon"].to_lowercase();
format!(
"<div class=\"{lower}\">\n\n{}\n\n</div>\n",
Expand All @@ -140,7 +140,7 @@ impl Spec {

impl Preprocessor for Spec {
fn name(&self) -> &str {
"nop-preprocessor"
"spec"
}

fn run(&self, _ctx: &PreprocessorContext, mut book: Book) -> Result<Book, Error> {
Expand Down
5 changes: 3 additions & 2 deletions mdbook-spec/src/std_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn std_links(chapter: &Chapter) -> String {

// Replace any disambiguated links with just the disambiguation.
let mut output = STD_LINK_RE
.replace_all(&chapter.content, |caps: &Captures| {
.replace_all(&chapter.content, |caps: &Captures<'_>| {
if let Some(dest) = caps.get(2) {
// Replace destination parenthesis with a link definition (square brackets).
format!("{}[{}]", &caps[1], dest.as_str())
Expand Down Expand Up @@ -174,7 +174,8 @@ fn run_rustdoc(tmp: &TempDir, links: &[(&str, Option<&str>)], chapter: &Chapter)
)
.unwrap();
fs::write(&src_path, &src).unwrap();
let output = Command::new("rustdoc")
let rustdoc = std::env::var("RUSTDOC").unwrap_or_else(|_| "rustdoc".into());
let output = Command::new(rustdoc)
.arg("--edition=2021")
.arg(&src_path)
.current_dir(tmp.path())
Expand Down

0 comments on commit 1cbd564

Please sign in to comment.