diff --git a/PlumedToHTML/PlumedFormatter.py b/PlumedToHTML/PlumedFormatter.py
index 504a359..7d5035a 100644
--- a/PlumedToHTML/PlumedFormatter.py
+++ b/PlumedToHTML/PlumedFormatter.py
@@ -18,6 +18,7 @@ def __init__(self, **options) :
self.hasload=options["hasload"]
self.broken=options["broken"]
self.auxinputs=options["auxinputs"]
+ self.auxinputlines=options["auxinputlines"]
self.valuedict=options["valuedict"]
self.actions=options["actions"]
self.valcolors = {
@@ -140,13 +141,13 @@ def format(self, tokensource, outfile):
iff = open( inp, 'r' )
fcontent = iff.read()
iff.close()
- if len(fcontent.splitlines())>5 :
- n, shortversion = 0, ""
- for l in fcontent.splitlines() :
- shortversion += l + "\n"
- n = n + 1
- if n==5 : break
- shortversion += "...\n" + fcontent.splitlines()[-1]
+ if len(self.auxinputlines)>0 :
+ shortversion, allines = "", fcontent.splitlines()
+ for n, l in enumerate(self.auxinputlines) :
+ bounds = l.split("-")
+ start, end = int( bounds[0] ), int( bounds[1] )
+ if n>0 : shortversion += "...\n"
+ for kk in range(start,end+1) : shortversion += allines[kk-1] + "\n"
fcontent = shortversion
outfile.write('
')
@@ -223,6 +224,7 @@ def format(self, tokensource, outfile):
else : raise Exception("keyword " + value.strip().upper() + " is not in syntax for action " + action )
if desc=="" and self.broken : outfile.write( value )
else :
+ if action not in self.keyword_dict : raise Exception("action " + action + " not present in keyword dictionary")
if "actionlink" in self.keyword_dict[action]["syntax"][mykey].keys() and self.keyword_dict[action]["syntax"][mykey]["actionlink"]!="none" :
linkaction = self.keyword_dict[action]["syntax"][mykey]["actionlink"]
desc = desc + ". Options for this keyword are explained in the documentation for
" + linkaction + ".";
diff --git a/PlumedToHTML/PlumedToHTML.py b/PlumedToHTML/PlumedToHTML.py
index 29436bf..ac33254 100644
--- a/PlumedToHTML/PlumedToHTML.py
+++ b/PlumedToHTML/PlumedToHTML.py
@@ -186,14 +186,22 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, usejson=None, maxch
inpt, incomplete = manage_incomplete_inputs( inpt )
# Create a list of all the auxiliary input files that are needed by the plumed input
- inputfiles = []
+ inputfiles, inputfilelines = [], []
for line in inpt.splitlines() :
if "#SETTINGS" in line :
for word in line.split() :
if "MOLFILE=" in word :
- inputfiles.append( word.replace("MOLFILE=","") )
+ molfile = word.replace("MOLFILE=","")
+ iff = open( molfile, 'r' )
+ content = iff.read()
+ iff.close()
+ inputfiles.append(molfile)
+ inputfilelines.append("1-5")
+ inputfilelines.append( str(len(content.splitlines())-4) + "-" + str(len(content.splitlines())) )
elif "INPUTFILES=" in word :
for n in word.replace("INPUTFILES=","").split(",") : inputfiles.append( n )
+ elif "INPUTFILELINES=" in word :
+ inputfilelines = word.replace("INPUTFILELINES=","").split(",")
# Check for include files
foundincludedfiles, srcdir = True, str(pathlib.PurePosixPath(name).parent)
@@ -235,7 +243,7 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, usejson=None, maxch
plumed_info = subprocess.run(cmd, capture_output=True, text=True )
keyfile = plumed_info.stdout.strip() + "/json/syntax.json"
formatfile = os.path.join(os.path.dirname(__file__),"PlumedFormatter.py")
- plumed_formatter = load_formatter_from_file(formatfile, "PlumedFormatter", keyword_file=keyfile, input_name=name, hasload=found_load, broken=any(broken), auxinputs=inputfiles, valuedict=valuedict, actions=actions )
+ plumed_formatter = load_formatter_from_file(formatfile, "PlumedFormatter", keyword_file=keyfile, input_name=name, hasload=found_load, broken=any(broken), auxinputs=inputfiles, auxinputlines=inputfilelines, valuedict=valuedict, actions=actions )
# Now generate html of input
html = '
\n'
diff --git a/PlumedToHTML/tests/test_formatter.py b/PlumedToHTML/tests/test_formatter.py
index e8c91ef..dd3895b 100644
--- a/PlumedToHTML/tests/test_formatter.py
+++ b/PlumedToHTML/tests/test_formatter.py
@@ -22,7 +22,7 @@ def testSimple(self) :
keyfile = plumed_info.stdout.strip() + "/json/syntax.json"
# Setup a plumed formatter
- f = PlumedFormatter( keyword_file=keyfile, input_name="testout", hasload=False, broken=False, actions=set({}), valuedict=dict({}), auxinputs=[] )
+ f = PlumedFormatter( keyword_file=keyfile, input_name="testout", hasload=False, broken=False, actions=set({}), valuedict=dict({}), auxinputs=[], auxinputlines=[] )
# Now run over all the inputs in the json
for item in tests["regtests"] :
diff --git a/setup.py b/setup.py
index cd82fc3..52b9e56 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@
setuptools.setup(
name='PlumedToHTML',
- version='0.87',
+ version='0.89',
author="Gareth Tribello",
author_email="gareth.tribello@gmail.com",
description="A package for creating pretified HTML for PLUMED files",