mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-27 12:30:06 +00:00
Improve documentation build
This commit is contained in:
parent
5940431e2d
commit
81e2dac955
17
doc/_templates/layout.html
vendored
17
doc/_templates/layout.html
vendored
@ -80,21 +80,24 @@
|
|||||||
</div> {# /.tb-container #}
|
</div> {# /.tb-container #}
|
||||||
</nav>
|
</nav>
|
||||||
{% if pagename == "index" %}
|
{% if pagename == "index" %}
|
||||||
|
{% set download_url = 'https://github.com/fmtlib/fmt/releases/download' %}
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<div class="tb-container">
|
<div class="tb-container">
|
||||||
<h1>{fmt}</h1>
|
<h1>{fmt}</h1>
|
||||||
<p class="lead">Small, safe and fast formatting library</p>
|
<p class="lead">Small, safe and fast formatting library</p>
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<a class="btn btn-success"
|
<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
|
<span class="glyphicon glyphicon-download"></span> Download
|
||||||
</a>
|
</a>
|
||||||
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
|
<button type="button" class="btn btn-success dropdown-toggle"
|
||||||
{# TODO: update downloads automatically #}
|
data-toggle="dropdown"><span class="caret"></span></button>
|
||||||
<ul class="dropdown-menu">
|
<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>
|
{% for v in versions.split(',') %}
|
||||||
<li><a href="https://github.com/fmtlib/fmt/releases/download/1.1.0/cppformat-1.1.0.zip">Version 1.1.0</a></li>
|
{% set name = 'fmt' if v.split('.')[0]|int >= 3 else 'cppformat' %}
|
||||||
<li><a href="https://github.com/fmtlib/fmt/releases/download/1.0.0/cppformat-1.0.0.zip">Version 1.0.0</a></li>
|
<li><a href="{{download_url}}/{{v}}/{{name}}-{{v}}.zip">Version {{v}}
|
||||||
|
</a></li>
|
||||||
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -111,7 +114,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="tb-container">
|
<div class="tb-container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{# TODO: integrate sidebar
|
{# Sidebar is currently disabled.
|
||||||
<div class="bs-sidebar">
|
<div class="bs-sidebar">
|
||||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||||
<div class="sphinxsidebarwrapper">
|
<div class="sphinxsidebarwrapper">
|
||||||
|
@ -20,7 +20,7 @@ def pip_install(package, commit=None, **kwargs):
|
|||||||
pass
|
pass
|
||||||
if commit:
|
if commit:
|
||||||
package = 'git+git://github.com/{0}.git@{1}'.format(package, 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])
|
check_call(['pip', 'install', package])
|
||||||
|
|
||||||
def create_build_env(dirname='virtualenv'):
|
def create_build_env(dirname='virtualenv'):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os, re, shutil, sys
|
import os, re, shutil, sys
|
||||||
|
from distutils.version import LooseVersion
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
|
||||||
class Git:
|
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)
|
dst = os.path.join(target_doc_dir, entry)
|
||||||
copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile
|
copy = shutil.copytree if os.path.isdir(src) else shutil.copyfile
|
||||||
copy(src, dst)
|
copy(src, dst)
|
||||||
# TODO: update links in navbar
|
|
||||||
# Rename index to contents.
|
# Rename index to contents.
|
||||||
contents = os.path.join(target_doc_dir, 'contents.rst')
|
contents = os.path.join(target_doc_dir, 'contents.rst')
|
||||||
if not os.path.exists(contents):
|
if not os.path.exists(contents):
|
||||||
os.rename(os.path.join(target_doc_dir, 'index.rst'), contents)
|
os.rename(os.path.join(target_doc_dir, 'index.rst'), contents)
|
||||||
# Fix issues in reference.rst.
|
# Fix issues in reference.rst/api.rst.
|
||||||
reference = os.path.join(target_doc_dir, 'reference.rst')
|
for filename in ['reference.rst', 'api.rst']:
|
||||||
if os.path.exists(reference):
|
reference = os.path.join(target_doc_dir, filename)
|
||||||
|
if not os.path.exists(reference):
|
||||||
|
continue
|
||||||
with open(reference) as f:
|
with open(reference) as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
data = data.replace('std::ostream &', 'std::ostream&')
|
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)
|
r'doxygenfunction:: \1(int)', data)
|
||||||
|
data = data.replace('std::FILE*', 'std::FILE *')
|
||||||
|
data = data.replace('unsigned int', 'unsigned')
|
||||||
with open(reference, 'w') as f:
|
with open(reference, 'w') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
# Build the docs.
|
# Build the docs.
|
||||||
html_dir = os.path.join(build_dir, 'html')
|
html_dir = os.path.join(build_dir, 'html')
|
||||||
if os.path.exists(html_dir):
|
if os.path.exists(html_dir):
|
||||||
shutil.rmtree(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,
|
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.
|
# Create symlinks for older versions.
|
||||||
for link, target in {'index': 'contents', 'api': 'reference'}.items():
|
for link, target in {'index': 'contents', 'api': 'reference'}.items():
|
||||||
link = os.path.join(html_dir, link) + '.html'
|
link = os.path.join(html_dir, link) + '.html'
|
||||||
|
Loading…
Reference in New Issue
Block a user