Add a check regarding the number of occurrences of ``` (#18389)

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
Yih-Dar
2022-08-01 14:23:02 +02:00
committed by GitHub
parent 1cd7c6f154
commit bd6d1b4300
26 changed files with 77 additions and 75 deletions

View File

@@ -92,6 +92,9 @@ def process_doc_file(code_file, add_new_line=True):
# fmt: off
splits = code.split("```")
if len(splits) % 2 != 1:
raise ValueError("The number of occurrences of ``` should be an even number.")
splits = [s if i % 2 == 0 else process_code_block(s, add_new_line=add_new_line) for i, s in enumerate(splits)]
clean_code = "```".join(splits)
# fmt: on