-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change absolute link to relative link during doc generation #8641
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,7 +445,15 @@ impl DocBuilder { | |
} | ||
} else { | ||
let name = path.iter().last().unwrap().to_string_lossy(); | ||
let readme_path = Path::new("/").join(&path).display().to_string(); | ||
let readme_path = Path::new("/") | ||
.join(&path) | ||
.display() | ||
.to_string() | ||
.trim_start_matches('/') | ||
.to_string(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any chance we can avoid the double allocation here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change to_string to to_owned There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Evalir Can you check the fix? |
||
let slash_count = readme_path.chars().filter(|&c| c == '/').count(); | ||
let prefix = "../".repeat(slash_count); | ||
let readme_path = format!("{prefix}{readme_path}/index.html"); | ||
readme.write_link_list_item(&name, &readme_path, 0)?; | ||
self.write_summary_section(summary, &files, Some(&path), depth + 1)?; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this step seems redundant because we first join then remove the leading
/