ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

How to properly reference ipywidgets elements in sphinx documentation for third party packages?

Open jmborr opened this issue 7 years ago • 4 comments
trafficstars

Referencing ipywidgets components in RST documents doesn't include a link after building In my conf.py file:

# Domains for intersphinx inventory file objects.inv
intersphinx_mapping = {
    'ipywidgets': ('http://ipywidgets.readthedocs.io/en/latest', None),
}

Then in the docstrings of my class methods, I've tried referencing class Widget in different ways

    def link_widget(self, widget, mapping=None):
        r"""Link the value of a single ipywidget to one trait, or the values
        of the element widgets of a composite ipywidget to different traits.
        The specific traits can be specified with the `mapping` argument.

        :class:`~ipywidgets:Widget`
        :class:`~ipywidgets:widget.Widget`
        :class:`~ipywidgets:widgets.widget.Widget`

        :class:`~ipywidgets:ipywidgets.Widget`
        :class:`~ipywidgets:ipywidgets.widget.Widget`
        :class:`~ipywidgets:ipywidgets.widgets.widget.Widget`

        Parameters
        ----------
        widget: :class:`~ipywidgets:ipywidgets.widgets.widget.Widget`
        mapping : str, dict, or **None**
...

None of these syntax seem to work. Can you please specify which syntax to use?

jmborr avatar Jun 13 '18 01:06 jmborr

ipywidgets currently does not have correctly configured api docs, so it does not export any references to use for intersphinx. To inspect the ipywidgets intersphinx inventory, the following code is useful:

from sphinx.ext.intersphinx import inspect_main
inspect_main(['http://ipywidgets.readthedocs.io/en/latest/objects.inv'])

vidartf avatar Jun 13 '18 09:06 vidartf

I decided to insert hyperlinks pointing to elements in the latest release tag, for instance class Widget

    def link_widget(self, widget, mapping=None):
        r"""Link the value of a single ipywidget to one trait, or the values
        of the element widgets of a composite ipywidget to different traits.
        The specific traits can be specified with the `mapping` argument.

        Parameters
        ----------
        widget: `Widget <https://github.com/jupyter-widgets/ipywidgets/blob/v7.0.0a1/ipywidgets/widgets/widget.py#L238>`_
       .
       .

jmborr avatar Jun 13 '18 14:06 jmborr

I'm going to keep this issue open in order to track as a request for API docs (which would be nice).

vidartf avatar Jun 13 '18 15:06 vidartf

It seems this issue got addressed some time in the past, there are API docs now:

https://ipywidgets.readthedocs.io/en/stable/reference/ipywidgets.html

maxnoe avatar Jul 15 '24 11:07 maxnoe