summaryrefslogtreecommitdiff
path: root/c2rst.py
diff options
context:
space:
mode:
authorScott Shawcroft <scott@chickadee.tech>2016-10-18 17:42:47 -0700
committerScott Shawcroft <scott@chickadee.tech>2016-10-18 17:42:47 -0700
commit46e7f8e4fb172207121516f5bd15d162aedd041d (patch)
tree7ff3890e7a3339402587f995d3a6c7099194fe61 /c2rst.py
parentcb99ae50328de982244ed5cd486ccd57f5bd93bd (diff)
Documentation rework to unify the docs together rather than having them
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.
Diffstat (limited to 'c2rst.py')
-rw-r--r--c2rst.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/c2rst.py b/c2rst.py
new file mode 100644
index 000000000..6b0fe646a
--- /dev/null
+++ b/c2rst.py
@@ -0,0 +1,17 @@
+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)