Skip to content

Commit 47854d4

Browse files
authored
Merge pull request #569 from veselypeta/petr/565/fail-build-on-spec-generate
[UR] Fail build on spec generate
2 parents 7089c92 + a5dce88 commit 47854d4

File tree

2 files changed

+54
-47
lines changed

2 files changed

+54
-47
lines changed

scripts/parse_specs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def __validate_params(d, tags):
430430
print("%s(%s): %s!"%(os.path.abspath(f), line_num, msg))
431431
print("-- Function Info --")
432432
print(d)
433-
return False
433+
raise
434434

435435
"""
436436
filters object by version

scripts/run.py

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -133,69 +133,76 @@ def main():
133133
'meta' : {},
134134
'ref' : {}
135135
}
136+
137+
try:
136138

137-
for section in configParser.sections():
138-
input['configs'].append({
139-
'name' : section,
140-
'namespace': configParser.get(section,'namespace'),
141-
'tags' : {'$'+key : configParser.get(section,key) for key in configParser.get(section,'tags').split(",")},
142-
})
139+
for section in configParser.sections():
140+
input['configs'].append({
141+
'name' : section,
142+
'namespace': configParser.get(section,'namespace'),
143+
'tags' : {'$'+key : configParser.get(section,key) for key in configParser.get(section,'tags').split(",")},
144+
})
145+
146+
# phase 2: parse specs
147+
for config in input['configs']:
148+
specs, input['meta'], input['ref'] = parse_specs.parse(config['name'], args['ver'], config['tags'], input['meta'], input['ref'])
149+
input['specs'].append(specs)
150+
151+
util.jsonWrite(args['api_json'], input)
143152

144-
# phase 2: parse specs
145-
for config in input['configs']:
146-
specs, input['meta'], input['ref'] = parse_specs.parse(config['name'], args['ver'], config['tags'], input['meta'], input['ref'])
147-
input['specs'].append(specs)
153+
# phase 3: generate files
154+
if args['clean']:
155+
clean()
148156

149-
util.jsonWrite(args['api_json'], input)
157+
incpath = os.path.join("../include/")
158+
srcpath = os.path.join("../source/")
159+
docpath = os.path.join("../docs/")
150160

151-
# phase 3: generate files
152-
if args['clean']:
153-
clean()
161+
generate_docs.prepare(docpath, args['rst'], args['html'], args['ver'])
162+
generate_docs.generate_ref(docpath, input['ref'])
154163

155-
incpath = os.path.join("../include/")
156-
srcpath = os.path.join("../source/")
157-
docpath = os.path.join("../docs/")
164+
for idx, specs in enumerate(input['specs']):
165+
config = input['configs'][idx]
166+
if args[config['name']]:
158167

159-
generate_docs.prepare(docpath, args['rst'], args['html'], args['ver'])
160-
generate_docs.generate_ref(docpath, input['ref'])
168+
generate_code.generate_api(incpath, srcpath, config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
161169

162-
for idx, specs in enumerate(input['specs']):
163-
config = input['configs'][idx]
164-
if args[config['name']]:
170+
if args['rst']:
171+
generate_docs.generate_rst(docpath, config['name'], config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
165172

166-
generate_code.generate_api(incpath, srcpath, config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
173+
if util.makeErrorCount():
174+
print("\n%s Errors found during generation, stopping execution!"%util.makeErrorCount())
175+
return
167176

168-
if args['rst']:
169-
generate_docs.generate_rst(docpath, config['name'], config['namespace'], config['tags'], args['ver'], args['rev'], specs, input['meta'])
177+
if args['debug']:
178+
util.makoFileListWrite("generated.json")
170179

171-
if util.makeErrorCount():
172-
print("\n%s Errors found during generation, stopping execution!"%util.makeErrorCount())
173-
return
180+
# phase 4: build code
181+
if args['build']:
182+
if not build():
183+
print("\nBuild failed, stopping execution!")
184+
return
174185

175-
if args['debug']:
176-
util.makoFileListWrite("generated.json")
186+
# phase 5: prep for publication of html or pdf
187+
if args['html'] or args['pdf']:
188+
generate_docs.generate_common(docpath, configParser.sections(), args['ver'], args['rev'])
177189

178-
# phase 4: build code
179-
if args['build']:
180-
if not build():
181-
print("\nBuild failed, stopping execution!")
182-
return
190+
# phase 5: publish documentation
191+
if args['html']:
192+
generate_docs.generate_html(docpath)
183193

184-
# phase 5: prep for publication of html or pdf
185-
if args['html'] or args['pdf']:
186-
generate_docs.generate_common(docpath, configParser.sections(), args['ver'], args['rev'])
194+
if args['pdf']:
195+
generate_docs.generate_pdf(docpath)
187196

188-
# phase 5: publish documentation
189-
if args['html']:
190-
generate_docs.generate_html(docpath)
197+
if args['update_spec']:
198+
update_spec(args['update_spec'])
191199

192-
if args['pdf']:
193-
generate_docs.generate_pdf(docpath)
200+
print("\nCompleted in %.1f seconds!"%(time.time() - start))
194201

195-
if args['update_spec']:
196-
update_spec(args['update_spec'])
202+
except:
203+
print("Failed to generate specification.")
204+
return sys.exit(1)
197205

198-
print("\nCompleted in %.1f seconds!"%(time.time() - start))
199206

200207
if __name__ == '__main__':
201208
main()

0 commit comments

Comments
 (0)