Skip to content

Commit

Permalink
fix: Fix misplaced doc comments (#411)
Browse files Browse the repository at this point in the history
* Fix misplaced doc comments

* Slightly refactor link_type integrity codegen
  • Loading branch information
c12i committed Dec 10, 2024
1 parent a6e9b69 commit 16d702c
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 180 deletions.
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

0 comments on commit 16d702c

Please sign in to comment.