in scripts/gen_api_doc.py [0:0]
def main(_):
# cleanup
outpath = Path(OUTDIR)
if outpath.exists():
shutil.rmtree(OUTDIR)
outpath.mkdir(parents=True)
cprint('output dir: %s' % OUTDIR, 'green')
# generate
gen_api_docs()
# fixing
cprint('Fixing documentation', 'magenta')
cprint("rename main file to md")
mfname = OUTDIR + 'README.md'
shutil.move(OUTDIR + 'TFSimilarity.md', mfname)
reps = [
[
"<!-- Insert buttons and diff -->",
"""TensorFlow Similarity is a TensorFlow library focused on making metric learning easy"""
],
[
"# Module: TFSimilarity",
"# TensorFlow Similarity API Documentation"
],
]
replace_in_file(mfname, reps)
cprint("[Bulk patching]", 'yellow')
# pattern, replacement
reps = [
["description: .+", ""], # remove "pseudo frontmatter"
["^\[", '- ['], # make list valid again
["[^#]+\# ", '# '],
[" module", ''],
]
for fname in Path(OUTDIR).glob('**/*md'):
fname = str(fname)
replace_in_file(fname, reps)