简体   繁体   中英

Python - How NOT to sort Sphinx output in alphabetical order

With Sphinx for Python how is it possible to avoid having all the method/function names sorted alphabetically in HTML? I want to keep them in the very same order as they are found in the source code.

From the sphinx.ext.autodoc documentation :

autodoc_member_order

This value selects if automatically documented members are sorted alphabetical (value 'alphabetical'), by member type (value 'groupwise') or by source order (value 'bysource'). The default is alphabetical.

Note that for source order, the module must be a Python module with the source code available.

So somewhere in your conf.py file, put:

autodoc_member_order = 'bysource'

For a single .rst file (watch the last string):

foo.bar module
=========================

.. automodule:: foo.bar
   :members:
   :undoc-members:
   :show-inheritance:
   :member-order: bysource

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM