我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用docutils.parsers.rst.directives.choice()。
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)))
def _option_format(arg): return directives.choice(arg, ('python', 'lisp'))
def _option_align(arg): return directives.choice(arg, ("top", "middle", "bottom", "left", "center", "right"))
def backlinks(arg): value = directives.choice(arg, Contents.backlinks_values) if value == 'none': return None else: return value
def align(argument): return directives.choice(argument, ('left', 'center', 'right'))
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)
def align(argument): return directives.choice(argument, Figure.align_h_values)
def align(argument): """Conversion function for the "align" option.""" return directives.choice(argument, ('left', 'center', 'right'))
def _option_format(arg): return directives.choice(arg, ('python', 'doctest'))
def fontset_choice(arg): return directives.choice(arg, ['cm', 'stix', 'stixsans'])
def align_spec(argument): # type: (Any) -> bool return directives.choice(argument, ('left', 'center', 'right'))
def csharp_unicodelevel(argument): return directives.choice(argument, ('none', 'basic', 'full'))
def lhs_litstyle(argument): return directives.choice(argument, ('bird', 'latex'))
def raw_compress(argument): return directives.choice(argument, ('gz', 'bz2')) # Register Directive # ------------------ # ::