From 31418a90da67a1bcd1af0a39f33e8ecc5cdd2d49 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 15 Feb 2022 23:28:50 +0000 Subject: Use black for formatting --- tools/hdoc.py | 75 +++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'tools/hdoc.py') 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 ", - ) - - 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 ", + ) + + 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: -- cgit v1.2.3