aboutsummaryrefslogtreecommitdiff
path: root/tools/hdoc.py
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-02-15 23:28:50 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-02-15 23:28:50 +0000
commit31418a90da67a1bcd1af0a39f33e8ecc5cdd2d49 (patch)
tree1127a547c91af3cb71912c6572a44c76484a1982 /tools/hdoc.py
parent9c984aa67d2bd607032ba7fa911c77f9bbf87d4c (diff)
downloadubox-msx-lib-31418a90da67a1bcd1af0a39f33e8ecc5cdd2d49.tar.gz
ubox-msx-lib-31418a90da67a1bcd1af0a39f33e8ecc5cdd2d49.zip
Use black for formatting
Diffstat (limited to 'tools/hdoc.py')
-rwxr-xr-xtools/hdoc.py75
1 files changed, 52 insertions, 23 deletions
diff --git a/tools/hdoc.py b/tools/hdoc.py
index 3a32eb3..4387110 100755
--- a/tools/hdoc.py
+++ b/tools/hdoc.py
@@ -17,29 +17,45 @@ RE_SECDOC = re.compile("//\s?(.*\n)")
def main():
- parser = ArgumentParser(description="Include docs to markdown",
- epilog="Copyright (C) 2020 Juan J Martinez <jjm@usebox.net>",
- )
-
- parser.add_argument("--version", action="version",
- version="%(prog)s " + __version__)
- parser.add_argument("--doc-version", dest="docver", default=None,
- help="Use this as version instead of git tag/commit")
- parser.add_argument("--header", dest="header", default=None,
- help="Add this file at the begining of the document")
- parser.add_argument("--footer", dest="footer", default=None,
- help="Add this file at the end of the document")
+ parser = ArgumentParser(
+ description="Include docs to markdown",
+ epilog="Copyright (C) 2020 Juan J Martinez <jjm@usebox.net>",
+ )
+
+ parser.add_argument(
+ "--version", action="version", version="%(prog)s " + __version__
+ )
+ parser.add_argument(
+ "--doc-version",
+ dest="docver",
+ default=None,
+ help="Use this as version instead of git tag/commit",
+ )
+ parser.add_argument(
+ "--header",
+ dest="header",
+ default=None,
+ help="Add this file at the begining of the document",
+ )
+ parser.add_argument(
+ "--footer",
+ dest="footer",
+ default=None,
+ help="Add this file at the end of the document",
+ )
parser.add_argument("title", help="Title of the resulting document")
args = parser.parse_args()
if args.docver is None:
- proc = Popen(["git", "describe", "--abbrev=0", "--tags"],
- stdout=PIPE, stderr=PIPE)
+ proc = Popen(
+ ["git", "describe", "--abbrev=0", "--tags"], stdout=PIPE, stderr=PIPE
+ )
out, err = proc.communicate()
if proc.returncode != 0:
- proc = Popen(["git", "rev-parse", "--short", "HEAD"],
- stdout=PIPE, stderr=PIPE)
+ proc = Popen(
+ ["git", "rev-parse", "--short", "HEAD"], stdout=PIPE, stderr=PIPE
+ )
out, err = proc.communicate()
out = b"git-" + out
@@ -117,14 +133,23 @@ def main():
g = RE_DOC.match(l)
if g:
doc += g.group(1)
- ref[name] = {"name": name, "anchor": anchor,
- "fn": fn, "doc": doc, "section": section}
-
- print("""\
+ ref[name] = {
+ "name": name,
+ "anchor": anchor,
+ "fn": fn,
+ "doc": doc,
+ "section": section,
+ }
+
+ print(
+ """\
---
title: '{title}'
subtitle: 'Version {version}'
-...""".format(title=args.title, version=docver))
+...""".format(
+ title=args.title, version=docver
+ )
+ )
if args.header:
with open(args.header, "rt") as fd:
@@ -139,14 +164,18 @@ subtitle: 'Version {version}'
if csec in sections:
print(sections[csec])
- print("""\
+ print(
+ """\
### {name}
```c
{fn}
```
{doc}
-""".format(**v))
+""".format(
+ **v
+ )
+ )
if args.footer:
with open(args.footer, "rt") as fd: