test2rst: ignore the #if/#endif line in the output
They are not useful for the rest.
--- a/docs/makefile Thu Sep 21 10:45:27 2017 +0200
+++ b/docs/makefile Thu Sep 21 16:55:17 2017 +0200
@@ -2,10 +2,10 @@
all: tutorials/tutorial.rst tutorials/topic-tutorial.rst static/logo-evolve.ico
sphinx-build . ../html/
-tutorials/tutorial.rst: tutorials/tutorial.t
+tutorials/tutorial.rst: tutorials/tutorial.t test2rst.py
python test2rst.py tutorials/
-tutorials/topic-tutorial.rst: tutorials/topic-tutorial.t
+tutorials/topic-tutorial.rst: tutorials/topic-tutorial.t test2rst.py
python test2rst.py tutorials/
static/logo-evolve.ico: static/logo-evolve.svg
--- a/docs/test2rst.py Thu Sep 21 10:45:27 2017 +0200
+++ b/docs/test2rst.py Thu Sep 21 16:55:17 2017 +0200
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+import re
import os
import os.path as op
import sys
@@ -12,6 +13,13 @@
:maxdepth: 1
'''
+ignored_patterns = [
+ re.compile('^#if'),
+ re.compile('^#else'),
+ re.compile('^#endif'),
+ re.compile('#rest-ignore$'),
+]
+
def rstify(orig, name):
newlines = []
@@ -28,8 +36,12 @@
sphinx_directive_mode = False
continue
- # Ignore line
- if line.endswith('#rest-ignore'):
+ ignored = False
+ for pattern in ignored_patterns:
+ if pattern.search(line):
+ ignored = True
+ break
+ if ignored:
continue
# Sphinx directives mode