I have a project with some functions documented in the napoleon numpy style. In the spirit of numpyness, I have a bunch of function arguments that are of the class array-like
. Here is an example:
def foo(x, y):
"""
Foo the arguments together to make a bar.
Parameters
----------
x : array-like
This is an argument.
y : array-like
I like it, give me another!
Returns
-------
bar : numpy.ndarray
Works every time
"""
pass
This works just fine, and the type is included in the output without a link:
The problem is that I get a warning on every line of every function that has this:
/.../my_project/my_module.py:docstring of my_project.my_module.foo:: WARNING: py:class reference target not found: array-like
/.../my_project/my_module.py:docstring of my_project.my_module.foo:: WARNING: py:class reference target not found: array-like
I am fairly convinced that there is some solution. It appears that PR #7690 addressed this somehow, but I can't find a meaningful reference "preprocessing" anywhere in the napoleon or broader sphinx documentation.
So how do I get rid of the warning?
Digging through the PR, I found where to look: the
napoleon_type_aliases
configuration item allows you to set up a mapping for things likearray-like
,dict-like
, etc. In this particular case, adding the following toconf.py
did the trick:napoleon_use_param
has to beTrue
for this to work. It's documented as defaulting toTrue
, but somewhere along the way in my setup, it got unset. It never hurts to be extra safe.To link to the
array_like
term on the numpy site, theintersphinx
extension must be enabled, andintersphinx_mapping
inconf.py
must link to numpy: