papyri 0.0.8 Pypi GitHub

NotesParameters
get_example_data(self, example_section, *, obj, qa: 'str', config, log) -> 'Tuple[Section, List[Any]]'

One of the section in numpydoc is "examples" that usually consist of number if paragraph, interleaved with examples starting with >>> and ...,

This attempt to parse this into structured data, with text, input and output as well as to infer the types of each token in the input examples.

This is currently relatively limited as the inference does not work across code blocks.

Notes

We do not yet properly handle explicit exceptions in examples, and those are seen as Papyri failures.

The capturing of matplotlib figures is also limited.

Parameters

example_section :

The example section of a numpydoc parsed docstring

obj :

The current object. It is common for the current object/function to not have to be imported imported in docstrings. This should become a high level option at some point. Note that for method classes, the class should be made available but currently is not.

qa :

The fully qualified name of current object

config : Config

Current configuration

log :

Logger instance

Extract example section data from a NumpyDocString

Examples

Those are self examples, generating papyri documentation with papyri should be able to handle the following

A simple input, should be execute and output should be shown if --exec option is set

>>> 1+1
>>> 2+2
4

Output with Syntax error should be marked as so.

This example does not not appear to be valid Python Syntax
>>> [this is syntax error]

if matplotlib and numpy available, we shoudl show graph

>>> import matplotlib.pyplot as plt
... import numpy as np
... x = np.arange(0, 10, 0.1)
... plt.plot(x, np.sin(x))
... plt.show()

Note that in the above we use :None:None:`plt.show`, but we can configure papyri to automatically detect when figures are created.

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /papyri/gen.py#984
type: <class 'function'>
Commit: