fmt/support/mkdocs

32 lines
951 B
Plaintext
Raw Normal View History

2024-06-02 16:29:07 +00:00
#!/usr/bin/env python3
# A script to invoke mkdocs with the correct environment.
2024-06-09 20:17:13 +00:00
import os, shutil, sys
from subprocess import call
2024-06-02 16:29:07 +00:00
2024-06-09 20:17:13 +00:00
dirname = os.path.dirname(__file__)
2024-06-02 16:47:52 +00:00
2024-06-02 16:29:07 +00:00
# Set PYTHONPATH for the mkdocstrings handler.
env = os.environ.copy()
path = env.get('PYTHONPATH')
2024-06-09 20:17:13 +00:00
env['PYTHONPATH'] = \
(path + ':' if path else '') + os.path.join(dirname, 'python')
2024-06-02 16:29:07 +00:00
2024-06-02 16:47:52 +00:00
config_path = os.path.join(dirname, 'mkdocs.yml')
2024-06-09 18:37:18 +00:00
args = sys.argv[1:]
2024-06-09 20:17:13 +00:00
if len(args) > 0:
command = args[0]
if command == 'deploy':
site_dir = 'fmt.dev'
shutil.rmtree(site_dir)
ret = call(['git', 'clone', '--depth=1',
'git@github.com:fmtlib/fmt.dev.git'])
if ret != 0:
sys.exit(ret)
sys.exit(call(['mike', 'deploy', '--config-file', config_path,
'--branch', 'master', 'dev'],
cwd=site_dir, env=env))
elif not command.startswith('-'):
2024-06-09 18:37:18 +00:00
args += ['-f', config_path]
2024-06-09 20:17:13 +00:00
sys.exit(call(['mkdocs'] + args, env=env))