summaryrefslogtreecommitdiff
path: root/scripts/asciidoc2html.py
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-01-27 15:27:43 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-01-27 15:27:43 +0100
commit57899d765562cef60e577d1c498ffc51e16824e4 (patch)
treecdb61356463b006e069a354c1da5b4f428b04b64 /scripts/asciidoc2html.py
parent81dea9267687be59ac16898bef6e0840ef683282 (diff)
downloadqutebrowser-57899d765562cef60e577d1c498ffc51e16824e4.tar.gz
qutebrowser-57899d765562cef60e577d1c498ffc51e16824e4.zip
Generate docs as part of mkvenv.py
See #5186
Diffstat (limited to 'scripts/asciidoc2html.py')
-rwxr-xr-xscripts/asciidoc2html.py37
1 files changed, 24 insertions, 13 deletions
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
index 2706e02e5..ceac1ff41 100755
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -42,9 +42,10 @@ class AsciiDoc:
FILES = ['faq', 'changelog', 'contributing', 'quickstart', 'userscripts']
- def __init__(self, args):
+ def __init__(self, asciidoc, website):
self._cmd = None
- self._args = args
+ self._asciidoc = asciidoc
+ self._website = website
self._homedir = None
self._themedir = None
self._tempdir = None
@@ -67,7 +68,7 @@ class AsciiDoc:
def build(self):
"""Build either the website or the docs."""
- if self._args.website:
+ if self._website:
self._build_website()
else:
self._build_docs()
@@ -120,7 +121,7 @@ class AsciiDoc:
"""Build a single website file."""
src = os.path.join(root, filename)
src_basename = os.path.basename(src)
- parts = [self._args.website[0]]
+ parts = [self._website[0]]
dirname = os.path.dirname(src)
if dirname:
parts.append(os.path.relpath(os.path.dirname(src)))
@@ -191,7 +192,7 @@ class AsciiDoc:
theme_file = os.path.abspath(os.path.join('www', 'qute.css'))
shutil.copy(theme_file, self._themedir)
- outdir = self._args.website[0]
+ outdir = self._website[0]
for root, _dirs, files in os.walk(os.getcwd()):
for filename in files:
@@ -221,8 +222,8 @@ class AsciiDoc:
def _get_asciidoc_cmd(self):
"""Try to find out what commandline to use to invoke asciidoc."""
- if self._args.asciidoc is not None:
- return self._args.asciidoc
+ if self._asciidoc is not None:
+ return self._asciidoc
try:
subprocess.run(['asciidoc'], stdout=subprocess.DEVNULL,
@@ -267,10 +268,8 @@ class AsciiDoc:
sys.exit(1)
-def main(colors=False):
- """Generate html files for the online documentation."""
- utils.change_cwd()
- utils.use_color = colors
+def parse_args():
+ """Parse command-line arguments."""
parser = argparse.ArgumentParser()
parser.add_argument('--website', help="Build website into a given "
"directory.", nargs=1)
@@ -278,13 +277,17 @@ def main(colors=False):
"asciidoc.py. If not given, it's searched in PATH.",
nargs=2, required=False,
metavar=('PYTHON', 'ASCIIDOC'))
- args = parser.parse_args()
+ return parser.parse_args()
+
+
+def run(**kwargs):
+ """Regenerate documentation."""
try:
os.mkdir('qutebrowser/html/doc')
except FileExistsError:
pass
- asciidoc = AsciiDoc(args)
+ asciidoc = AsciiDoc(**kwargs)
try:
asciidoc.prepare()
except FileNotFoundError:
@@ -299,5 +302,13 @@ def main(colors=False):
asciidoc.cleanup()
+def main(colors=False):
+ """Generate html files for the online documentation."""
+ utils.change_cwd()
+ utils.use_color = colors
+ args = parse_args()
+ run(asciidoc=args.asciidoc, website=args.website)
+
+
if __name__ == '__main__':
main(colors=True)