Skip to content

Commit 91e25e5

Browse files
committed
Update comrak crate
1 parent aa20fea commit 91e25e5

File tree

3 files changed

+46
-80
lines changed

3 files changed

+46
-80
lines changed

Cargo.lock

Lines changed: 32 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ native-tls = "0.2"
3333
x509-cert = { version = "0.2.5", features = ["pem"] }
3434
serde_path_to_error = "0.1.2"
3535
octocrab = { version = "0.30.1", features = ["stream"] }
36-
comrak = { version = "0.8.2", default-features = false }
36+
comrak = { version = "0.38", default-features = false }
3737
route-recognizer = "0.3.0"
3838
cynic = "3.2.2"
3939
itertools = "0.10.2"

src/changelogs/rustc.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::Changelog;
2+
use anyhow::Context as _;
23
use comrak::{
3-
nodes::{Ast, AstNode, NodeHeading, NodeValue},
4+
nodes::{AstNode, NodeHeading, NodeValue},
45
Arena, ComrakOptions,
56
};
6-
use std::cell::RefCell;
77
use std::collections::HashMap;
88

99
pub(super) struct RustcFormat<'a> {
@@ -35,7 +35,16 @@ impl<'a> RustcFormat<'a> {
3535
self.store_version(h1, section_ast)?;
3636
}
3737

38-
self.current_h1 = Some(String::from_utf8(child_data.content.clone())?);
38+
let Some(h1_child_data) = child.first_child().map(|c| c.data.borrow()) else {
39+
anyhow::bail!("unable to retrieve heading (H1) child from changelog");
40+
};
41+
self.current_h1 = Some(
42+
h1_child_data
43+
.value
44+
.text()
45+
.context("unable to get the text of node below the heading H1")?
46+
.to_string(),
47+
);
3948
section_ast = Vec::new();
4049
} else {
4150
section_ast.push(child);
@@ -50,9 +59,7 @@ impl<'a> RustcFormat<'a> {
5059

5160
fn store_version(&mut self, h1: String, body: Vec<&'a AstNode<'a>>) -> anyhow::Result<()> {
5261
// Create a document with only the contents of this section
53-
let document = self
54-
.arena
55-
.alloc(AstNode::new(RefCell::new(Ast::new(NodeValue::Document))));
62+
let document = self.arena.alloc(NodeValue::Document.into());
5663
for child in &body {
5764
document.append(child);
5865
}

0 commit comments

Comments
 (0)