Improve documentation build

This commit is contained in:
Victor Zverovich 2016-06-03 07:19:05 -07:00
parent 5940431e2d
commit 81e2dac955
3 changed files with 24 additions and 14 deletions

View File

@ -80,21 +80,24 @@
</div> {# /.tb-container #}
</nav>
{% if pagename == "index" %}
{% set download_url = 'https://github.com/fmtlib/fmt/releases/download' %}
<div class="jumbotron">
<div class="tb-container">
<h1>{fmt}</h1>
<p class="lead">Small, safe and fast formatting library</p>
<div class="btn-group" role="group">
<a class="btn btn-success"
href="https://github.com/fmtlib/fmt/releases/download/2.0.0/cppformat-2.0.0.zip">
href="{{download_url}}/{{version}}/fmt-{{version}}.zip">
<span class="glyphicon glyphicon-download"></span> Download
</a>
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
{# TODO: update downloads automatically #}
<button type="button" class="btn btn-success dropdown-toggle"
data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://github.com/fmtlib/fmt/releases/download/2.0.0/cppformat-2.0.0.zip">Version 2.0.0</a></li>
<li><a href="https://github.com/fmtlib/fmt/releases/download/1.1.0/cppformat-1.1.0.zip">Version 1.1.0</a></li>
<li><a href="https://github.com/fmtlib/fmt/releases/download/1.0.0/cppformat-1.0.0.zip">Version 1.0.0</a></li>
{% for v in versions.split(',') %}
{% set name = 'fmt' if v.split('.')[0]|int >= 3 else 'cppformat' %}
<li><a href="{{download_url}}/{{v}}/{{name}}-{{v}}.zip">Version {{v}}
</a></li>
{% endfor %}
</ul>
</div>
</div>
@ -111,7 +114,7 @@
{% block content %}
<div class="tb-container">
<div class="row">
{# TODO: integrate sidebar
{# Sidebar is currently disabled.
<div class="bs-sidebar">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">

View File

@ -20,7 +20,7 @@ def pip_install(package, commit=None, **kwargs):
pass
if commit:
package = 'git+git://github.com/{0}.git@{1}'.format(package, commit)
print('Installing {}'.format(package))
print('Installing {0}'.format(package))
check_call(['pip', 'install', package])
def create_build_env(dirname='virtualenv'):

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python
import os, re, shutil, sys
from distutils.version import LooseVersion
from subprocess import check_call
class Git:
@ -62,27 +63,33 @@ for version in ['1.0.0', '1.1.0', '2.0.0', '3.0.0']:
dst = os.path.join(target_doc_dir, entry)
copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile
copy(src, dst)
# TODO: update links in navbar
# 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)
# Fix issues in reference.rst.
reference = os.path.join(target_doc_dir, 'reference.rst')
if os.path.exists(reference):
# Fix issues in reference.rst/api.rst.
for filename in ['reference.rst', 'api.rst']:
reference = os.path.join(target_doc_dir, filename)
if not os.path.exists(reference):
continue
with open(reference) as f:
data = f.read()
data = data.replace('std::ostream &', 'std::ostream&')
data = re.sub(r'doxygenfunction.. (bin|oct|hexu|hex)',
data = re.sub(re.compile('doxygenfunction.. (bin|oct|hexu|hex)$', re.MULTILINE),
r'doxygenfunction:: \1(int)', data)
data = data.replace('std::FILE*', 'std::FILE *')
data = data.replace('unsigned int', 'unsigned')
with open(reference, 'w') as f:
f.write(data)
# Build the docs.
html_dir = os.path.join(build_dir, 'html')
if os.path.exists(html_dir):
shutil.rmtree(html_dir)
include_dir = fmt_repo.dir
if LooseVersion(version) >= LooseVersion('3.0.0'):
include_dir = os.path.join(include_dir, 'fmt')
build.build_docs(version, doc_dir=target_doc_dir,
include_dir=fmt_repo.dir, work_dir=build_dir)
include_dir=include_dir, work_dir=build_dir)
# Create symlinks for older versions.
for link, target in {'index': 'contents', 'api': 'reference'}.items():
link = os.path.join(html_dir, link) + '.html'