Changeset View
Changeset View
Standalone View
Standalone View
src/kapidox/generator.py
Show First 20 Lines • Show All 442 Lines • ▼ Show 20 Line(s) | 434 | def postprocess_internal(htmldir, tmpl, mapping): | |||
---|---|---|---|---|---|
443 | """ | 443 | """ | ||
444 | for name in os.listdir(htmldir): | 444 | for name in os.listdir(htmldir): | ||
445 | if name.endswith('.html'): | 445 | if name.endswith('.html'): | ||
446 | path = os.path.join(htmldir, name) | 446 | path = os.path.join(htmldir, name) | ||
447 | newpath = path + '.new' | 447 | newpath = path + '.new' | ||
448 | 448 | | |||
449 | if name != 'classes.html' and name.startswith('class'): | 449 | if name != 'classes.html' and name.startswith('class'): | ||
450 | mapping['classname'] = name[5:-5].split('_1_1')[-1] | 450 | mapping['classname'] = name[5:-5].split('_1_1')[-1] | ||
451 | mapping['fullname'] = name[5:-5].replace('_1_1', '::') | ||||
452 | elif name.startswith('namespace') and name != 'namespaces.html' and not name.startswith('namespacemembers'): | ||||
453 | mapping['classname'] = None | ||||
454 | mapping['fullname'] = name[9:-5].replace('_1_1', '::') | ||||
451 | else: | 455 | else: | ||
452 | mapping['classname'] = None | 456 | mapping['classname'] = None | ||
457 | mapping['fullname'] = None | ||||
453 | 458 | | |||
454 | with codecs.open(path, 'r', 'utf-8', errors='ignore') as f: | 459 | with codecs.open(path, 'r', 'utf-8', errors='ignore') as f: | ||
ochurlaud: Prefer the use of 2 settings to None instead of this double one. It's more explicit for people… | |||||
455 | mapping['dox'] = parse_dox_html(f) | 460 | mapping['dox'] = parse_dox_html(f) | ||
456 | 461 | | |||
457 | with codecs.open(newpath, 'w', 'utf-8') as outf: | 462 | with codecs.open(newpath, 'w', 'utf-8') as outf: | ||
458 | try: | 463 | try: | ||
459 | html = tmpl.render(mapping) | 464 | html = tmpl.render(mapping) | ||
460 | except Exception: | 465 | except Exception: | ||
461 | logging.error('postprocessing {} failed'.format(path)) | 466 | logging.error('postprocessing {} failed'.format(path)) | ||
462 | raise | 467 | raise | ||
▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines |
Prefer the use of 2 settings to None instead of this double one. It's more explicit for people not coming from python (majority here).