Skip to content

Commit

Permalink
Print an error when the language is not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
bobismijnnaam committed Jan 24, 2022
1 parent 34f163b commit dc3a1f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions util/wiki/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vercors.wiki/
wiki.pdf
12 changes: 10 additions & 2 deletions util/wiki/generate_wiki_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import optparse
import time
import uuid
import sys

class SnippetTestcase:
"""
Expand Down Expand Up @@ -195,8 +196,15 @@ def collect_testcases(document, cases):
for block in document['blocks']:
# Code blocks preceded by a label are added to the labeled testcase
if block['t'] == 'CodeBlock' and code_block_label is not None:
cases[code_block_label].add_content(block['c'][1].strip())
cases[code_block_label].language = block['c'][0][1][0]
code_txt = block['c'][1]
cases[code_block_label].add_content(code_txt)

languages = block['c'][0][1]
if len(languages) == 0:
print(f"Error: language was not specified for code block.\nLabel: {code_block_label}\nText in code block:\n{code_txt}")
sys.exit(1)

cases[code_block_label].language = languages[0]
block['_case_label'] = code_block_label

code_block_label = None
Expand Down

0 comments on commit dc3a1f9

Please sign in to comment.