[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 08:28:00 PDT 2024


================
@@ -312,6 +322,20 @@ struct SymbolInfo : public Info {
 
   std::optional<Location> DefLoc;     // Location where this decl is defined.
   llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.
+
+  bool operator<(const SymbolInfo &Other) const {
+    // Sort by declaration location since we want the doc to be
+    // generated in the order of the source code.
----------------
ilovepi wrote:

Documentation often sorts methods by name, so its easy to find things. As an example, here's Rust's `Vec` documentation https://doc.rust-lang.org/std/vec/struct.Vec.html. Methods are sorted in the navigation window and within the body, despite not being that way in source.

Doxygen maintains source order, so its fine to do it that way for now, but we may want to consider making that a configurable option, since I think its more user friendly to do it that way (and arguably more modern).

https://github.com/llvm/llvm-project/pull/101387


More information about the cfe-commits mailing list