Example #1
0
            return [nodes.literal(text = 'No version of example %s in language %s - patches welcome!'
                % (last_example, highlight_language))]
        self.arguments[0] = "/" + filename
        if not 'start-after' in self.options and not 'end-before' in self.options:
            if 'marker' in self.options:
                marker = self.options['marker']
                del self.options['marker']
            else:
                marker = 'example code'
            self.options['start-after'] = 'Start of ' + marker
            self.options['end-before'] = 'End of ' + marker
        return super(XapianCodeExample, self).run()

# Usage:
# .. xapianexample:: search_filters2
directives.register_directive('xapianexample', XapianCodeExample)

def xapian_escape_args(args):
    def esc_char(match):
        return "=%02x" % ord(match.group(0))
    return re.sub(r' ', r'_', re.sub(r'[^-A-Za-z0-9 .]', esc_char, args))
class XapianRunExample(LiteralInclude):
    option_spec = {
        'args': directives.unchanged_required,
        'cleanfirst': directives.unchanged,
        'shouldfail': directives.unchanged,
    }

    def run(self):
        filename = xapian_code_example_filename(self.arguments[0])
        if not os.path.exists(filename):
Example #2
0
            ]
        self.arguments[0] = "/" + filename
        if 'start-after' not in self.options and 'end-before' not in self.options:
            if 'marker' in self.options:
                marker = self.options['marker']
                del self.options['marker']
            else:
                marker = 'example code'
            self.options['start-after'] = 'Start of ' + marker
            self.options['end-before'] = 'End of ' + marker
        return super(XapianCodeExample, self).run()


# Usage:
# .. xapianexample:: search_filters2
directives.register_directive('xapianexample', XapianCodeExample)


def xapian_escape_args(args):
    def esc_char(match):
        return "=%02x" % ord(match.group(0))

    return re.sub(r' ', r'_', re.sub(r'[^-A-Za-z0-9 .]', esc_char, args))


class XapianRunExample(LiteralInclude):
    option_spec = {
        'args': directives.unchanged_required,
        'cleanfirst': directives.unchanged,
        'shouldfail': directives.unchanged,
        'silent': directives.flag,
Example #3
0
            return [nodes.literal(text = 'No version of example %s in language %s - patches welcome!'
                % (last_example, highlight_language))]
        self.arguments[0] = "/" + filename
        if not 'start-after' in self.options and not 'end-before' in self.options:
            if 'marker' in self.options:
                marker = self.options['marker']
                del self.options['marker']
            else:
                marker = 'example code'
            self.options['start-after'] = 'Start of ' + marker
            self.options['end-before'] = 'End of ' + marker
        return super(XapianCodeExample, self).run()

# Usage:
# .. xapianexample:: search_filters2
directives.register_directive('xapianexample', XapianCodeExample)

def xapian_escape_args(args):
    def esc_char(match):
        return "=%02x" % ord(match.group(0))
    return re.sub(r' ', r'_', re.sub(r'[^-A-Za-z0-9 .]', esc_char, args))

class XapianRunExample(LiteralInclude):
    option_spec = {
        'args': directives.unchanged_required,
    }

    def run(self):
        filename = xapian_code_example_filename(self.arguments[0])
        if not os.path.exists(filename):
            return [nodes.literal(text = 'No version of example %s in language %s - patches welcome!'
Example #4
0
            ]
        self.arguments[0] = "/" + filename
        if not 'start-after' in self.options and not 'end-before' in self.options:
            if 'marker' in self.options:
                marker = self.options['marker']
                del self.options['marker']
            else:
                marker = 'example code'
            self.options['start-after'] = 'Start of ' + marker
            self.options['end-before'] = 'End of ' + marker
        return super(XapianCodeExample, self).run()


# Usage:
# .. xapianexample:: search_filters2
directives.register_directive('xapianexample', XapianCodeExample)


def xapian_escape_args(args):
    def esc_char(match):
        return "=%02x" % ord(match.group(0))

    return re.sub(r' ', r'_', re.sub(r'[^-A-Za-z0-9 .]', esc_char, args))


class XapianRunExample(LiteralInclude):
    option_spec = {
        'args': directives.unchanged_required,
        'cleanfirst': directives.unchanged,
        'shouldfail': directives.unchanged,
    }
Example #5
0
            ]
        self.arguments[0] = "/" + filename
        if not 'start-after' in self.options and not 'end-before' in self.options:
            if 'marker' in self.options:
                marker = self.options['marker']
                del self.options['marker']
            else:
                marker = 'example code'
            self.options['start-after'] = 'Start of ' + marker
            self.options['end-before'] = 'End of ' + marker
        return super(XapianCodeExample, self).run()


# Usage:
# .. xapianexample:: search_filters2
directives.register_directive('xapianexample', XapianCodeExample)


def xapian_escape_args(args):
    def esc_char(match):
        return "=%02x" % ord(match.group(0))

    return re.sub(r' ', r'_', re.sub(r'[^-A-Za-z0-9 .]', esc_char, args))


class XapianRunExample(LiteralInclude):
    option_spec = {
        'args': directives.unchanged_required,
    }

    def run(self):