matplotlib._docstring#

matplotlib._docstring.Substitution(*args, **kwargs)[源代码]#

基类: object

一个装饰器,对对象的文档字符串执行百分号替换。

即使 obj.__doc__ 为 None(例如,如果向解释器传递了 -OO 参数),此装饰器也应具有鲁棒性。

用法:使用适合执行替换的序列或字典构造一个 docstring.Substitution;然后用构造的对象装饰一个合适的函数,例如:

sub_author_name = Substitution(author='Jason')

@sub_author_name
def some_function(x):
    "%(author)s wrote this function"

# note that some_function.__doc__ is now "Jason wrote this function"

也可以使用位置参数

sub_first_last_names = Substitution('Edgar Allen', 'Poe')

@sub_first_last_names
def some_function(x):
    "%s %s wrote the Raven"
matplotlib._docstring.copy(source)[源代码]#

从另一个源函数复制文档字符串(如果存在)。

matplotlib._docstring.kwarg_doc(text)[源代码]#

用于定义 artist 属性的 kwdoc 文档的装饰器。

此装饰器可应用于 artist 属性的设置方法。给定文本存储在方法的私有属性 _kwarg_doc 中。它用于覆盖 artist 的kwdoc 列表中自动生成的文档。当 **kwargs 是 artist 的属性时,kwdoc 列表用于文档化它们。例如,请参阅 Axes.text 中的 **kwargs 部分。

文本应包含支持的类型,以及适用的默认值,例如:

@_docstring.kwarg_doc("bool, default: rcParams["text.usetex"] (默认值: False)") def set_usetex(self, usetex)