From 9e3aa892dfa891826e85cdb505d504facb02e299 Mon Sep 17 00:00:00 2001 From: Patrick Seewald Date: Sat, 7 Jan 2017 21:16:16 +0000 Subject: [PATCH] deactivate prettify and doxify for files containing fypp directives svn-origin-rev: 17664 --- tools/doxify/doxify.sh | 2 ++ tools/doxify/is_fypp.py | 13 +++++++++++++ tools/prettify/fprettify.py | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 tools/doxify/is_fypp.py diff --git a/tools/doxify/doxify.sh b/tools/doxify/doxify.sh index 3f4b087bf9..62ddbb0b46 100755 --- a/tools/doxify/doxify.sh +++ b/tools/doxify/doxify.sh @@ -5,6 +5,8 @@ SCRIPTDIR=$(cd $(dirname "$0"); pwd) # Pick up full path to scripts from whereve for file in "$@"; do + if $(python $SCRIPTDIR/is_fypp.py $file) ; then exit 0; fi + # generate temp-file names tmp_file1=`mktemp` tmp_file2=`mktemp` diff --git a/tools/doxify/is_fypp.py b/tools/doxify/is_fypp.py new file mode 100644 index 0000000000..e9e4a25c63 --- /dev/null +++ b/tools/doxify/is_fypp.py @@ -0,0 +1,13 @@ +import sys, re + +FYPP_SYMBOLS = r"(#|\$|@)" +FYPP_LINE = r"^\s*" + FYPP_SYMBOLS + r":" +FYPP_INLINE = r"(" + FYPP_SYMBOLS + r"{|}" + FYPP_SYMBOLS + r")" +FYPP_RE = re.compile(r"(" + FYPP_LINE + r"|" + FYPP_INLINE + r")") + +infile = open(sys.argv[1], 'r') +for line in infile.readlines(): + if FYPP_RE.match(line): + sys.exit(0) + +sys.exit(1) diff --git a/tools/prettify/fprettify.py b/tools/prettify/fprettify.py index 92c1b56f6f..a388a2f5a4 100755 --- a/tools/prettify/fprettify.py +++ b/tools/prettify/fprettify.py @@ -96,6 +96,11 @@ def prettifyFile(infile, filename, normalize_use, decl_linelength, decl_offset, max_pretty_iter = 5 n_pretty_iter = 0 + if is_fypp(ifile): + logger = logging.getLogger('prettify-logger') + logger.error(orig_filename + ": fypp directives not supported.\n") + return ifile + while True: n_pretty_iter += 1 hash_prev = md5() @@ -209,6 +214,20 @@ def prettfyInplace(fileName, bkDir=None, stdout=False, **kwargs): infile.close() outfile.close() +def is_fypp(infile): + FYPP_SYMBOLS = r"(#|\$|@)" + FYPP_LINE = r"^\s*" + FYPP_SYMBOLS + r":" + FYPP_INLINE = r"(" + FYPP_SYMBOLS + r"{|}" + FYPP_SYMBOLS + r")" + FYPP_RE = re.compile(r"(" + FYPP_LINE + r"|" + FYPP_INLINE + r")") + + infile.seek(0) + for line in infile.readlines(): + if FYPP_RE.match(line): + return True + + infile.seek(0) + return False + def main(argv=None): if argv is None: