Skip to content

Commit 5e70ccc

Browse files
authored
Merge pull request #580 from kbenzie/benie/add-validate-rst-exceptions
[ur] Actually fail when RST validation finds an error
2 parents 00e1469 + f439fbb commit 5e70ccc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

scripts/generate_docs.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def _make_ref(symbol, symbol_type, meta):
7575
ref = ":ref:`" + ref + " <" + target.replace("_", "-") + ">`"
7676
else:
7777
print("%s(%s) : error : enum symbol not found for etor %s"%(fin, iline+1, symbol))
78+
raise Exception()
7879
elif not re.match("function", symbol_type):
7980
ref = ":ref:`" + ref.replace("_", "-") + "`"
8081
else:
@@ -92,6 +93,8 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
9293

9394
print("Generating %s..."%fout)
9495

96+
error = False
97+
9598
outlines = []
9699
for iline, line in enumerate(util.textRead(fin)):
97100

@@ -116,6 +119,7 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
116119

117120
if re.match(RE_INVALID_TAG_FORMAT, line):
118121
print("%s(%s) : error : invalid %s tag used"%(fin, iline+1, re.sub(RE_INVALID_TAG_FORMAT, r"\1", line)))
122+
error = True
119123

120124
newline = line # new line will contain proper tags for reStructuredText if needed.
121125
if re.match(RE_PROPER_TAG_FORMAT, line):
@@ -128,6 +132,7 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
128132
symbol_type = _find_symbol_type(symbol, meta)
129133
if not symbol_type:
130134
print("%s(%s) : error : symbol '%s' not found"%(fin, iline+1, symbol))
135+
error = True
131136
continue
132137

133138
if code_block and 'function' == symbol_type:
@@ -136,6 +141,7 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
136141
if len(words) != len(meta['function'][symbol]['params']):
137142
print("%s(%s) : error : %s parameter count mismatch - %s actual vs. %s expected"%(fin, iline+1, symbol, len(words), len(meta['function'][symbol]['params'])))
138143
print("line = %s"%line)
144+
error = True
139145

140146
ref = _make_ref(symbol, symbol_type, meta)
141147
if ref:
@@ -157,6 +163,9 @@ def _generate_valid_rst(fin, fout, namespace, tags, ver, rev, meta):
157163

158164
outlines.append(newline)
159165

166+
if error:
167+
raise Exception('Error during reStructuredText generation.')
168+
160169
util.writelines(os.path.abspath(fout), outlines)
161170

162171
return util.makoWrite(os.path.abspath(fout), fout,

0 commit comments

Comments
 (0)