Conversation
mhvk
left a comment
There was a problem hiding this comment.
Good idea! Some comments inline.
sphinx_automodapi/automodapi.py
Outdated
|
|
||
| * ``:sort:`` | ||
| Sort the objects in the module alphabetically. The default is to | ||
| sort by the order they appear in the module (as specified by `__all__` |
There was a problem hiding this comment.
Looking at the actual code below, I see that without __all__, our use of dir(module) automatically sorts things. So, maybe rewrite as
Sort the objects in the module alphabetically also if they are
explicitly given in ``__all__`` (if ``__all__`` is not present, the
objects are found using `dir`, which always gives a sorted list).
Actually, writing this suggests that perhaps the default should be to sort also with __all__ and have a nosort option. In that case,
Do not sort the objects alphabetically, but use the order given by ``__all__``.
This option has no effect if a module does not have ``__all__``.
But probably what you have makes a bit more sense.
sphinx_automodapi/utils.py
Outdated
| else: | ||
| pkgitems = [(k, getattr(mod, k)) for k in dir(mod) if k[0] != '_'] | ||
|
|
||
| if sort: |
There was a problem hiding this comment.
Given that dir is guaranteed to sort, this could be moved inside the if statement. (This is true even if __dir__ is defined and returns something unsorted.)
|
Maybe we should change the option from |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #182 +/- ##
==========================================
+ Coverage 90.24% 90.28% +0.03%
==========================================
Files 28 28
Lines 1179 1204 +25
==========================================
+ Hits 1064 1087 +23
- Misses 115 117 +2 ☔ View full report in Codecov by Sentry. |
|
We do need to add a test... |
|
@nstarman , are you still interested in pursuing this? |
|
Yes. Thanks for putting it back on my radar. |
d259d02 to
e02d4ee
Compare
|
Hm. Not sure why the test is failing so early. I copied it from a test above! |
|
I cannot tell why it is failing from the log. You might need to run this test locally and debug. |
|
I would welcome help on the test suite for this PR. The PR works when tested on Astropy, I just can't wrangle this library's test suite. |
|
@nstarman - I think I found the problem: you missed how |
|
Thanks @mhvk! I just cherry-picked your commit from your branch https://github.com/mhvk/sphinx-automodapi/tree/sort-option |
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
|
Rebased to fix conflict. |
|
Ping @eteq, I think this is now ready for review! |
mhvk
left a comment
There was a problem hiding this comment.
I think this looks all good, but then I looked at it already. The one unfortunate thing about the last commit (mine...) is that it does a lot of unrelated blackening as well - this makes it much harder to review. Could you try adding that commit again without that happening? (I checked, my original commit did not do this). I will make review much easier for @eteq.
Signed-off-by: nstarman <nstarman@users.noreply.github.com> # Conflicts: # sphinx_automodapi/automodsumm.py
|
Done! Had to google how VSCode can do saving w/out formatting (I have mine set up to run code quality tools on save). |
| """ | ||
|
|
||
|
|
||
| def test_sort(tmpdir): |
There was a problem hiding this comment.
Since this is new test, no reason to use legacy tmpdir? Can you please switch to tmp_path? Thanks!
There was a problem hiding this comment.
Unfortunately this will require a larger refactor, because run_sphinx_in_tmpdir requires a tmpdir object! (the .strpath)
There was a problem hiding this comment.
Ah ok, I opened #188 . Thanks for the clarification!
pllim
left a comment
There was a problem hiding this comment.
Given this is opt-in, let's merge. Thanks!
Do you need an immediate release?
I wonder whether we could clean out 1 or 2 more of the remaining PRs, so we don't end up with single PR releases :) |
Ping @mhvk