bundles / papyri 0.0.10 / papyri / gen / Gen / get_example_data
function
papyri.gen:Gen.get_example_data
source: /papyri/gen.py :826
Signature
def get_example_data ( self , example_section : Any , * , obj : Any , qa : str , config : Config , log : logging.Logger ) → tuple[Section, list[Any]] Summary
Extract example section data from a NumpyDocString
Extended Summary
One of the section in numpydoc is "examples" that usually consist of number of paragraphs, interleaved with examples starting with >>> and ...,
This attempts 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.
Parameters
example_sectionThe example section of a numpydoc parsed docstring
objThe 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: strThe fully qualified name of current object
config: ConfigCurrent configuration
logLogger instance
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.
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 set1+1
✗2+2
✓[this is syntax error]
⚠import matplotlib.pyplot as plt import numpy as np x = np.arange(0, 10, 0.1) plt.plot(x, np.sin(x)) plt.show()⚠
Aliases
-
papyri.gen.Gen.get_example_data