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

bug: Members are not ordered by explicit list #119

Closed
RafaelWO opened this issue Dec 27, 2023 · 3 comments
Closed

bug: Members are not ordered by explicit list #119

RafaelWO opened this issue Dec 27, 2023 · 3 comments
Assignees
Labels
docs Improvements or additions to documentation

Comments

@RafaelWO
Copy link

RafaelWO commented Dec 27, 2023

Description of the bug

Hello, I'm trying to display some members of a module in a specific order. For that, I have the following block in my Markdown file:

::: mymodule
    options:
      members:
      - my_func
      - MyData

The documentation on the members option says:

The members will be rendered in the specified order, regardless of the value of members_order. [source]

But when rendering the page with mkdocs, the member MyData is displayed first:

grafik

To Reproduce

members_order_test.zip

I have compiled a MRE example and attached it as a zip file above. The contents are as follows:

test
├── docs
│   └── index.md
├── mkdocs.yml
├── mymodule
│   └── __init__.py
└── requirements.txt

1. Download it and extract the files
2. Run `cd test`
3. Run `pip install -r requirements.txt`
4. Run `mkdocs serve`
5. Open http://127.0.0.1:8000/ in a browser
6. You should see the same result as in the screenshot above

Full traceback

n/a

Expected behavior

I would expected that mymodule.my_func is displayed first.

Environment information

python -m mkdocstrings_handlers.python.debug  # | xclip -selection clipboard
  • System: Linux-5.15.133.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
  • Python: cpython 3.11.5
  • Environment variables:
  • Installed packages:
    • mkdocs v1.5.3
    • mkdocstrings v0.24.0
    • mkdocstrings-python v1.7.5
    • griffe v0.38.1

Additional context

n/a

@pawamoy
Copy link
Member

pawamoy commented Jan 9, 2024

Hello, thanks for the report!

So, I think it works as intended, however there's a subtlety that should definitely be documented to avoid confusion: objects are still grouped by category (modules, classes, functions, attributes) before being sorted as specified by members or members_order. Can you try disabling grouping to see if it solves your issue? group_by_category: false.

@pawamoy pawamoy added the docs Improvements or additions to documentation label Jan 9, 2024
pawamoy added a commit that referenced this issue Jan 9, 2024
@pawamoy
Copy link
Member

pawamoy commented Jan 9, 2024

I was able to confirm my suggested solution above in your MRE (thanks for it). I pushed an update to the docs, will deploy them now, closing 🙂

@pawamoy pawamoy closed this as completed Jan 9, 2024
@RafaelWO
Copy link
Author

Thanks for the explanation and the update to the docs! It's much clearer now 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants