# HG changeset patch # User Pierre-Yves David # Date 1506005717 -7200 # Node ID 1a4f26eec0af2c95c63a9198514da0d16a09663f # Parent ef361938dfa1fc5bc079144908883c8c00fee080 test2rst: ignore the #if/#endif line in the output They are not useful for the rest. diff -r ef361938dfa1 -r 1a4f26eec0af docs/makefile --- 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 diff -r ef361938dfa1 -r 1a4f26eec0af docs/test2rst.py --- 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