matplotlib._docstring#

class 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 文档的装饰器。

此装饰器可应用于艺术对象的属性设置方法。给定的文本存储在该方法的私有属性 _kwarg_doc 中。它用于覆盖艺术对象 kwdoc 列表 中自动生成的文档。当 **kwargs 是艺术对象的属性时,kwdoc 列表用于为其编写文档。例如,请参见 Axes.text 中的 **kwargs 部分。

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

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