Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Treat validation as normal case if not a prepreq. #100
Browse files Browse the repository at this point in the history
  • Loading branch information
lastcoolnameleft committed Mar 4, 2018
1 parent 26b122b commit c1c7f99
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/prerequisites/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ They don't even need to be in the same list

By this point, the prerequisites have either run or have passed their validation

# Did our prerequisites run?
# Validation

```shell
echo prereq_ignored = $prereq_ignored
Expand Down
2 changes: 1 addition & 1 deletion examples/prerequisites/expected_result.dump
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{'content': 'By this point, the prerequisites have either run or '
'have passed their validation',
'type': 'text'},
{'content': 'Did our prerequisites run?',
{'content': 'Validation',
'level': 1,
'type': 'heading'},
{'content': ['echo prereq_ignored = $prereq_ignored',
Expand Down
2 changes: 1 addition & 1 deletion examples/prerequisites/expected_result.seo
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"type": "text"
},
{
"content": "Did our prerequisites run?",
"content": "Validation",
"level": 1,
"type": "heading"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/prerequisites/expected_result.tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ They don't even need to be in the same list

By this point, the prerequisites have either run or have passed their validation

# Did our prerequisites run?
# Validation

$ echo prereq_ignored = $prereq_ignored
prereq_ignored =
Expand Down
2 changes: 1 addition & 1 deletion simdem/mode/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def process_file(self, file_path, is_prereq=False, toc={}):
# Change the working directory in case of any recursion
start_path = os.path.dirname(os.path.abspath(file_path))
logging.debug('parse_file::start_path=' + start_path)
steps = self.parser.parse_file(file_path)
steps = self.parser.parse_file(file_path, is_prereq)

# We want to inherit the parent's TOC to reduce the # of copies needed
if toc:
Expand Down
10 changes: 6 additions & 4 deletions simdem/parser/simdem1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class SimDem1Parser(object): # pylint: disable=R0903
""" Parses markdown based off of Mistletoe renderer """

@staticmethod
def parse_file(file_path):
def parse_file(file_path, is_prerequisite=False):
""" The main meat for parsing the file. """
with open(file_path, 'r') as fin:
with SimDemMistletoeRenderer() as renderer:
with SimDemMistletoeRenderer(is_prerequisite) as renderer:
rendered = renderer.render(Document(fin))

# Do stuff here
Expand All @@ -28,11 +28,13 @@ class SimDemMistletoeRenderer(BaseRenderer):
"""
section = None
block = None
_is_prerequisite = False

def __init__(self):
def __init__(self, is_prerequisite):
super().__init__()
self.output = defaultdict(list)
self.reset_section()
self._is_prerequisite = is_prerequisite

def render_heading(self, token):
""" Render for Heading: # """
Expand All @@ -48,7 +50,7 @@ def render_heading(self, token):
return inner

# Validation Heading
elif inner.lower() == 'validation':
elif self._is_prerequisite and inner.lower() == 'validation':
self.set_section('validation')

# Cleanup
Expand Down

0 comments on commit c1c7f99

Please sign in to comment.