Sphinx: Question: automodule documentation fails on methods wrapped by a decorator (python 2.7)

Created on 24 Apr 2018  路  2Comments  路  Source: sphinx-doc/sphinx

Subject:

My use case is as follows, I have a decorated method compute_something.
It turns out that the decorator disable Sphinx auto documentation ...

@validate(argument)
def compute_something(param1, param2):
    """

    Compute something

    Parameters
    ----------
    param1 : type
        Description of parameter `param1`.
    param2 : type
        Description of parameter `param2`.

    Returns
    -------
    type
        Description of returned object.

    """
    # do many things 

    return

the .rst file used by Sphinx is as follows

.. automodule:: compute_things
    :members:
    :undoc-members:
    :show-inheritance:

Sphinx generates no doc for this function when I add the decorator
@validate(argument) whereas it works well without the decorator

Is there any work around ?

Environment info

  • OS: Linux Ubuntu 16.04
  • Python version: 2.7.12
  • Sphinx version: 1.7.0
autodoc question

Most helpful comment

Do you use functools.wraps() for the decorator?
https://docs.python.org/3.6/library/functools.html#functools.wraps

All 2 comments

Do you use functools.wraps() for the decorator?
https://docs.python.org/3.6/library/functools.html#functools.wraps

Thanks for your answer, it worked perfectly !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ubershmekel picture ubershmekel  路  3Comments

shimizukawa picture shimizukawa  路  3Comments

shimizukawa picture shimizukawa  路  3Comments

MichiK picture MichiK  路  3Comments

oonid picture oonid  路  3Comments