parent
81dea92676
commit
57899d7655
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import venv
|
|||
import subprocess
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
|
||||
from scripts import utils, link_pyqt
|
||||
from scripts import utils, link_pyqt, asciidoc2html
|
||||
|
||||
|
||||
REPO_ROOT = pathlib.Path(__file__).parent.parent
|
||||
|
|
@ -58,6 +58,10 @@ def parse_args() -> argparse.Namespace:
|
|||
parser.add_argument('--virtualenv',
|
||||
action='store_true',
|
||||
help="Use virtualenv instead of venv.")
|
||||
parser.add_argument('--asciidoc', help="Full path to python and "
|
||||
"asciidoc.py. If not given, it's searched in PATH.",
|
||||
nargs=2, required=False,
|
||||
metavar=('PYTHON', 'ASCIIDOC'))
|
||||
parser.add_argument('--tox-error',
|
||||
action='store_true',
|
||||
help=argparse.SUPPRESS)
|
||||
|
|
@ -203,6 +207,12 @@ def install_qutebrowser(venv_dir: pathlib.Path) -> None:
|
|||
pip_install(venv_dir, '-e', str(REPO_ROOT))
|
||||
|
||||
|
||||
def regenerate_docs(venv_dir: pathlib.Path, asciidoc: typing.Tuple[str, str]):
|
||||
"""Regenerate docs using asciidoc."""
|
||||
utils.print_title("Generating documentation")
|
||||
asciidoc2html.run(website=False, asciidoc=asciidoc)
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Install qutebrowser in a virtualenv.."""
|
||||
args = parse_args()
|
||||
|
|
@ -235,6 +245,7 @@ def main() -> None:
|
|||
|
||||
install_requirements(venv_dir)
|
||||
install_qutebrowser(venv_dir)
|
||||
regenerate_docs(venv_dir, args.asciidoc)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in New Issue