From dc3a1f904085648a5b27b2eab2a527f44e0a8ed6 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 24 Jan 2022 16:46:27 +0100 Subject: [PATCH] Print an error when the language is not specified --- util/wiki/.gitignore | 2 ++ util/wiki/generate_wiki_pdf.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 util/wiki/.gitignore diff --git a/util/wiki/.gitignore b/util/wiki/.gitignore new file mode 100644 index 0000000000..8ed110b15a --- /dev/null +++ b/util/wiki/.gitignore @@ -0,0 +1,2 @@ +vercors.wiki/ +wiki.pdf diff --git a/util/wiki/generate_wiki_pdf.py b/util/wiki/generate_wiki_pdf.py index acde651630..3fdaa132c7 100755 --- a/util/wiki/generate_wiki_pdf.py +++ b/util/wiki/generate_wiki_pdf.py @@ -10,6 +10,7 @@ import optparse import time import uuid +import sys class SnippetTestcase: """ @@ -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