Member order

54 views
Skip to first unread message

Mmanu Chaturvedi

unread,
Feb 5, 2020, 11:58:23 PM2/5/20
to sphinx-users
Hi,

Consider the following problem:

Suppose we have three methods bound to a class `C` with the following names:
`__init__`, `a` and `A`.

Now, in the documentation created by sphinx, we'd have documentation in order (when `member-order` is `alphabetic`) :
`A`, `__init__` and `a`.

it seems like it is so because:  `sorted(["a", "__init__", "A"]) == ["A", "__init__", "a"]`

------- 

I know that it's not recommended by PEP8, but we have a few methods which start with a capital letter. ( We're creating python bindings via pybind11).

This behavior of sphinx, is leading to documentation which looks unsightly because sometimes `__init__` comes way down after all the methods which start with a capital letter:
https://www.photobox.co.uk/my/photo/full?photo_id=502682079763

I was wondering how could we solve it?

Thanks,
Mmanu



Message has been deleted

Komiya Takeshi

unread,
Feb 9, 2020, 8:31:24 AM2/9/20
to sphinx...@googlegroups.com
Hi,

Is this resolved if we'll add an option for sorting methods by
definition order (in source code)?
We have an issue to add such option. I'd like to know it helps your case or not.

Thanks,
Takeshi KOMIYA

2020年2月6日(木) 13:58 'Mmanu Chaturvedi' via sphinx-users
<sphinx...@googlegroups.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/abcfbd61-6562-4d65-ae05-a6ff3b5fed1e%40googlegroups.com.

Mmanu Chaturvedi

unread,
Feb 17, 2020, 1:15:52 PM2/17/20
to sphinx-users
Hi Takeshi Komiya,

Thanks for the reply! 

> Is this resolved if we'll add an option for sorting methods by
> definition order (in source code)?

Yes, that could possibly resolve the issue.  We seem to have the `bysource` option, which seems to be for sorting by source, but it doesn't work for us.
The `self.analyzer` gets set to `None`:


Also, there seem to be open issues related to `bysource`:

Thank you,
Mmanu
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx...@googlegroups.com.

Mmanu Chaturvedi

unread,
Feb 17, 2020, 5:22:52 PM2/17/20
to sphinx-users
I tried to create a PR, which adds the ability to add a custom key function:

https://github.com/sphinx-doc/sphinx/pull/7177

If you think it's acceptable, I can create a corresponding issue as well.
When the python code is in `.so` format which we import, the analyzer doesn't work on it.
Message has been deleted

Komiya Takeshi

unread,
Feb 20, 2020, 12:21:47 PM2/20/20
to sphinx...@googlegroups.com
Hi,

If you'd like to sort members by definition order, it would be better
to follow PEP-520. Since py36, using cls.__dict__ is much appropriate
way to sort members "by source" instead of analyzer.
https://www.python.org/dev/peps/pep-0520/

Thanks,
Takeshi KOMIYA

2020年2月18日(火) 3:15 'Mmanu Chaturvedi' via sphinx-users
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/e7b4e2e6-d401-4b05-a531-5c4bebdb2469%40googlegroups.com.

Mmanu Chaturvedi

unread,
Feb 24, 2020, 11:00:39 AM2/24/20
to sphinx-users
Hi Takeshi Komiya,

Thanks!  This must be the issue, right?

Komiya Takeshi

unread,
Feb 29, 2020, 1:47:53 AM2/29/20
to sphinx...@googlegroups.com
Oh, I'd forgotten it. But, yes, I meant it.

2020年2月25日(火) 1:00 'Mmanu Chaturvedi' via sphinx-users
<sphinx...@googlegroups.com>:
>
> Hi Takeshi Komiya,
>
> Thanks! This must be the issue, right?
> https://github.com/sphinx-doc/sphinx/issues/5270
>
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/d153f190-405c-42f8-aa18-16b4553194d3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages