sort: ["source-order"] should apply to group ordering, not just group members
Current Behavior
When sort: ["source-order"] is configured in typedoc.json, it only affects the ordering of items within groups, not the groups themselves. Groups are always ordered alphabetically.
Example configuration:
{
"sort": [
"source-order"
]
}
Source code order:
/**
* @group Comparators
*/
export function ascending() { }
/**
* @group Factories
*/
export function by() { }
/**
* @group Combinators
*/
export function reverse() { }
Generated docs show groups in alphabetical order:
- Combinators
- Comparators
- Factories
Expected Behavior
When sort: ["source-order"] is configured, groups whose order is not explicitly specified in groupOrder should be sorted by source order rather than alphabetically:
- Comparators (first
@groupin source) - Factories (second
@groupin source) - Combinators (third
@groupin source)
Note: groupOrder should maintain precedence when explicitly specified. This is about the fallback behavior for unspecified groups.
Current Workaround
Must explicitly configure groupOrder:
{
"sort": [
"source-order"
],
"groupOrder": [
"Comparators",
"Factories",
"Combinators",
"*"
]
}
Proposed Solution
Modify group sorting behavior to respect the sort option when groupOrder doesn't explicitly specify all groups:
- Groups listed in
groupOrdermaintain their explicit order (preserves existing behavior) - Unlisted groups fall back to
sort: ["source-order"]if configured, alphabetically otherwise - Update groupOrder documentation from "Groups whose order is not specified will be sorted alphabetically" to "Groups whose order is not specified will be sorted by source order if
sort: ["source-order"]is configured, alphabetically otherwise."
if sort: ["source-order"] is configured, alphabetically otherwise.
This is a hard no. Options which conditionally change their behavior depending on other option values cause extreme maintenance pain because they explosively increase the number of possible combinations which might cause unexpected results.
The idea of always sorting groups (and categories!) based on the relative sorting of their children if an explicit order for groups wasn't specified makes a lot of sense to me, though it's a breaking change that will need to wait for 0.29. Experimentally changing this for TypeDoc's docs changes nearly every page (mostly due to properties showing up before methods now)
I'm probably going to take some time late December/early January to make the few breaking changes I have planned for 0.29, I think this makes sense then