本文整理匯總了Python中docutils.parsers.rst.directives.choice方法的典型用法代碼示例。如果您正苦於以下問題:Python directives.choice方法的具體用法?Python directives.choice怎麽用?Python directives.choice使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類docutils.parsers.rst.directives
的用法示例。
在下文中一共展示了directives.choice方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: choice
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def choice(argument, values):
"""
Directive option utility function, supplied to enable options whose
argument must be a member of a finite set of possible values (must be
lower case). A custom conversion function must be written to use it. For
example::
from docutils.parsers.rst import directives
def yesno(argument):
return directives.choice(argument, ('yes', 'no'))
Raise ``ValueError`` if no argument is found or if the argument's value is
not valid (not an entry in the supplied list).
"""
try:
value = argument.lower().strip()
except AttributeError:
raise ValueError('must supply an argument; choose from %s'
% format_values(values))
if value in values:
return value
else:
raise ValueError('"%s" unknown; choose from %s'
% (argument, format_values(values)))
示例2: align_spec
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def align_spec(argument):
# type: (Any) -> bool
return directives.choice(argument, ('left', 'center', 'right'))
示例3: align
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def align(argument):
return directives.choice(argument, ('left', 'center', 'right'))
示例4: backlinks
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def backlinks(arg):
value = directives.choice(arg, Contents.backlinks_values)
if value == 'none':
return None
else:
return value
示例5: align
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def align(argument):
# This is not callable as self.align. We cannot make it a
# staticmethod because we're saving an unbound method in
# option_spec below.
return directives.choice(argument, Image.align_values)
示例6: _option_format
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def _option_format(arg):
return directives.choice(arg, ('python', 'doctest'))
示例7: _option_align
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def _option_align(arg):
return directives.choice(arg, ("top", "middle", "bottom", "left", "center",
"right"))
示例8: fontset_choice
# 需要導入模塊: from docutils.parsers.rst import directives [as 別名]
# 或者: from docutils.parsers.rst.directives import choice [as 別名]
def fontset_choice(arg):
return directives.choice(arg, ['cm', 'stix', 'stixsans'])