summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-05-20 20:07:36 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-20 20:07:36 +0200
commit2f2cf55f74a6710748cbf369226dd1d80667ec30 (patch)
treead0cb5344c471e6faee4fca70c5db0762f2766e4
parent5d4ee9e471c2a543423382e3e79ea5e886e7fe6f (diff)
downloadweechat-2f2cf55f74a6710748cbf369226dd1d80667ec30.zip
doc: format script with black
-rwxr-xr-xdoc/python_stub.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/python_stub.py b/doc/python_stub.py
index dcc7fcb51..9e4be9ed8 100755
--- a/doc/python_stub.py
+++ b/doc/python_stub.py
@@ -28,7 +28,7 @@ from typing import TextIO
import re
-DOC_DIR = Path(__file__).resolve().parent / 'en'
+DOC_DIR = Path(__file__).resolve().parent / "en"
STUB_HEADER = """\
#
@@ -57,11 +57,11 @@ def write_stub_constants(stub_file: TextIO) -> None:
Write constants in the stub file, extracted from the Scripting guide.
"""
types = {
- 'integer': 'int',
- 'string': 'str',
+ "integer": "int",
+ "string": "str",
}
constant_pattern = re.compile(CONSTANT_RE)
- with open(DOC_DIR / 'weechat_scripting.en.adoc') as scripting_file:
+ with open(DOC_DIR / "weechat_scripting.en.adoc") as scripting_file:
scripting = scripting_file.read()
for match in constant_pattern.finditer(scripting):
stub_file.write(f'{match["constant"]}: {types[match["type"]]}\n')
@@ -73,24 +73,26 @@ def write_stub_functions(stub_file: TextIO) -> None:
Plugin API reference.
"""
function_pattern = re.compile(FUNCTION_RE, re.DOTALL)
- with open(DOC_DIR / 'weechat_plugin_api.en.adoc') as api_doc_file:
+ with open(DOC_DIR / "weechat_plugin_api.en.adoc") as api_doc_file:
api_doc = api_doc_file.read()
for match in function_pattern.finditer(api_doc):
url = f'https://weechat.org/doc/api#_{match["function"]}'
- stub_file.write(f"""\n
+ stub_file.write(
+ f"""\n
def {match["function"]}{match["args"]}{match["return"]}
\"""`{match["function"]} in WeeChat plugin API reference <{url}>`_\"""
...
-""")
+"""
+ )
def stub_api() -> None:
"""Write Python stub file."""
- with open('weechat.pyi', 'w') as stub_file:
+ with open("weechat.pyi", "w") as stub_file:
stub_file.write(STUB_HEADER)
write_stub_constants(stub_file)
write_stub_functions(stub_file)
-if __name__ == '__main__':
+if __name__ == "__main__":
stub_api()