vtkmodules.generate_pyi
#
This program will generate .pyi files for all the VTK modules in the “vtkmodules” package (or whichever package you specify). These files are used for type checking and autocompletion in some Python IDEs.
The VTK modules must be in Python’s path when you run this script. Options are as follows:
-p PACKAGE The package to generate .pyi files for [vtkmodules] -o OUTPUT The output directory [default is the package directory] -e EXT The file suffix [.pyi] -i IMPORTER The static module importer (for static builds only) -h HELP
With no arguments, the script runs with the defaults (the .pyi files are put inside the existing vtkmodules package). This is equivalent to the following:
python -m vtkmodules.generate_pyi -p vtkmodules
To put the pyi files somewhere else, perhaps with a different suffix:
python -m vtkmodules.generate_pyi -o /path/to/vtkmodules -e .pyi
To generate pyi files for just one or two modules:
python -m vtkmodules.generate_pyi -p vtkmodules vtkCommonCore vtkCommonDataModel
To generate pyi files for your own modules in your own package:
python -m vtkmodules.generate_pyi -p mypackage mymodule [mymodule2 ...]
Module Contents#
Classes#
Functions#
Check for VTK’s custom method descriptor |
|
Check for namespaces within a module |
|
Check for enums (currently derived from int) |
|
Generate a typename that can be used for annotation. |
|
Generate a typename, or if necessary, a forward reference. |
|
Build a graph from a module’s dictionary. |
|
Helper for topological sorting. |
|
Sort a graph and return the sorted items. |
|
Return the items from a module’s dictionary, topologically sorted. |
|
Print a parse error, syntax or otherwise. |
|
Return the new text to be used for an annotation. |
|
Fix the annotations in a method definition. The signature must be a single-line function def, no decorators. |
|
Process a method signature and add it to the list. |
|
Return a list of method signatures found in the docstring. |
|
Get constructors from the class documentation. |
|
If method has no “self”, add @static decorator. |
|
Add the given indent before every line in the string. |
|
Fake a namespace by creating a dummy class. |
|
Generate all the method stubs for a class. |
|
Generate the contents of a .pyi file for a VTK module. |
|
Data#
API#
- vtkmodules.generate_pyi.types#
None
- vtkmodules.generate_pyi.ismethod#
None
- vtkmodules.generate_pyi.isclass#
None
- vtkmodules.generate_pyi.vtkmethod#
None
- vtkmodules.generate_pyi.template#
None
- vtkmodules.generate_pyi.isvtkmethod(m)#
Check for VTK’s custom method descriptor
- vtkmodules.generate_pyi.isnamespace(m)#
Check for namespaces within a module
- vtkmodules.generate_pyi.isenum(m)#
Check for enums (currently derived from int)
- vtkmodules.generate_pyi.typename(o)#
Generate a typename that can be used for annotation.
- vtkmodules.generate_pyi.typename_forward(o)#
Generate a typename, or if necessary, a forward reference.
- class vtkmodules.generate_pyi.Graph#
A graph for topological sorting.
Initialization
- __getitem__(name)#
- __setitem__(name, node)#
- class vtkmodules.generate_pyi.Node(o, d)#
A node for the graph.
Initialization
- vtkmodules.generate_pyi.build_graph(d)#
Build a graph from a module’s dictionary.
- vtkmodules.generate_pyi.sorted_graph_helper(graph, m, visited, items)#
Helper for topological sorting.
- vtkmodules.generate_pyi.sorted_graph(graph)#
Sort a graph and return the sorted items.
- vtkmodules.generate_pyi.topologically_sorted_items(d)#
Return the items from a module’s dictionary, topologically sorted.
- vtkmodules.generate_pyi.string#
None
- vtkmodules.generate_pyi.identifier#
None
- vtkmodules.generate_pyi.indent#
None
- vtkmodules.generate_pyi.has_self#
None
- vtkmodules.generate_pyi.keychar#
None
- vtkmodules.generate_pyi.parse_error(message, text, begin, pos)#
Print a parse error, syntax or otherwise.
- vtkmodules.generate_pyi.annotation_text(a, text, is_return)#
Return the new text to be used for an annotation.
- vtkmodules.generate_pyi.fix_annotations(signature)#
Fix the annotations in a method definition. The signature must be a single-line function def, no decorators.
- vtkmodules.generate_pyi.push_signature(o, l, signature)#
Process a method signature and add it to the list.
- vtkmodules.generate_pyi.get_signatures(o)#
Return a list of method signatures found in the docstring.
- vtkmodules.generate_pyi.get_constructors(c)#
Get constructors from the class documentation.
- vtkmodules.generate_pyi.handle_static(o, signature)#
If method has no “self”, add @static decorator.
- vtkmodules.generate_pyi.add_indent(s, indent)#
Add the given indent before every line in the string.
- vtkmodules.generate_pyi.namespace_pyi(c, mod)#
Fake a namespace by creating a dummy class.
- vtkmodules.generate_pyi.class_pyi(c)#
Generate all the method stubs for a class.
- vtkmodules.generate_pyi.module_pyi(mod, output)#
Generate the contents of a .pyi file for a VTK module.
- vtkmodules.generate_pyi.main(argv=sys.argv)#