Skip to content

Commit

Permalink
fix: forc-doc links sort order (FuelLabs#4475)
Browse files Browse the repository at this point in the history
close FuelLabs#3995 

Fixes shallow alphabetization for the all doc items.

---------

Co-authored-by: Sophie Dankel <[email protected]>
  • Loading branch information
sarahschwartz and sdankel authored Apr 21, 2023
1 parent e77749e commit 3334843
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions forc-plugins/forc-doc/src/render/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ impl Renderable for DocLinks {
fn render(self, _render_plan: RenderPlan) -> Result<Box<dyn RenderBox>> {
let mut links_vec = Vec::new();
// sort the doc links alphabetically
// for the AllDoc page, sort based on the module prefix
// for the AllDoc page, sort based on the module prefix and name
match self.style {
DocStyle::AllDoc(_) => {
for (block_title, mut doc_link) in self.links {
doc_link.sort_by(|a, b| {
a.module_info.module_prefixes[1].cmp(&b.module_info.module_prefixes[1])
let first = a
.module_info
.to_path_literal_string(&a.name, a.module_info.project_name());
let second = b
.module_info
.to_path_literal_string(&b.name, b.module_info.project_name());
first.cmp(&second)
});
links_vec.push((block_title, doc_link));
}
Expand Down

0 comments on commit 3334843

Please sign in to comment.