jazzy icon indicating copy to clipboard operation
jazzy copied to clipboard

Order of functions added by extension seems somewhat random

Open aure opened this issue 9 years ago • 6 comments

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?

aure avatar Dec 19 '15 05:12 aure

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?

pcantrell avatar Dec 20 '15 21:12 pcantrell

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.

aure avatar Dec 20 '15 23:12 aure

To clarify, alphabetized after the base type's methods would be fine.

aure avatar Dec 20 '15 23:12 aure

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.

pigeon-archive avatar Nov 23 '16 15:11 pigeon-archive

No, I think extensions are still grouped by file.

jpsim avatar Nov 26 '16 04:11 jpsim

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.

SDGGiesbrecht avatar Dec 16 '16 00:12 SDGGiesbrecht