I posted this here on StackOverflow
<https://stackoverflow.com/questions/56137571/change-the-name-of-a-module-in-python-sphinxs-autodoc>
as well, thinking it might get some more meaningful eyeballs here though. I
am looking to autodoc some functions in a Python module using
`autofunction`. Let's say, for example, the functions are defined in
`mylib/funcs/a.py` and that file looks something like this:
def myfunc(arg):
""" My function does something """
return
My intent is to have users call that function from the root of the library
rather than at that file/module path. In other words *mylib.myfunc* rather
than *mylib.funcs.a.myfunc*.
However, for reasons outside of the scope of this question that I'd rather
not get in to, when you do *import mylib; mylib.myfunc* or do *from mylib
import myfunc* it doesn't point to the actual function where the docstring
is. In other words, I cannot reference the actual myfunc in the
*mylib/__init__.py* file.
I can get the function to auto doc like so:
..currentmodule:: mylib.funcs.a
..autofunction:: myfunc
However, the resulting documentation has a signature that looks like
*mylib.funcs.a.myfunc*. I would like it to just be *mylib.myfunc*.
If I wasn't using autodoc I could do something like this in my sphinx docs:
.. function:: myfunc(arg)
:module: mylib
So I suppose my question is this: Is there a way to "alias" or change the
label of a *module* when using autodoc on a function? I have looked at the
preprocessing events for processing a docstring and the signature but those
don't seem to allow you to change how the module is displayed.
I have also tried setting *__module__* in the *a.py* file and in a few
other places, based on the source code and the *get_real_modname* method in
autodoc
<https://github.com/sphinx-doc/sphinx/blob/master/sphinx/ext/autodoc/__init__.py#L342>,
but it doesn't seem to have any effect.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/8285591b-2b34-4686-8f1f-41c13fdd1285%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.