readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
415 stars 126 forks source link

Don't force member sort order to alphabetic #362

Closed ashb closed 1 year ago

ashb commented 1 year ago

sphinx.ext.autodoc has a member-order: directive, and this powers the sort_member function[1] to sort object members for us -- by removing the sorted call ourselves we allow the "bysource" mode to work: with the sorted call, since we don't set self.analyzer no extra sorting happens, so the :member-order: bysource setting has no effect.

The default sort mode for autodoc is alphabetical, so this should result in no changes to docs by default

ashb commented 1 year ago

I have tested this manually like so -- and changing the member-order directive does change the output order.

.. autoapimodule:: airflow.policies
  :no-members:
  :members: task_policy, dag_policy, task_instance_mutation_hook, pod_mutation_hook
  :member-order: bysource
ashb commented 1 year ago

~I should add tests for this.~ Done.

ashb commented 1 year ago

@AWhetter cc if you have time to take a look that would be ace.

AWhetter commented 1 year ago

Looks great! Thanks for the change.

AWhetter commented 1 year ago

@ashb Sorry it took so long to get this released. There were some test failures that had to be addressed first. This just got released in v2.0.1. Let me know if you encounter any issues.