summaryrefslogtreecommitdiff
path: root/scripts/asciidoc2html.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/asciidoc2html.py')
-rwxr-xr-xscripts/asciidoc2html.py48
1 files changed, 6 insertions, 42 deletions
diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py
index 1b904736d..6f3b170af 100755
--- a/scripts/asciidoc2html.py
+++ b/scripts/asciidoc2html.py
@@ -20,7 +20,7 @@
"""Generate the html documentation based on the asciidoc files."""
-from typing import List, Optional
+from typing import Optional
import re
import os
import sys
@@ -48,13 +48,7 @@ class AsciiDoc:
'install', 'stacktrace'
]
- def __init__(self,
- asciidoc: Optional[str],
- asciidoc_python: Optional[str],
- website: Optional[str]) -> None:
- self._cmd: Optional[List[str]] = None
- self._asciidoc = asciidoc
- self._asciidoc_python = asciidoc_python
+ def __init__(self, website: Optional[str]) -> None:
self._website = website
self._homedir: Optional[pathlib.Path] = None
self._themedir: Optional[pathlib.Path] = None
@@ -63,7 +57,6 @@ class AsciiDoc:
def prepare(self) -> None:
"""Get the asciidoc command and create the homedir to use."""
- self._cmd = self._get_asciidoc_cmd()
self._homedir = pathlib.Path(tempfile.mkdtemp())
self._themedir = self._homedir / '.asciidoc' / 'themes' / 'qute'
self._tempdir = self._homedir / 'tmp'
@@ -224,26 +217,6 @@ class AsciiDoc:
except FileExistsError:
pass
- def _get_asciidoc_cmd(self) -> List[str]:
- """Try to find out what commandline to use to invoke asciidoc."""
- if self._asciidoc is not None:
- python = (sys.executable if self._asciidoc_python is None
- else self._asciidoc_python)
- return [python, self._asciidoc]
-
- for executable in ['asciidoc', 'asciidoc.py']:
- try:
- subprocess.run([executable, '--version'],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- check=True)
- except OSError:
- pass
- else:
- return [executable]
-
- raise FileNotFoundError
-
def call(self, src: pathlib.Path, dst: pathlib.Path, *args):
"""Call asciidoc for the given files.
@@ -253,8 +226,7 @@ class AsciiDoc:
*args: Additional arguments passed to asciidoc.
"""
print("Calling asciidoc for {}...".format(src.name))
- assert self._cmd is not None # for mypy
- cmdline = self._cmd[:]
+ cmdline = [sys.executable, "-m", "asciidoc"]
if dst is not None:
cmdline += ['--out-file', str(dst)]
cmdline += args
@@ -281,12 +253,6 @@ def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('--website', help="Build website into a given "
"directory.")
- parser.add_argument('--asciidoc', help="Full path to asciidoc.py. "
- "If not given, it's searched in PATH.",
- nargs='?')
- parser.add_argument('--asciidoc-python', help="Python to use for asciidoc."
- "If not given, the current Python interpreter is used.",
- nargs='?')
return parser.parse_args()
@@ -298,9 +264,8 @@ def run(**kwargs) -> None:
try:
asciidoc.prepare()
except FileNotFoundError:
- utils.print_error("Could not find asciidoc! Please install it, or use "
- "the --asciidoc argument to point this script to "
- "the correct asciidoc.py location!")
+ utils.print_error("Could not find asciidoc! Please install it, e.g. via "
+ "pip install -r misc/requirements/requirements-docs.txt")
sys.exit(1)
try:
@@ -314,8 +279,7 @@ def main(colors: bool = False) -> None:
utils.change_cwd()
utils.use_color = colors
args = parse_args()
- run(asciidoc=args.asciidoc, asciidoc_python=args.asciidoc_python,
- website=args.website)
+ run(website=args.website)
if __name__ == '__main__':