pygvisuals.util package

Package for useful functionalities not belonging to any other cathegory.

pygvisuals.util.inherit_docstrings_from_superclass(cls, doc_inheritance_specifier='inherit_doc::')[source]

Add docstrings for methods of the class from its superclasses and return it.

Every function from the given class without a __doc__-attribute or with a __doc__-attribute containing the given specifier will get a copy of a __doc__-attribute from a function with the same name from one of its superclasses.

This can be used as a decorator.

This function was taken and modified from the ‘Stack Overflow’ network. The original author is Raymond Hettinger. - original source: https://stackoverflow.com/a/8101598

The original is licensed under Creative Commons Attribution-Share Alike. This function, the functions it relies on included this file and its documentation are therefore licensed under the same license (Adapter’s License). You can find a copy of this license here: https://creativecommons.org/licenses/by-sa/4.0/legalcode And a more readable summary here: https://creativecommons.org/licenses/by-sa/4.0/

The doc_inheritance_specifier will be interpreted similar to a reStructuredText-directive. It will accept one the following parameters:

description: Instead of replacing the specifier and this parameter with all of the superclass’

__doc__-attribute, only the description above the sections Args and Returns will be copied.

arguments: Instead of replacing the specifier and this parameter with all of the superclass’

__doc__-attribute, only the section Args will be copied.

return_values: Instead of replacing the specifier and this parameter with all of the superclass’

__doc__-attribute, only the section Returns will be copied.

all: Replaces the specifier and this parameter with all of the superclass’ __doc__-attribute,

same as if no parameter was given.

Any replacement string from a superclass will have leading and trailing whitespace stripped off so it integrates seamlessly into existing docstrings.

Parameters
  • cls – A class to modify.

  • doc_inheritance_specifier – A string to search for in the __doc__-attributes of functions. If this string is found, it will be replaced with the found __doc__ from a superclass; the rest of the __doc__-attribute remains as before. If this is a falsy value (e.g. None), no such specifier will be searched for; instead only functions without a __doc__ attribute will inherit docstrings from superclasses.

Returns

The class supplied (with the modifications made).

Submodules

pygvisuals.util.constants module

A collection of all constants defined in PyGVisuals.