diff --git a/CHANGELOG.md b/CHANGELOG.md index ea1da31..1aa9825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ SPDX-License-Identifier: MIT - Show the definition for constants and typedefs. - Fix group and ID for typdef items. - Extract the description of module items as HTML instead of plain text. + - Sort implementations alphabetically. ## v0.1.2 (2020-07-25) diff --git a/src/parser.rs b/src/parser.rs index 1acf784..92f55c9 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -484,6 +484,8 @@ fn get_implementation_group( } } + impls.sort(); + Ok(impls.into_member_group(Some(title.to_owned()))) } @@ -578,6 +580,14 @@ impl<'a> MemberDocs<'a> { } } + pub fn sort(&mut self) { + self.docs.sort_by(|d1, d2| { + d1.name + .cmp(&d2.name) + .then_with(|| d1.definition.cmp(&d2.definition)) + }) + } + pub fn push( &mut self, name: &mut Option,