on a per port basis. Also enables generating docs from inline RST in C code. Simply omits all lines except those that start with //|. Indentation after "//| " will be preserved.
18 lines
495 B
Python
18 lines
495 B
Python
import sphinx.parsers
|
|
import docutils.parsers.rst as rst
|
|
|
|
class CStrip(sphinx.parsers.Parser):
|
|
def __init__(self):
|
|
self.rst_parser = rst.Parser()
|
|
|
|
def parse(self, inputstring, document):
|
|
stripped = []
|
|
for line in inputstring.split("\n"):
|
|
line = line.strip()
|
|
if line == "//|":
|
|
stripped.append("")
|
|
elif line.startswith("//| "):
|
|
stripped.append(line[len("//| "):])
|
|
stripped = "\r\n".join(stripped)
|
|
self.rst_parser.parse(stripped, document)
|