Goto Definition from Documentation

Index of All Documentation » Wing Pro Reference Manual » Source Code Editor » Source Assistant »

PEP 287 docstrings may include references that link to the point of definition of a named symbol in Python code. This is done using an interpreted text role in the following form:


The symbol may be a simple name like MyClass or a dotted name like modulename.MyClass or modulename.MyClass.SomeMethod.

When docstrings containing symbol references are rendered in the Source Assistant, they will generate a link to the symbol's point of definition. Clicking the link will resolve the point of definition by looking first for the symbol in the same scope as the class, method, or function that the docstring describes, and if that is unsuccessful then by attempting to look up the name on the project's effective Python Path.

To return from the point of definition, use the back arrow in the top left of the editor area.

For example, specifying :py:`path` looks for path in the scope of the described symbol and then looks for a module named path on the Python Path. If :py:`sys.path.abspath` is used instead then the process looks for sys.path.abspath in the scope of the described symbol, then looks for a module named sys with an attribute path.abspath, and finally looks for a module named sys.path with an attribute abspath. This works even if the referenced module is not imported in the scope of the described object.

In addition to the :py: role, Wing follows Sphinx to support the py:mod, py:func, py:data, py:const, py:class, py:meth, py:attr, py:exc, and py:obj interpreted text roles. However, there is no difference in how the point of definition is found for each of these.