-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmakedoc.py
executable file
·40 lines (33 loc) · 1.21 KB
/
makedoc.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
39
40
#!/usr/bin/python
"""makedoc.py takes the README.md file and creates the doc.go file.
This makes keeping the Markdown and godoc in sync easy. It doesn't understand all aspects of
Markdown, or all aspects of Godoc, just the few that are used in this repo.
To update documentation, update the README.md, and then run this script to update the doc.go file.
Do not edit doc.go directly.
"""
def main():
"""Main."""
doc = []
for line in open("README.md"):
if line.startswith("[![Build"):
continue
if line == "pyfmt":
continue
# Fix up the header to be in pyfmt format
if line.startswith("pyfmt implements"):
line = "Package " + line
if line.startswith("```"):
continue
if line.startswith("#"):
line = line.lstrip("#").lstrip(" ")
doc.append(line)
with open("doc.go", 'w') as outp:
outp.write("// Copyright 2018 Stephen Longfield, Jr.\n")
outp.write("// Autogenerated by makedoc.py DO NOT EDIT \n\n")
outp.write("/*\n")
for line in doc:
outp.write(line)
outp.write("*/\n")
outp.write("package pyfmt\n")
if __name__ == '__main__':
main()