forked from fmtlib/fmt
Implement website update script
This commit is contained in:
@@ -51,7 +51,9 @@ def create_build_env():
|
|||||||
pip_install('michaeljones/breathe',
|
pip_install('michaeljones/breathe',
|
||||||
'1c9d7f80378a92cffa755084823a78bb38ee4acc')
|
'1c9d7f80378a92cffa755084823a78bb38ee4acc')
|
||||||
|
|
||||||
def build_docs(version='dev', doc_dir=os.path.dirname(os.path.realpath(__file__))):
|
def build_docs(version='dev', **kwargs):
|
||||||
|
doc_dir = kwargs.get('doc_dir', os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
include_dir = kwargs.get('include_dir', os.path.join(os.path.dirname(doc_dir), 'fmt'))
|
||||||
# Build docs.
|
# Build docs.
|
||||||
cmd = ['doxygen', '-']
|
cmd = ['doxygen', '-']
|
||||||
p = Popen(cmd, stdin=PIPE)
|
p = Popen(cmd, stdin=PIPE)
|
||||||
@@ -77,7 +79,7 @@ def build_docs(version='dev', doc_dir=os.path.dirname(os.path.realpath(__file__)
|
|||||||
FMT_USE_USER_DEFINED_LITERALS=1 \
|
FMT_USE_USER_DEFINED_LITERALS=1 \
|
||||||
FMT_API=
|
FMT_API=
|
||||||
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
|
||||||
'''.format(os.path.join(os.path.dirname(doc_dir), 'fmt')).encode('UTF-8'))
|
'''.format(include_dir).encode('UTF-8'))
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
raise CalledProcessError(p.returncode, cmd)
|
raise CalledProcessError(p.returncode, cmd)
|
||||||
check_call(['sphinx-build',
|
check_call(['sphinx-build',
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os, shutil, sys
|
import os, shutil, sys, tempfile
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
|
||||||
class Git:
|
class Git:
|
||||||
@@ -22,22 +22,41 @@ sys.path.insert(0, os.path.join(fmt_dir, 'doc'))
|
|||||||
import build
|
import build
|
||||||
build.create_build_env()
|
build.create_build_env()
|
||||||
|
|
||||||
git = Git('fmt')
|
fmt_repo = Git(tempfile.mkdtemp('fmt'))
|
||||||
git.clone('git@github.com:fmtlib/fmt.git')
|
try:
|
||||||
|
fmt_repo.clone('git@github.com:fmtlib/fmt')
|
||||||
|
doc_repo = Git('fmtlib.github.io')
|
||||||
|
doc_repo.clone('git@github.com:fmtlib/fmtlib.github.io')
|
||||||
|
|
||||||
versions = ['1.0.0']
|
versions = ['1.0.0']
|
||||||
for version in versions:
|
for version in versions:
|
||||||
git.checkout(version)
|
fmt_repo.checkout(version)
|
||||||
target_doc_dir = os.path.join(git.dir, 'doc')
|
target_doc_dir = os.path.join(fmt_repo.dir, 'doc')
|
||||||
# Remove the old theme.
|
# Remove the old theme.
|
||||||
for entry in os.listdir(target_doc_dir):
|
for entry in os.listdir(target_doc_dir):
|
||||||
path = os.path.join(target_doc_dir, entry)
|
path = os.path.join(target_doc_dir, entry)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
# Copy the new theme.
|
# Copy the new theme.
|
||||||
for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap']:
|
for entry in ['_static', '_templates', 'basic-bootstrap', 'bootstrap', 'conf.py', 'fmt.less']:
|
||||||
src = os.path.join(fmt_dir, 'doc', entry)
|
src = os.path.join(fmt_dir, 'doc', entry)
|
||||||
dst = os.path.join(target_doc_dir, entry)
|
dst = os.path.join(target_doc_dir, entry)
|
||||||
shutil.copytree(src, dst)
|
copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile
|
||||||
build.build_docs(version, target_doc_dir)
|
copy(src, dst)
|
||||||
# TODO: copy docs to website
|
# Rename index to contents.
|
||||||
|
contents = os.path.join(target_doc_dir, 'contents.rst')
|
||||||
|
if not os.path.exists(contents):
|
||||||
|
os.rename(os.path.join(target_doc_dir, 'index.rst'), contents)
|
||||||
|
# Build the docs.
|
||||||
|
build.build_docs(version, doc_dir=target_doc_dir, include_dir=fmt_repo.dir)
|
||||||
|
# Create symlinks for older versions.
|
||||||
|
for link, target in {'index': 'contents', 'api': 'reference'}.items():
|
||||||
|
os.symlink(target + '.html', os.path.join('html', link) + '.html')
|
||||||
|
# Copy docs to the website.
|
||||||
|
version_doc_dir = os.path.join(doc_repo.dir, version)
|
||||||
|
shutil.rmtree(version_doc_dir)
|
||||||
|
shutil.copytree('html', version_doc_dir, symlinks=True)
|
||||||
|
# TODO: fix links
|
||||||
|
# TODO: remove doc repo
|
||||||
|
except:
|
||||||
|
shutil.rmtree(fmt_repo.dir)
|
||||||
|
Reference in New Issue
Block a user