mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 06:05:29 -04:00
deactivate prettify and doxify for files containing fypp directives
svn-origin-rev: 17664
This commit is contained in:
parent
61a5455e0a
commit
9e3aa892df
3 changed files with 34 additions and 0 deletions
|
|
@ -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`
|
||||
|
|
|
|||
13
tools/doxify/is_fypp.py
Normal file
13
tools/doxify/is_fypp.py
Normal file
|
|
@ -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)
|
||||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue