Implement doc building

This commit is contained in:
Victor Zverovich 2024-06-09 13:17:13 -07:00
parent d4a8d26c55
commit ab6b257a39
2 changed files with 21 additions and 6 deletions

View File

@ -1,17 +1,31 @@
#!/usr/bin/env python3
# A script to invoke mkdocs with the correct environment.
import os, subprocess, sys
import os, shutil, sys
from subprocess import call
dirname = os.path.join(os.path.dirname(__file__), 'python')
dirname = os.path.dirname(__file__)
# Set PYTHONPATH for the mkdocstrings handler.
env = os.environ.copy()
path = env.get('PYTHONPATH')
env['PYTHONPATH'] = (path + ':' if path else '') + dirname
env['PYTHONPATH'] = \
(path + ':' if path else '') + os.path.join(dirname, 'python')
config_path = os.path.join(dirname, 'mkdocs.yml')
args = sys.argv[1:]
if 'build' in args:
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('-'):
args += ['-f', config_path]
subprocess.run(['mkdocs'] + args, env=env)
sys.exit(call(['mkdocs'] + args, env=env))

View File

@ -2,6 +2,7 @@
# Copyright (c) 2012 - present, Victor Zverovich
import os
from pathlib import Path
import xml.etree.ElementTree as et
from mkdocstrings.handlers.base import BaseHandler
from typing import Any, Mapping, Optional
@ -156,7 +157,7 @@ class CxxHandler(BaseHandler):
# Run doxygen.
cmd = ['doxygen', '-']
doc_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
doc_dir = Path(__file__).parents[3]
include_dir = os.path.join(os.path.dirname(doc_dir), 'include', 'fmt')
self._ns2doxyxml = {}
self._doxyxml_dir = 'doxyxml'