machow / plotnine-docs-demo

MIT License
0 stars 2 forks source link

support numpy xref alias config #7

Open machow opened 1 year ago

machow commented 1 year ago

numpydoc is a tool that translates a docstring to rst for sphinx. It has a few global options you can set. One of these, numpy_xref_aliases let's you specify mappings from "types" specified in docstrings to interlink entries.

This is useful for making terms like dataframe below linkable:

def f(x):
    """
    Parameters
    ------------
    x: dataframe
        Some data

In this case we could use the mapping "dataframe": "pandas.DataFrame".

See

https://github.com/has2k1/plotnine/blob/main/doc/conf.py#L442

numpydoc_xref_aliases = {
    # python
    "sequence": ":term:`python:sequence`",
    "iterable": ":term:`python:iterable`",
    "string": "str",
    "tuples": "tuple",
    "boolean": "bool",
    # numpy
    "array": "numpy.ndarray",
    ...
}