Exemplo n.º 1
0
    def get_visual_id_info(self):
        docname = self.env.docname
        """
        docname is not the same as self.source.
        source is a absolute path/filename.
        docname is the path/filename relative to project (without extension)
        """

        visualid = directives.unchanged_required(self.arguments[0])
        # or use this to get an ID-compatible string
        # name = directives.class_option(self.arguments[0])

        return docname, visualid
Exemplo n.º 2
0
    def get_visual_id_info(self):
        docname = self.env.docname
        """
        docname is not the same as self.source.
        source is a absolute path/filename.
        docname is the path/filename relative to project (without extension)
        """

        visualid = directives.unchanged_required(self.arguments[0])
        # or use this to get an ID-compatible string
        # name = directives.class_option(self.arguments[0])

        return docname, visualid
Exemplo n.º 3
0
def endpoint_set(option_value):
    """
    Parses the given string, converting it from a comma-separated list of
    values into a Python set of endpoint identifier strings ("client" or
    "server").

    :param option_value:
        The string to parse, as may be received from Sphinx as the value of a
        directive option.

    :return set:
        A Python set containing all endpoint identifier strings within the
        provided comma-separated list.

    :raises ValueError:
        If any provided endpoint is invalid.
    """
    entries = directives.unchanged_required(option_value)
    return {endpoint(entry) for entry in entries.split(',')}
Exemplo n.º 4
0
def phase_set(option_value):
    """
    Parses the given string, converting it from a comma-separated list of
    values into a Python set of Guacamole protocol session phase identifier
    strings ("handshake" or "interactive").

    :param option_value:
        The string to parse, as may be received from Sphinx as the value of a
        directive option.

    :return set:
        A Python set containing all phase identifier strings within the
        provided comma-separated list.

    :raises ValueError:
        If any provided phase is invalid.
    """
    entries = directives.unchanged_required(option_value)
    return {phase(entry) for entry in entries.split(',')}
Exemplo n.º 5
0
    def run(self):
        node = youtube_video('', **self.options)
        node['classes'] += self.options.get('class', [])
        youtube_id = None
        yt_base_embed = 'https://www.youtube.com/embed'
        is_list_type = 'list' in self.options and 'listtype' in self.options

        try:
            err = ValueError('Invalid Youtube ID')
            if self.arguments:
                youtube_id = directives.unchanged_required(self.arguments[0])
                regex = r"[a-zA-Z0-9_-]{11}"
                if not re.search(regex, youtube_id) and not is_list_type:
                    raise err
            elif not is_list_type:
                raise err
        except ValueError:
            err = 'Invalid Youtube ID attribute value for "%s" directive: "%s".'
            raise self.error(
                err % (self.name, self.arguments[0] if self.arguments else ''))

        if youtube_id and not is_list_type:
            node['src'] = yt_base_embed + "/{id}".format(id=youtube_id)
        else:
            node['src'] = yt_base_embed

        youtube_params = self.create_url_params(node)
        if len(youtube_params):
            node['src'] += '?%s' % youtube_params

        # ratio is done via Bootstrap class
        ratio = '16by9'
        if '4by3' in self.options:
            ratio = '4by3'

        node['classes'].insert(0, 'embed-responsive')
        node['classes'].insert(1, 'embed-responsive-%s' % ratio)

        self.add_name(node)
        return [node]
 def album_id(arg):
     return directives.positive_int(directives.unchanged_required(arg))
 def url(arg):
     return directives.uri(directives.unchanged_required(arg))
Exemplo n.º 8
0
 def test_unchanged_required(self):
     # Raise error when there is no argument:
     self.assertRaises(ValueError, directives.unchanged_required, None)
     self.assertEqual(3, directives.unchanged_required(3))
Exemplo n.º 9
0
 def album_id(arg):
     return directives.positive_int(directives.unchanged_required(arg))
Exemplo n.º 10
0
 def url(arg):
     return directives.uri(directives.unchanged_required(arg))