7

I know how to remove the module prefix for functions in automodule directive by set "add_module_names = False". Remove package and module name from sphinx function

However it can't remove the module prefix for the args in automodule directive. Below is the document generated by automodule.

you can see the data type of self arg has a long prefix like "PyPhysLeo.data_core".


data_core submodule

class BufferDataD a class which manage CPU buffer and GPU buffer simultaneously, data type is double

CPU2GPU(self: PyPhysLeo.data_core.BufferDataD) → None

GPU2CPU(self: PyPhysLeo.data_core.BufferDataD) → None

allocateCPU(self: PyPhysLeo.data_core.BufferDataD) → None

allocateGPU(self: PyPhysLeo.data_core.BufferDataD) → None

setZeroCPU(self: PyPhysLeo.data_core.BufferDataD) → None

setZeroGPU(self: PyPhysLeo.data_core.BufferDataD) → None

size(self: PyPhysLeo.data_core.BufferDataD) → int

mzjn
  • 48,958
  • 13
  • 128
  • 248
徐力有
  • 79
  • 4
  • Do you actually have "self" in the output? `self` is the conventional name of the implicit first argument of an instance method. Usually it is not shown in documentation. – mzjn Jul 18 '18 at 08:13
  • @mzjn I check the output of "help(PyPhysLeo.data_core.BufferDataD)" in python interpreter, it has the self arg. Actually, module PyPhysLeo is a module created by pybind11. So maybe I need to search relative information about pybind11 rather than sphinx. It is not a problem with sphinx – 徐力有 Jul 18 '18 at 13:51
  • @mzjn this is because the pybind11 will automatically generate function signature . But what it generates is the tedious one, and the sphinx just bring it out. Now I //disable auto function signature in module init process py::options options; options.disable_function_signatures(); Then sphinx behave as what I want. I think I need to close this question, thanks for your reply. – 徐力有 Jul 18 '18 at 14:18

1 Answers1

0

The signatures generated by pybind11 always are long and tedious(has self arg, type may has long module prefix). So the best way is to disable these signatures by adding code py::options options;options.disable_function_signatures(); to your module init function. Then you need to write your own signature in the first line of the docstring like

setZeroGPU() -> None

    reset GPU buffer data to zero

    :return: None
    :rtype: None

setZeroGPU() -> None is the signature and it is in the first line.

Because "autodoc_docstring_signature" in conf.py is set to True by default, sphinx will automatically try to read function signature from the first line of docstring. At last, you can get a beautiful document like this.

setZeroGPU() → None
    reset GPU buffer data to zero

    返回: None
    返回类型:   None
徐力有
  • 79
  • 4