Skip to content

Respect the order of selection.members #102

Closed

Description

@hSaria

Is your feature request related to a problem? Please describe.
Respect the order of selection.members when displaying the attributes/methods of a class.

Describe the solution you'd like
Ordering the sections of a class according to how they were listed under selection.members.

Describe alternatives you've considered
A new option can be introduced that deals specifically with sorting, but I feel that introduces one more thing to maintain.

Another option would be to sort the methods in the same order as they were defined in the class, though I can see this becoming an issue for folks that want to sort their methods in the code in one way and their docs in another.

Additional context
Assuming there is a class with the methods add, subtract, multiply, and divide, the docs currently list them in alphabetical order.

I would like to manually specify an order, maybe something like so:

::: module.Class
    selection:
      members:
        - add
        - subtract
        - multiply
        - divide

Activity

  1. added
    feature
    on Apr 27, 2020
  2. pawamoy commented on Apr 27, 2020

    @pawamoy
    Member

    I think it would be fair to respect the specified members order, though I'd like to have the opinion of others using this feature 🙂 @ofek @florimondmanca @StephenBrown2 @chrieke (from #44)

    Additionally, a sorting option would be nice. Sphinx has that: source order, alphabetical order, and group order IIRC?

  3. ofek commented on Apr 27, 2020

    @ofek
    Contributor

    Yes please! The natural order of members should be the default.

  4. StephenBrown2 commented on Apr 27, 2020

    @StephenBrown2
    Contributor

    Just a note, Sphinx sorts the members by default. TIL that that's configurable!

  5. ofek commented on May 1, 2020

    @ofek
    Contributor

    I'll take any way we choose 🙂

  6. pawamoy commented on May 1, 2020

    @pawamoy
    Member

    Let's do this then. Just opened mkdocstrings/pytkdocs#29

  7. added a commit that references this issue on May 1, 2021
    5b0704d
  8. ofek commented on Nov 24, 2021

    @ofek
    Contributor

    @pawamoy Hmm, I see your preferred solution in mkdocstrings/pytkdocs#29 but wouldn't it make more sense to have the renderer read the members and act accordingly? Especially since the renderer has since added a new sorting option #274

  9. pawamoy commented on Dec 14, 2021

    @pawamoy
    Member
  10. pawamoy commented on May 28, 2022

    @pawamoy
    Member

    Fixed in the new handler (not the legacy one, though it's possible to fix now).

  11. samuelcolvin commented on Jul 20, 2023

    @samuelcolvin

    This is marked as closed, but as far as I can tell, the original request (which is what I need) to respect the order of members is still not supported - the only options are alphabetical and source - as per here.

    Is there any possibility to re-open this and provide a way to respect the order from member?

  12. pawamoy commented on Jul 20, 2023

    @pawamoy
    Member

    The members_order option is ignored when a list of members is specified, however the group_by_category one still comes into play (and it is on by default). Maybe try to set it to false to see if the order is better? We can consider ignoring this option as well when members are specified.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    extractor: pytkdocsfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions