diff --git a/src/preprocess/links.rs b/src/preprocess/links.rs index 0521e2e9..840f2e09 100644 --- a/src/preprocess/links.rs +++ b/src/preprocess/links.rs @@ -1,7 +1,7 @@ use crate::errors::*; use crate::utils::{ - take_anchored_lines, take_lines, take_remove_indent, take_rustdoc_include_anchored_lines, - take_rustdoc_include_lines, + take_anchored_lines, take_format_remove_indent, take_lines, + take_rustdoc_include_anchored_lines, take_rustdoc_include_lines, }; use regex::{CaptureMatches, Captures, Regex}; use std::fs; @@ -244,8 +244,6 @@ fn parse_range_or_anchor(parts: Option<&str>) -> RangeOrAnchor { // the single line specified by `start`. let end = end.map(|s| s.parse::()); - println!("Start: {:?} End: {:?}", start, end); - match (start, end) { (Some(start), Some(Ok(end))) => RangeOrAnchor::Range(LineRange::from(start..end)), (Some(start), Some(Err(_))) => RangeOrAnchor::Range(LineRange::from(start..)), @@ -317,8 +315,6 @@ impl<'a> Link<'a> { _ => None, }; - println!("Ovo je : {:?}", link_type); - link_type.and_then(|lnk_type| { cap.get(0).map(|mat| Link { start_index: mat.start(), @@ -356,7 +352,8 @@ impl<'a> Link<'a> { } LinkType::IncludeNoIndent(ref pat, ref range_or_anchor) => { let target = base.join(pat); - let s = fs::read_to_string(&target) + + fs::read_to_string(&target) .map(|s| match range_or_anchor { RangeOrAnchor::Range(range) => take_lines(&s, range.clone()), RangeOrAnchor::Anchor(anchor) => take_anchored_lines(&s, anchor), @@ -367,8 +364,8 @@ impl<'a> Link<'a> { self.link_text, target.display(), ) - }); - take_remove_indent(s) + }) + .map(|s| take_format_remove_indent(s.as_str())) } LinkType::RustdocInclude(ref pat, ref range_or_anchor) => { let target = base.join(pat); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index bf1a0daf..a2f50030 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -15,8 +15,8 @@ use std::fmt::Write; use std::path::Path; pub use self::string::{ - take_anchored_lines, take_lines, take_remove_indent, take_rustdoc_include_anchored_lines, - take_rustdoc_include_lines, + take_anchored_lines, take_format_remove_indent, take_lines, + take_rustdoc_include_anchored_lines, take_rustdoc_include_lines, }; /// Replaces multiple consecutive whitespace characters with a single space character. diff --git a/src/utils/string.rs b/src/utils/string.rs index a0368255..841eaa77 100644 --- a/src/utils/string.rs +++ b/src/utils/string.rs @@ -1,4 +1,3 @@ -use anyhow::Error; use once_cell::sync::Lazy; use regex::Regex; use std::ops::Bound::{Excluded, Included, Unbounded}; @@ -116,14 +115,7 @@ pub fn take_rustdoc_include_anchored_lines(s: &str, anchor: &str) -> String { output } -pub fn take_remove_indent(s: Result) -> Result { - match s { - Err(_) => s, - Ok(_str) => Ok(take_format_remove_indent(_str.as_str())), - } -} - -fn take_format_remove_indent(str: &str) -> String { +pub fn take_format_remove_indent(str: &str) -> String { let mut output = Vec::::new(); let mut min_indent = usize::MAX;