Skip to content

Commit 6a56aaa

Browse files
Gareth Aneurin TribelloGareth Aneurin Tribello
authored andcommitted
Fixed keyword in example detection from last commit
1 parent 6a290f5 commit 6a56aaa

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/PlumedToHTML/PlumedFormatter.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def format(self, tokensource, outfile):
3838
for ttype, value in tokensource :
3939
# This checks if we are at the start of a new action. If we are we should be reading a value or an action and the label and action for the previous one should be set
4040
if len(action)>0 and (ttype==String or ttype==Keyword or ttype==Comment.Preproc) :
41+
if action==self.checkaction :
42+
for key in keywords :
43+
self.checkaction_keywords.add( key )
4144
if notooltips :
4245
# Reset everything for the new action
4346
action, label, keywords, notooltips = "", "", [], False
@@ -293,6 +296,9 @@ def format(self, tokensource, outfile):
293296
else :
294297
outfile.write('<span class="plumedtooltip" style="color:green">' + value.strip() + '<span class="right">'+ self.keyword_dict[action]["description"] + ' <a href="' + self.keyword_dict[action]["hyperlink"] + '" style="color:green">More details</a><i></i></span></span>')
295298
# Check if there is stuff to output for the last action in the file
299+
if action==self.checkaction :
300+
for key in keywords :
301+
self.checkaction_keywords.add( key )
296302
if len(label)>0 and label not in all_labels and label not in self.valuedict.keys() :
297303
all_labels.add( label )
298304
if action in self.keyword_dict and "output" in self.keyword_dict[action]["syntax"] : self.writeValuesData( outfile, action, label, keywords, self.keyword_dict[action]["syntax"]["output"] )
@@ -303,9 +309,6 @@ def format(self, tokensource, outfile):
303309
outfile.write('</pre>')
304310

305311
def writeValuesData( self, outfile, action, label, keywords, outdict ) :
306-
if action==self.checkaction :
307-
for key in keywords :
308-
self.checkaction_keywords.add( key )
309312
# Some header stuff
310313
outfile.write('<span style="display:none;" id="' + self.egname + label + r'">')
311314
outfile.write('The ' + action + ' action with label <b>' + label + '</b>')

tests/test_keyword_list.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from unittest import TestCase
2+
3+
import os
4+
import json
5+
import PlumedToHTML
6+
7+
class TestPlumedArguments(TestCase):
8+
def testReadKeywords(self) :
9+
inpt = """
10+
```plumed
11+
d1: DISTANCE ATOMS=1,2
12+
PRINT ARG=d1 FILE=colvar
13+
```
14+
"""
15+
actions = set({})
16+
keyset = set({"ATOMS","COMPONENTS"})
17+
with open("check_keywords_file", "w") as ofile :
18+
PlumedToHTML.processMarkdownString( inpt, "check_keyword", ("plumed",), ("master",), actions, ofile, checkaction="DISTANCE", checkactionkeywords=keyset )
19+
self.assertTrue( keyset==set({"COMPONENTS"}) )
20+
21+
keyset = set({"ARG","FILE"})
22+
with open("check_keywords_file", "w") as ofile :
23+
PlumedToHTML.processMarkdownString( inpt, "check_keyword", ("plumed",), ("master",), actions, ofile, checkaction="PRINT", checkactionkeywords=keyset )
24+
self.assertTrue( len(keyset)==0 )

0 commit comments

Comments
 (0)