Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of classes not stable #473

Closed
esad opened this issue Feb 4, 2016 · 4 comments
Closed

Order of classes not stable #473

esad opened this issue Feb 4, 2016 · 4 comments
Assignees
Milestone

Comments

@esad
Copy link
Collaborator

esad commented Feb 4, 2016

I'm working on updating the integration specs for #466. However, when I run rake spec from the current jazzy master it doesn't pass because the order of classes in the generated docs seems different than the one in integration specs (see screenshots).

I'm using ruby 2.3.0p0

screen shot 2016-02-04 at 14 53 01
screen shot 2016-02-04 at 14 52 55

esad added a commit to PSPDFKit-labs/jazzy that referenced this issue Feb 4, 2016
@esad
Copy link
Collaborator Author

esad commented Feb 4, 2016

I think the cause for this is

https://github.com/realm/jazzy/blob/master/lib/jazzy/doc_builder.rb#L34

There, we first sort by name and then by nav_order. In case that nav_order is nil (which it is for classes in realm-objc), one would think that the first sort would remain stable, but it doesn't (at least under ruby 2.3).

Example:

2.3.0 :007 > %w(b z a X z Z ZZ Z).sort_by {|x| x}
 => ["X", "Z", "Z", "ZZ", "a", "b", "z", "z"] 

2.3.0 :008 > %w(b z a X z Z ZZ Z).sort_by {|x| x}.sort_by { nil }
 => ["z", "Z", "Z", "ZZ", "a", "b", "z", "X"] # <- Whoops?

# Proposed fix:
2.3.0 :009 > %w(b z a X z Z ZZ Z).sort_by {|x| x}.sort_by { |x| [nil,x] }
 => ["X", "Z", "Z", "ZZ", "a", "b", "z", "z"] 

@esad esad mentioned this issue Feb 4, 2016
esad added a commit to PSPDFKit-labs/jazzy that referenced this issue Feb 4, 2016
pcantrell added a commit that referenced this issue Feb 6, 2016
@p2
Copy link

p2 commented Feb 9, 2016

I came here because of a similar issue -- the first and last items in the Classes list are exchanged. It seems that's what's happening in your example as well (RLMArray should be first, RLMSortDescriptor last). I'll assume it's the same issue and check once this fix here has been rolled out. 👍🏼

@pcantrell
Copy link
Collaborator

It should be fixed on master, if you want to verify the fix! (git clone the repo and run bin/jazzy from the clone.)

@p2
Copy link

p2 commented Feb 9, 2016

Yes, that does it, great!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants