-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_readme.py
38 lines (34 loc) · 1.48 KB
/
generate_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from py_simple_readme import readme_generator
about = "I'm tired of hand-making big, navigatable readme.md files for github projects so I made this to make the process a lot less tedious. This readme was generated by this project."
install_message = "Available on pip - `pip install py_simple_readme`"
usage_code = """from py_simple_readme import readme_generator()
gen = readme_generator(title="Example", slogan="This goes below the title in the readme")
gen.set_changelog({"0.0.0": "Push"})
gen.add_heading_1("About")
gen.add_paragraph("A paragraph about the project.")
gen.add_heading_1("Installation")
gen.add_paragraph("Installation instructions")
gen.add_heading_1("Usage")
gen.add_paragraph("A paragraph about using the module")
with open("readme.md", "w+") as f:
f.write(gen.assemble())
"""
def generate_readme(tables: dict, changelog: dict):
name = tables["project"]["name"]
version = tables["project"]["version"]
description = tables["project"]["description"]
gen = readme_generator(title=f"{name} {version}", slogan=description)
gen.set_changelog(changelog)
gen.add_heading_1("About")
gen.add_paragraph(about)
gen.increase_toc_depth()
gen.add_heading_3("Installation")
gen.add_paragraph(install_message)
gen.decrease_toc_depth()
gen.add_heading_1("Usage")
gen.increase_toc_depth()
gen.add_heading_3("Example")
gen.add_code_block(usage_code)
gen.decrease_toc_depth()
gen.handle_class_list([readme_generator])
return gen.assemble()