Example #1
0
    def run(self):
        # type: () -> List[nodes.Node]
        language = self.arguments[0].strip()
        linenothreshold = self.options.get('linenothreshold', sys.maxsize)

        self.env.temp_data['highlight_language'] = language
        return [addnodes.highlightlang(lang=language, linenothreshold=linenothreshold)]
Example #2
0
    def run(self):
        # type: () -> List[nodes.Node]
        language = self.arguments[0].strip()
        linenothreshold = self.options.get('linenothreshold', sys.maxsize)

        self.env.temp_data['highlight_language'] = language
        return [addnodes.highlightlang(lang=language, linenothreshold=linenothreshold)]
Example #3
0
 def run(self):
     # type: () -> List[nodes.Node]
     linenothreshold = self.options.get('linenothreshold', sys.maxsize)
     return [
         addnodes.highlightlang(lang=self.arguments[0].strip(),
                                linenothreshold=linenothreshold)
     ]
Example #4
0
    def run(self) -> List[Node]:
        language = self.arguments[0].strip()
        linenothreshold = self.options.get('linenothreshold', sys.maxsize)
        force = 'force' in self.options

        self.env.temp_data['highlight_language'] = language
        return [addnodes.highlightlang(lang=language,
                                       force=force,
                                       linenothreshold=linenothreshold)]
Example #5
0
 def run(self):
     if "linenothreshold" in self.options:
         try:
             linenothreshold = int(self.options["linenothreshold"])
         except Exception:
             linenothreshold = 10
     else:
         linenothreshold = sys.maxsize
     return [addnodes.highlightlang(lang=self.arguments[0].strip(), linenothreshold=linenothreshold)]
Example #6
0
 def run(self):
     if 'linenothreshold' in self.options:
         try:
             linenothreshold = int(self.options['linenothreshold'])
         except Exception:
             linenothreshold = 10
     else:
         linenothreshold = sys.maxsize
     return [addnodes.highlightlang(lang=self.arguments[0].strip(),
                                    linenothreshold=linenothreshold)]
Example #7
0
File: code.py Project: LFYG/sphinx
 def run(self):
     # type: () -> List[nodes.Node]
     if 'linenothreshold' in self.options:
         try:
             linenothreshold = int(self.options['linenothreshold'])
         except Exception:
             linenothreshold = 10
     else:
         linenothreshold = sys.maxsize
     return [addnodes.highlightlang(lang=self.arguments[0].strip(),
                                    linenothreshold=linenothreshold)]
Example #8
0
def highlightlang_directive(name, arguments, options, content, lineno,
                            content_offset, block_text, state, state_machine):
    if 'linenothreshold' in options:
        try:
            linenothreshold = int(options['linenothreshold'])
        except Exception:
            linenothreshold = 10
    else:
        linenothreshold = sys.maxint
    return [addnodes.highlightlang(lang=arguments[0].strip(),
                                   linenothreshold=linenothreshold)]
Example #9
0
def highlightlang_directive(name, arguments, options, content, lineno,
                            content_offset, block_text, state, state_machine):
    if 'linenothreshold' in options:
        try:
            linenothreshold = int(options['linenothreshold'])
        except Exception:
            linenothreshold = 10
    else:
        linenothreshold = sys.maxint
    return [addnodes.highlightlang(lang=arguments[0].strip(),
                                   linenothreshold=linenothreshold)]
Example #10
0
    def run(self):
        filename = self.arguments[0]

        # Load rose configuration.
        try:
            conf = config.load(filename)
        except config.ConfigSyntaxError:
            LOGGER.error('Syntax error in Rose configuration file "%s".' %
                         filename)
            raise

        nodes = []
        nodes.append(addnodes.highlightlang(lang='rose', linenothreshold=20))

        # Append file level comments if present.
        if conf.comments:
            contentnode = addnodes.desc_content()
            contentnode.document = self.state.document
            self.state.nested_parse(StringList(conf.comments),
                                    self.content_offset, contentnode)
            nodes.append(contentnode)

        # Append configurations.
        section = None
        node = block_quote()
        for key, conf_node in sorted(conf.walk()):
            if isinstance(conf_node.value, str):
                # Configuration setting - "name=arg".
                name = '%s=%s' % (key[-1], conf_node.value or '')
            else:
                # Configuration section - "name"
                name = key[-1]
            # Prepare directive object.
            directive = RoseConfigDirective(
                'rose:conf',
                [name],
                {},
                StringList(conf_node.comments),
                self.lineno,
                self.content_offset,
                self.block_text,
                self.state,
                self.state_machine,
            )
            if isinstance(conf_node.value, dict):
                # Configuration section.
                if section:
                    node.append(section.run()[1])
                section = directive
            elif key[0]:
                # Sub-configuration.
                section.register_subnode(directive)
            else:
                # Top-level configuration
                node.append(directive.run()[1])
        if section:
            node.append(section.run()[1])
        nodes.append(node)

        nodes.append(addnodes.highlightlang(lang='bash', linenothreshold=20))

        return nodes
Example #11
0
    def run(self):
        filename = self.arguments[0]

        # Load rose configuration.
        try:
            conf = config.load(filename)
        except config.ConfigSyntaxError:
            LOGGER.error(
                'Syntax error in Rose configuration file "%s".' % filename)
            raise

        nodes = []
        nodes.append(addnodes.highlightlang(lang='rose', linenothreshold=20))

        # Append file level comments if present.
        if conf.comments:
            contentnode = addnodes.desc_content()
            contentnode.document = self.state.document
            self.state.nested_parse(
                StringList(conf.comments),
                self.content_offset,
                contentnode
            )
            nodes.append(contentnode)

        # Append configurations.
        section = None
        node = block_quote()
        for key, conf_node in sorted(conf.walk()):
            if isinstance(conf_node.value, str):
                # Configuration setting - "name=arg".
                name = '%s=%s' % (key[-1], conf_node.value or '')
            else:
                # Configuration section - "name"
                name = key[-1]
            # Prepare directive object.
            directive = RoseConfigDirective(
                'rose:conf',
                [name],
                {},
                StringList(conf_node.comments),
                self.lineno,
                self.content_offset,
                self.block_text,
                self.state,
                self.state_machine,
            )
            if isinstance(conf_node.value, dict):
                # Configuration section.
                if section:
                    node.append(section.run()[1])
                section = directive
            elif key[0]:
                # Sub-configuration.
                section.register_subnode(directive)
            else:
                # Top-level configuration
                node.append(directive.run()[1])
        if section:
            node.append(section.run()[1])
        nodes.append(node)

        nodes.append(addnodes.highlightlang(lang='bash', linenothreshold=20))

        return nodes
Example #12
0
 def run(self):
     # type: () -> List[nodes.Node]
     linenothreshold = self.options.get('linenothreshold', sys.maxsize)
     return [addnodes.highlightlang(lang=self.arguments[0].strip(),
                                    linenothreshold=linenothreshold)]