jazzy
jazzy copied to clipboard
Order of functions added by extension seems somewhat random
If I extend a class in several places, the new functions do get documented within the original class, but their order seems to be just whatever order Jazzy parsed the files in. Is there a way I can force the order of the new functions or have them just be alphabetized amongst the classes "native" functions?
Currently all extension methods appear after all methods from the base type, but there's no deterministic sorting beyond that.
I like the idea of being able to order extension, but am not sure how it could work elegantly. If you were to specify an order or sorting, how would you imagine it working: in config in or in the docs themselves?
I'd be satisfied with alphabetical sorting by default. Anything more specific feels like it would be thought of as too much work for the result. If it were specified, I would say the config file would need to allow children added under the specific class, not based on anything in the docs themselves. Thank you for the consideration of this issue.
To clarify, alphabetized after the base type's methods would be fine.
I'd be satisfied with alphabetical sorting by default
I read somewhere else (can't find it though) that this change has been made. I don't have a project I can test Jazzy with yet (putting one together) so interested in what others have to say.
No, I think extensions are still grouped by file.
There is nothing random here. Methods and properties (within a given scope) are in precisely the order they appear in source.
You can manipulate this order to your heart’s content by arranging individual declarations within their respective file and arranging whole files in the Xcode project under Build Phases → Compile Sources. Drag the files around in the list to sort them.
If you are using the Swift Package Manager, swift package generate-xcodeproj
will arrange the files in the build list more or less the same as Finder does.
Alphabetization, if still necessary, should be optional so that it doesn’t break the existing fine‐grained control.