Skip to content

Commit 47e4276

Browse files
authored
Merge pull request #21 from jayvdb/sphinx-templates
WIP: Use upstream sphinx templates
2 parents 7be8b89 + a4be270 commit 47e4276

File tree

11 files changed

+357
-85
lines changed

11 files changed

+357
-85
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ jobs:
1919
- git diff --exit-code
2020

2121
stage: test
22+
23+
before_script:
24+
- git clone https://github.com/sphinx-doc/sphinx ../sphinx
25+
- (cd .. && ln -s sphinx/sphinx/templates/quickstart/
26+
sphinx-quickstart-templates)
27+
- sed -i "s/{{ \(\w*\) | repr }}/'{{ \1 }}'/;s/{%- \(for\|endfor\)/{% \1/"
28+
../sphinx-quickstart-templates/conf.py_t
29+
2230
script:
2331
- find templates/ -type f -name '*.jj2' -exec echo '{}' \;|sed -e "s/templates\//{%include \"/" -e "s/$/\" %}/" > test.file
2432
- moban -c config/data.yml -t test.file -td templates .

config/data.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ description: Scaffolding templates for your Python project.
1212
release: 0.0.0
1313
gitter_room: chfw_moban/Lobby
1414
setup_py: false
15+
rsrcdir: docs/source
16+
rbuilddir: docs/_build
17+
version: 0.1.1rc3
18+
mastertocmaxdepth: 3

local.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ configuration:
33
template_dir:
44
- .moban.dt/
55
- templates
6+
- ../sphinx-quickstart-templates
67
targets:
78
- .gitignore: gitignore.jj2
89
- LICENSE: NEW_BSD_LICENSE.jj2
910
- README.rst: local-README.rst.jj2
11+
copy:
12+
- templates/docs/Makefile.jj2: Makefile.new_t
13+
- templates/docs/make.bat.jj2: make.bat.new_t
14+
- templates/docs/master_doc.rst_t: master_doc.rst_t
15+
- templates/docs/conf.py_t: conf.py_t

