forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc2rst.py
More file actions
18 lines (16 loc) · 655 Bytes
/
c2rst.py
File metadata and controls
18 lines (16 loc) · 655 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import sphinx.parsers
class CStrip(sphinx.parsers.Parser):
def __init__(self):
self.rst_parser = sphinx.parsers.RSTParser()
def parse(self, inputstring, document):
# This setting is missing starting with Sphinx 1.7.1 so we set it ourself.
document.settings.tab_width = 4
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)