Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix misplaced doc comments #411

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/file_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ pub fn insert_file(
let mut folder_path = file_path.to_path_buf();
folder_path.pop();

let content = convert_rust_line_to_doc_comments(file_path, content);

insert_file_tree_in_dir(
file_tree,
&folder_path,
Expand Down Expand Up @@ -232,7 +230,7 @@ pub fn map_rust_files<F: Fn(PathBuf, syn::File) -> ScaffoldResult<syn::File> + C
/// otherwise returns the original content unchanged.
fn convert_rust_line_to_doc_comments(file_path: &Path, content: &str) -> String {
if file_path.extension().and_then(|ext| ext.to_str()) == Some("rs") {
let re = Regex::new(r"^\/\/[^\/]|[^\/]\/\/[^\/]").expect("Failed to create regex");
let re = Regex::new(r"(?:^|[^:])/(/[^/])").expect("Failed to create regex");
content
.lines()
.map(|line| re.replace_all(line, "/// ").into_owned() + "\n")
Expand Down
Loading
Loading