templates/conf.py.jj2

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,48 @@ DESCRIPTION = (
77
{% endfor %}
88
''
99
)
10-
extensions = [
11-
'sphinx.ext.autodoc',
12-
'sphinx.ext.doctest',
13-
'sphinx.ext.intersphinx',
14-
'sphinx.ext.viewcode',
15-
{%block SPHINX_EXTENSIONS%}
16-
{%endblock%}
17-
]
18-
intersphinx_mapping = {
19-
{%block intersphinx_mapping%}
20-
{%endblock%}
21-
}
22-
templates_path = ['_templates']
23-
source_suffix = '.rst'
24-
master_doc = 'index'
10+
{% set project_str = name %}
11+
{% set copyright_str = '{0} {1}'.format(copyright_year, company) %}
12+
{% set author_str = author %}
13+
{% set author = company %}
14+
{% set version_str = release %}
15+
{% set release_str = version %}
16+
{% if sphinx_extensions %}
17+
{% set extensions = sphinx_extensions %}
18+
{% else %}
19+
{% set extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode'] %}
20+
{% endif %}
21+
{% set project_fn = name %}
22+
{% set dot = '_' %}
23+
{% set suffix = '.rst' %}
24+
{% set master_str = 'index' %}
25+
{% set language = 'en' %}
26+
{% set project_doc_str = name + ' Documentation' %}
27+
{# TeX config #}
28+
{% set project_doc_texescaped_str = project_doc_str %}
29+
{% set author_texescaped_str = author %}
30+
{# Man config #}
31+
{% set project_manpage = name %}
32+
{% include 'docs/conf.py_t' %}
2533

26-
project = u'{{name}}'
27-
copyright = u'{{copyright_year}} {{company}}'
28-
version = '{{release}}'
29-
release = '{{version}}'
30-
exclude_patterns = []
31-
pygments_style = 'sphinx'
34+
# TODO: html_theme not configurable upstream
3235
{%block custom_doc_theme%}
36+
{% if sphinx_html_theme %}
37+
html_theme = '{{ sphinx_html_theme }}'
38+
{% else %}
3339
html_theme = 'default'
40+
{% endif %}
3441
{%endblock%}
35-
html_static_path = ['_static']
36-
htmlhelp_basename = '{{name}}doc'
37-
latex_elements = {}
38-
latex_documents = [
39-
('index', '{{name}}.tex',
40-
'{{name}} Documentation',
41-
'{{company}}', 'manual'),
42-
]
43-
man_pages = [
44-
('index', '{{name}}',
45-
'{{name}} Documentation',
46-
[u'{{company}}'], 1)
47-
]
42+
43+
# TODO: DESCRIPTION not configurable upstream
4844
texinfo_documents = [
4945
('index', '{{name}}',
5046
'{{name}} Documentation',
5147
'{{company}}', '{{name}}',
5248
DESCRIPTION,
5349
'Miscellaneous'),
5450
]
51+
intersphinx_mapping.update({
52+
{% block intersphinx_mapping %}
53+
{% endblock %}
54+
})

templates/docs/Makefile.jj2

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SOURCEDIR = {{ rsrcdir }}
8+
BUILDDIR = {{ rbuilddir }}
9+
10+
# Put it first so that "make" without argument is like "make help".
11+
help:
12+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
13+
14+
.PHONY: help Makefile
15+
16+
# Catch-all target: route all unknown targets to Sphinx using the new
17+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18+
%: Makefile
19+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

templates/docs/conf.py_t

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Configuration file for the Sphinx documentation builder.
4+
#
5+
# This file does only contain a selection of the most common options. For a
6+
# full list see the documentation:
7+
# http://www.sphinx-doc.org/en/master/config
8+
9+
# -- Path setup --------------------------------------------------------------
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
{% if append_syspath -%}
16+
import os
17+
import sys
18+
sys.path.insert(0, u'{{ module_path }}')
19+
{% else -%}
20+
# import os
21+
# import sys
22+
{% if module_path -%}
23+
# sys.path.insert(0, u'{{ module_path }}')
24+
{% else -%}
25+
# sys.path.insert(0, os.path.abspath('.'))
26+
{% endif -%}
27+
{% endif %}
28+
29+
# -- Project information -----------------------------------------------------
30+
31+
project = u'{{ project_str }}'
32+
copyright = u'{{ copyright_str }}'
33+
author = u'{{ author_str }}'
34+
35+
# The short X.Y version
36+
version = u'{{ version_str }}'
37+
# The full version, including alpha/beta/rc tags
38+
release = u'{{ release_str }}'
39+
40+
41+
# -- General configuration ---------------------------------------------------
42+
43+
# If your documentation needs a minimal Sphinx version, state it here.
44+
#
45+
# needs_sphinx = '1.0'
46+
47+
# Add any Sphinx extension module names here, as strings. They can be
48+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
49+
# ones.
50+
extensions = [
51+
{% for ext in extensions %}
52+
'{{ ext }}',
53+
{% endfor %}
54+
]
55+
56+
# Add any paths that contain templates here, relative to this directory.
57+
templates_path = ['{{ dot }}templates']
58+
59+
# The suffix(es) of source filenames.
60+
# You can specify multiple suffix as a list of string:
61+
#
62+
# source_suffix = ['.rst', '.md']
63+
source_suffix = '{{ suffix }}'
64+
65+
# The master toctree document.
66+
master_doc = '{{ master_str }}'
67+
68+
# The language for content autogenerated by Sphinx. Refer to documentation
69+
# for a list of supported languages.
70+
#
71+
# This is also used if you do content translation via gettext catalogs.
72+
# Usually you set "language" from the command line for these cases.
73+
language = '{{ language }}'
74+
75+
# List of patterns, relative to source directory, that match files and
76+
# directories to ignore when looking for source files.
77+
# This pattern also affects html_static_path and html_extra_path.
78+
exclude_patterns = [{{ exclude_patterns }}]
79+
80+
# The name of the Pygments (syntax highlighting) style to use.
81+
pygments_style = 'sphinx'
82+
83+
84+
# -- Options for HTML output -------------------------------------------------
85+
86+
# The theme to use for HTML and HTML Help pages. See the documentation for
87+
# a list of builtin themes.
88+
#
89+
html_theme = 'alabaster'
90+
91+
# Theme options are theme-specific and customize the look and feel of a theme
92+
# further. For a list of options available for each theme, see the
93+
# documentation.
94+
#
95+
# html_theme_options = {}
96+
97+
# Add any paths that contain custom static files (such as style sheets) here,
98+
# relative to this directory. They are copied after the builtin static files,
99+
# so a file named "default.css" will overwrite the builtin "default.css".
100+
html_static_path = ['{{ dot }}static']
101+
102+
# Custom sidebar templates, must be a dictionary that maps document names
103+
# to template names.
104+
#
105+
# The default sidebars (for documents that don't match any pattern) are
106+
# defined by theme itself. Builtin themes are using these templates by
107+
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
108+
# 'searchbox.html']``.
109+
#
110+
# html_sidebars = {}
111+
112+
113+
# -- Options for HTMLHelp output ---------------------------------------------
114+
115+
# Output file base name for HTML help builder.
116+
htmlhelp_basename = '{{ project_fn }}doc'
117+
118+
119+
# -- Options for LaTeX output ------------------------------------------------
120+
121+
latex_elements = {
122+
# The paper size ('letterpaper' or 'a4paper').
123+
#
124+
# 'papersize': 'letterpaper',
125+
126+
# The font size ('10pt', '11pt' or '12pt').
127+
#
128+
# 'pointsize': '10pt',
129+
130+
# Additional stuff for the LaTeX preamble.
131+
#
132+
# 'preamble': '',
133+
134+
# Latex figure (float) alignment
135+
#
136+
# 'figure_align': 'htbp',
137+
}
138+
139+
# Grouping the document tree into LaTeX files. List of tuples
140+
# (source start file, target name, title,
141+
# author, documentclass [howto, manual, or own class]).
142+
latex_documents = [
143+
(master_doc, '{{ project_fn }}.tex', u'{{ project_doc_texescaped_str }}',
144+
u'{{ author_texescaped_str }}', 'manual'),
145+
]
146+
147+
148+
# -- Options for manual page output ------------------------------------------
149+
150+
# One entry per manual page. List of tuples
151+
# (source start file, name, description, authors, manual section).
152+
man_pages = [
153+
(master_doc, '{{ project_manpage }}', u'{{ project_doc_str }}',
154+
[author], 1)
155+
]
156+
157+
158+
# -- Options for Texinfo output ----------------------------------------------
159+
160+
# Grouping the document tree into Texinfo files. List of tuples
161+
# (source start file, target name, title, author,
162+
# dir menu entry, description, category)
163+
texinfo_documents = [
164+
(master_doc, '{{ project_fn }}', u'{{ project_doc_str }}',
165+
author, '{{ project_fn }}', 'One line description of project.',
166+
'Miscellaneous'),
167+
]
168+
{%- if epub %}
169+
170+
171+
# -- Options for Epub output -------------------------------------------------
172+
173+
# Bibliographic Dublin Core info.
174+
epub_title = project
175+
epub_author = author
176+
epub_publisher = author
177+
epub_copyright = copyright
178+
179+
# The unique identifier of the text. This can be a ISBN number
180+
# or the project homepage.
181+
#
182+
# epub_identifier = ''
183+
184+
# A unique identification for the text.
185+
#
186+
# epub_uid = ''
187+
188+
# A list of files that should not be packed into the epub file.
189+
epub_exclude_files = ['search.html']
190+
{%- endif %}
191+
{%- if extensions %}
192+
193+
194+
# -- Extension configuration -------------------------------------------------
195+
{%- endif %}
196+
{%- if 'sphinx.ext.intersphinx' in extensions %}
197+
198+
# -- Options for intersphinx extension ---------------------------------------
199+
200+
# Example configuration for intersphinx: refer to the Python standard library.
201+
intersphinx_mapping = {'https://docs.python.org/': None}
202+
{%- endif %}
203+
{%- if 'sphinx.ext.todo' in extensions %}
204+
205+
# -- Options for todo extension ----------------------------------------------
206+
207+
# If true, `todo` and `todoList` produce output, else they produce nothing.
208+
todo_include_todos = True
209+
{%- endif %}

templates/docs/index.rst.jj2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% macro underlines(name) %}
2+
{%- for i in range(name|length) -%}={%- endfor -%}
3+
{% endmacro %}
4+
{% set project = name %}
5+
{% set project_underline = underlines(name) %}
6+
{% set mastertoctree = '
7+
.. toctree::
8+
:caption: API Documentation
9+
:hidden:
10+
11+
List of Modules<modules>
12+
' %}
13+
{% include "docs/master_doc.rst_t" %}

0 commit comments

Comments
 (0)