From 115a3274fe48a357cd2b3d6f94256e9c4993895d Mon Sep 17 00:00:00 2001 From: Yota Toyama Date: Tue, 5 Dec 2023 21:56:54 +0900 Subject: [PATCH] Refactor --- macro/src/dialect.rs | 4 +--- macro/src/dialect/operation.rs | 2 +- macro/src/dialect/utility.rs | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/macro/src/dialect.rs b/macro/src/dialect.rs index 31bffe6d67..61c1bae059 100644 --- a/macro/src/dialect.rs +++ b/macro/src/dialect.rs @@ -64,9 +64,7 @@ fn generate_dialect_module( let doc = format!( "`{name}` dialect.\n\n{}", - sanitize_documentation(&unindent::unindent( - dialect.str_value("description").unwrap_or(""), - ))? + sanitize_documentation(dialect.str_value("description").unwrap_or(""),)? ); let name = sanitize_snake_case_name(name)?; diff --git a/macro/src/dialect/operation.rs b/macro/src/dialect/operation.rs index ec96804430..f0ade14124 100644 --- a/macro/src/dialect/operation.rs +++ b/macro/src/dialect/operation.rs @@ -586,7 +586,7 @@ impl<'a> Operation<'a> { ] .join(" ") }, - description: unindent::unindent(definition.str_value("description")?), + description: sanitize_documentation(definition.str_value("description")?)?, regions, }) } diff --git a/macro/src/dialect/utility.rs b/macro/src/dialect/utility.rs index bc43fae820..a13cf22235 100644 --- a/macro/src/dialect/utility.rs +++ b/macro/src/dialect/utility.rs @@ -32,7 +32,7 @@ fn sanitize_name(name: &str) -> Result { pub fn sanitize_documentation(string: &str) -> Result { let arena = Arena::new(); - let node = parse_document(&arena, string, &Default::default()); + let node = parse_document(&arena, &unindent::unindent(string), &Default::default()); for node in node.traverse() { let NodeEdge::Start(node) = node else {