Skip to content
Snippets Groups Projects
Commit a37c2ef5 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[CMake][Doc] Add some useful error messages to the CMake doc

Previously, the script that splits the in-module documentation
into parts exited with cryptic error messages that gave no hint
on where the typo happened. It now prints the offending line.
parent 0a4d31eb
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,7 @@
This is used by dune-common to generate the build system documentation.
Users do not want to use this!!!
"""
from __future__ import print_function
import argparse
import os
......@@ -51,7 +52,11 @@ def read_module(args=get_args()):
cmdpath = os.path.join(args['builddir'], 'commands')
if not os.path.exists(cmdpath):
os.makedirs(cmdpath)
cmd = re.findall(r'# .. cmake_function:: (.*)', l)[0]
try:
cmd = re.findall(r'# .. cmake_function:: (.*)', l)[0]
except IndexError as e:
print("CMake doc syntax error in {}: cannot parse function on line {}".format(args['module'], l))
raise e
cmdfile = os.path.join(cmdpath, cmd + ".rst")
# if not listHeader:
# mod.write("\nThis module defines the following functions or macros:\n\n")
......@@ -68,7 +73,11 @@ def read_module(args=get_args()):
varpath = os.path.join(args['builddir'], 'variables')
if not os.path.exists(varpath):
os.makedirs(varpath)
var = re.findall(r'# .. cmake_variable:: (.*)', l)[0]
try:
var = re.findall(r'# .. cmake_variable:: (.*)', l)[0]
except IndexError as e:
print("CMake doc syntax error in {}: cannot parse variable on line".format(args['module'], l))
raise e
varfile = os.path.join(varpath, var + ".rst")
o = open(varfile, 'w')
o.write(".. _" + var + ":\n\n")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment