File: seealso.py

package info (click to toggle)
haproxy 3.2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 23,924 kB
  • sloc: ansic: 267,927; sh: 3,466; xml: 1,756; python: 1,345; makefile: 1,155; perl: 168; cpp: 21
file content (32 lines) | stat: -rw-r--r-- 924 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import re
import parser

class SeeAlsoParser(parser.Parser):
    def parse(self, line):
        pctxt = self.pctxt

        result = re.search(r'(See also *:)', line)
        if result:
            label = result.group(0)

            desc = re.sub(r'.*See also *:', '', line).strip()

            indent = parser.get_indent(line)

            # Some descriptions are on multiple lines
            while pctxt.has_more_lines(1) and parser.get_indent(pctxt.get_line(1)) >= indent and pctxt.get_line(1).strip() != '':
                desc += " " + pctxt.get_line(1).strip()
                pctxt.next()

            pctxt.eat_empty_lines()
            pctxt.next()
            pctxt.stop = True

            template = pctxt.templates.get_template("parser/seealso.tpl")
            return template.render(
                pctxt=pctxt,
                label=label,
                desc=desc,
            )

        return line