Skip to content

Commit e0d07cc

Browse files
author
Marek Suchánek
committed
Reformat the code with rustfmt
1 parent 4bd1739 commit e0d07cc

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ mod tests {
213213
let options = minimal_options();
214214
let assembly = Module::new(mod_type, mod_title, &options);
215215

216-
let pre_generated =
217-
include_str!("../data/generated/minimal-assembly.adoc");
216+
let pre_generated = include_str!("../data/generated/minimal-assembly.adoc");
218217

219218
assert_eq!(assembly.text, pre_generated);
220219
}
@@ -253,8 +252,7 @@ mod tests {
253252
let options = minimal_options();
254253
let reference = Module::new(mod_type, mod_title, &options);
255254

256-
let pre_generated =
257-
include_str!("../data/generated/minimal-reference.adoc");
255+
let pre_generated = include_str!("../data/generated/minimal-reference.adoc");
258256

259257
assert_eq!(reference.text, pre_generated);
260258
}

src/module.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
use log::debug;
12
/// This module defines the `Module` struct, its builder struct, and methods on both structs.
23
use std::path::{Path, PathBuf};
3-
use log::debug;
44

55
use crate::Options;
66

7-
87
/// All possible types of the AsciiDoc module
98
#[derive(Debug, Clone, Copy, PartialEq)]
109
pub enum ModuleType {
@@ -332,7 +331,11 @@ mod tests {
332331
fn check_detected_path() {
333332
let options = path_options();
334333

335-
let module = Module::new(&ModuleType::Procedure, "Testing the detected path", &options);
334+
let module = Module::new(
335+
&ModuleType::Procedure,
336+
"Testing the detected path",
337+
&options,
338+
);
336339

337340
assert_eq!(
338341
module.include_statement,

src/templating.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use regex::{Regex, RegexBuilder};
21
use askama::Template;
2+
use regex::{Regex, RegexBuilder};
33

44
use crate::module::{Input, ModuleType};
55

@@ -48,7 +48,6 @@ struct ReferenceTemplate<'a> {
4848
examples: bool,
4949
}
5050

51-
5251
// We're implementing the template functions on the Input struct, not on Module,
5352
// because the templating happens at the point when newdoc composes the text of the module,
5453
// which is part of the module creation. The module then stores the rendered template.
@@ -79,23 +78,28 @@ impl Input {
7978
module_title: &self.title,
8079
include_statements: &self.includes_block(),
8180
examples: self.options.examples,
82-
}.render(),
81+
}
82+
.render(),
8383
ModuleType::Concept => ConceptTemplate {
8484
module_id: &self.id(),
8585
module_title: &self.title,
8686
examples: self.options.examples,
87-
}.render(),
87+
}
88+
.render(),
8889
ModuleType::Procedure => ProcedureTemplate {
8990
module_id: &self.id(),
9091
module_title: &self.title,
9192
examples: self.options.examples,
92-
}.render(),
93+
}
94+
.render(),
9395
ModuleType::Reference => ReferenceTemplate {
9496
module_id: &self.id(),
9597
module_title: &self.title,
9698
examples: self.options.examples,
97-
}.render(),
98-
}.expect("Failed to construct the document from the template");
99+
}
100+
.render(),
101+
}
102+
.expect("Failed to construct the document from the template");
99103

100104
// If comments are disabled via an option, delete comment lines from the content
101105
if !self.options.comments {
@@ -105,28 +109,22 @@ impl Input {
105109
.swap_greed(true)
106110
.build()
107111
.unwrap();
108-
document = multi_comments
109-
.replace_all(&document, "")
110-
.to_string();
112+
document = multi_comments.replace_all(&document, "").to_string();
111113

112114
// Delete single-line comments
113115
let single_comments: Regex = RegexBuilder::new(r"^//.*\n")
114116
.multi_line(true)
115117
.swap_greed(true)
116118
.build()
117119
.unwrap();
118-
document = single_comments
119-
.replace_all(&document, "")
120-
.to_string();
120+
document = single_comments.replace_all(&document, "").to_string();
121121

122122
// Delete leading white space left over by the deleted comments
123123
let leading_whitespace: Regex = RegexBuilder::new(r"^[\s\n]*")
124124
.multi_line(true)
125125
.build()
126126
.unwrap();
127-
document = leading_whitespace
128-
.replace(&document, "")
129-
.to_string();
127+
document = leading_whitespace.replace(&document, "").to_string();
130128
}
131129

132130
// Remove excess blank lines that might have been left by the verious

0 commit comments

Comments
 (0)