Stefan
Stefan

Reputation: 4317

Cross referencing decorators

The python domain in sphinx has .. py:decorator:: to document decorators, but how to cross reference a decorator?

For functions (documented with .. py:function::) there is :py:func:. What is the equivalent for decorators?

Upvotes: 3

Views: 220

Answers (1)

Stefan
Stefan

Reputation: 4317

I found the answer in sphinx's documentation:

There is no py:deco role to link to a decorator that is marked up with this directive; rather, use the py:func role. http://sphinx-doc.org/domains.html#directive-py:decorator

The official solution is to use :py:func:. It works too. Unfoutunately sphinx adds brackets after the decorator name.

text py:func:`mydecorator` text

becomes in the output:

text mydecorator() text

The brakets can be disabled globally, but I quite like them when referencing real functions.

Upvotes: 2

Related Questions