Mercurial > public > mercurial-scm > evolve
diff docs/test2rst.py @ 2960:1a4f26eec0af
test2rst: ignore the #if/#endif line in the output
They are not useful for the rest.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 21 Sep 2017 16:55:17 +0200 |
parents | ef361938dfa1 |
children | 16c1398b0063 |
line wrap: on
line diff
--- 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