Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customized and bootstrap-ifyed HTMLTranslator #92

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
eaefb88
extending examples
torbjoernk Feb 16, 2014
77d53da
extending examples: autodoc/automodule
torbjoernk Feb 16, 2014
9d4a155
first draft of BootstrapHtmlTranslator
torbjoernk Feb 16, 2014
d994b1b
custom javascript to patch the HTML shouldn't be needed any more
torbjoernk Feb 16, 2014
716d59c
add support for Notes+Examples as admonitions
torbjoernk Feb 18, 2014
46180c2
fix admonition heading level; blockquote footer
torbjoernk Feb 18, 2014
d3e58b0
fix display of return values for Napoleon parser output
torbjoernk Feb 18, 2014
fad612a
fixup return type descriptions
torbjoernk Feb 19, 2014
7852aa3
Revert "custom javascript to patch the HTML shouldn't be needed any m…
torbjoernk Feb 19, 2014
a9c161a
add Font Awesome for better icons
torbjoernk Feb 20, 2014
e1e37fe
fix compact paragraph
torbjoernk Feb 20, 2014
efeab9b
make the navbar hidden for print
torbjoernk Feb 20, 2014
24cd3c6
rework footer
torbjoernk Feb 20, 2014
ef5609a
source and relations links now use Font Awesome icons
torbjoernk Feb 20, 2014
aa41a4e
remove unnecessary patches from javascript
torbjoernk Feb 20, 2014
1c81245
fix styling of footer and affix sidebar
torbjoernk Feb 20, 2014
1745e5a
remove relations from top navbar (they are now in the footer bar
torbjoernk Feb 20, 2014
3e10650
source link position defaults to footer now
torbjoernk Feb 20, 2014
51631a0
demo of sidebar for long page on Examples page
torbjoernk Feb 20, 2014
fe95d33
PEP8-ification + some docu for HTML Translator
torbjoernk Feb 21, 2014
010dc90
some adjustments to fix up BS 2.x styling
torbjoernk Feb 21, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions demo/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# Disabled: , 'sphinx.ext.intersphinx'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', 'sphinx.ext.viewcode']
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -62,15 +67,15 @@
#default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
show_authors = True

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
Expand All @@ -81,8 +86,21 @@
# Enable todo output
todo_include_todos = True

autoclass_content = 'class'
autodoc_member_order = 'bysource'
autodoc_default_flags = [
'members',
'undoc-members',
'private-members',
# 'special-members',
# 'inherited-members',
'show-inheritance'
]

# -- Options for HTML output ---------------------------------------------------

html_translator_class = 'sphinx_bootstrap_theme.BootstrapTranslator'

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'bootstrap'
Expand Down Expand Up @@ -132,7 +150,7 @@

# Location of link to source.
# Options are "nav" (default), "footer" or anything else to exclude.
'source_link_position': "nav",
'source_link_position': "footer",

# Bootswatch (http://bootswatch.com/) theme.
#
Expand Down Expand Up @@ -199,7 +217,10 @@

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
html_sidebars = {'sidebar': ['localtoc.html', 'sourcelink.html', 'searchbox.html']}
html_sidebars = {
'sidebar': ['localtoc.html', 'sourcelink.html', 'searchbox.html'],
'examples': ['localtoc.html']
}

# Additional templates that should be rendered to pages, maps page names to
# template names.
Expand All @@ -218,10 +239,10 @@
#html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
Expand Down
8 changes: 8 additions & 0 deletions demo/source/example_module.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Example Module (:mod:`ExampleModule`)
=====================================

.. automodule:: sphinx_bootstrap_theme.example_module
:members:
:undoc-members:
:private-members:
:special-members:
12 changes: 12 additions & 0 deletions demo/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ Danger
------
.. danger:: This is **danger**-ous.

Attention
---------
.. attention:: This is a note.

See Also
--------
.. seealso:: Probably a reference.

Error
-----
.. error:: This is a error.

Footnotes
=========
I have footnoted a first item [#f1]_ and second item [#f2]_.
Expand Down
8 changes: 8 additions & 0 deletions demo/source/html_bootstrap_translator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
HTML Bootstrap Translator (:mod:`html_bootstrap_translator`)
============================================================

.. automodule:: sphinx_bootstrap_theme.html_bootstrap_translator
:members:
:undoc-members:
:private-members:
:special-members:
3 changes: 3 additions & 0 deletions demo/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ Setting up and using the theme.
examples
sidebar
subdir/index
example_module
html_bootstrap_translator


Development history and feature wish lists.

Expand Down
3 changes: 3 additions & 0 deletions sphinx_bootstrap_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
__version__ = ".".join(str(v) for v in VERSION)
__version_full__ = __version__


def get_html_theme_path():
"""Return list of HTML theme paths."""
cur_dir = os.path.abspath(os.path.dirname(__file__))
return [cur_dir]

from sphinx_bootstrap_theme.html_bootstrap_translator import BootstrapTranslator
110 changes: 88 additions & 22 deletions sphinx_bootstrap_theme/bootstrap/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
{% if theme_bootstrap_version == "3" %}
{% set theme_css_files = theme_css_files + [
'_static/bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css',
'_static/font-awesome-4.0.3/css/font-awesome.min.css',
'_static/bootstrap-sphinx.css'
]
%}
{% else %}
{% set theme_css_files = theme_css_files + [
'_static/bootswatch-' + bootstrap_version + '/' + theme_bootswatch_theme + '/bootstrap.min.css',
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css',
'_static/font-awesome-4.0.3/css/font-awesome.min.css',
'_static/bootstrap-sphinx.css'
]
%}
Expand All @@ -29,6 +31,7 @@
{% set theme_css_files = theme_css_files + [
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap.min.css',
'_static/bootstrap-' + bootstrap_version + '/css/bootstrap-' + bootstrap_additional_css + '.min.css',
'_static/font-awesome-4.0.3/css/font-awesome.min.css',
'_static/bootstrap-sphinx.css'
]
%}
Expand Down Expand Up @@ -102,7 +105,7 @@
{%- block content %}
{{ navBar() }}
<div class="container">
<div class="row">
<div class="{% if theme_bootstrap_version == '3' %}row{% else %}row-fluid{% endif %}">
{%- block sidebar1 %}{{ bsidebar() }}{% endblock %}
<div class="{{ bs_span_prefix }}{{ bs_content_width }}">
{% block body %}{% endblock %}
Expand All @@ -114,28 +117,91 @@

{%- block footer %}
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
{% if theme_source_link_position == "footer" %}
<br/>
{% include "sourcelink.html" %}
{% endif %}
</p>
<p>
{%- if show_copyright %}
{%- if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}<br/>
{%- else %}
{% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}<br/>
{% if theme_bootstrap_version == "3" %}
<div class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#footer-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="footer-navbar-collapse">
<ul class="nav navbar-nav navbar-left">
{% if theme_source_link_position == "footer" %}
<li>
{% include "sourcelink.html" %}
</li>
{% endif %}
{% if theme_navbar_sidebarrel %}
<li>
{% include "relations.html" %}
</li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">
<i class="fa fa-chevron-up fa-fw"></i> <span class="hidden-sm hidden-xs">Back to top</span>
</a>
</li>
</ul>
</div>
</div>
</div>
{% else %}
<div class="navbar navbar-default navbar-fixed-bottom" role="navigation">
<div class="navbar-inner">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="btn btn-navbar" data-toggle="collapse" data-target="#footer-navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<div class="nav-collapse" id="footer-navbar-collapse">
<ul class="nav navbar-nav navbar-left">
{% if theme_source_link_position == "footer" %}
<li>
{% include "sourcelink.html" %}
</li>
{% endif %}
{% if theme_navbar_sidebarrel %}
<li>
{% include "relations.html" %}
</li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">
<i class="fa fa-chevron-up fa-fw"></i> <span class="hidden-sm hidden-xs">Back to top</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
{% endif %}
<div class="footer-text">
<p class="text-muted">
{%- if show_copyright %}
{%- if hasdoc('copyright') %}
{% trans path=pathto('copyright'), copyright=copyright|e %}&copy; <a href="{{ path }}">Copyright</a> {{ copyright }}.{% endtrans %}<br/>
{%- else %}
{% trans copyright=copyright|e %}&copy; Copyright {{ copyright }}.{% endtrans %}<br/>
{%- endif %}
{%- endif %}
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}<br/>
{%- endif %}
{%- if show_sphinx %}
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}<br/>
{%- endif %}
{%- endif %}
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}<br/>
{%- endif %}
{%- if show_sphinx %}
{% trans sphinx_version=sphinx_version|e %}Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version }}.{% endtrans %}<br/>
{%- endif %}
</p>
</div>
</footer>
Expand Down
5 changes: 0 additions & 5 deletions sphinx_bootstrap_theme/bootstrap/navbar-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
{% include "navbartoc.html" %}
{% endif %}
{% endblock %}
{% if theme_navbar_sidebarrel %}
{% block sidebarrel %}
{% include "relations.html" %}
{% endblock %}
{% endif %}
{% block navbarextra %}
{% endblock %}
{% if theme_source_link_position == "nav" %}
Expand Down
9 changes: 2 additions & 7 deletions sphinx_bootstrap_theme/bootstrap/navbar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="navbar" class="{{ theme_navbar_class }} navbar-default {% if theme_navbar_fixed_top == 'true' -%} navbar-fixed-top{%- endif -%}">
<div id="navbar" class="{{ theme_navbar_class }} navbar-default hidden-print {% if theme_navbar_fixed_top == 'true' -%} navbar-fixed-top{%- endif -%}">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
Expand All @@ -13,7 +13,7 @@
{%- endblock %}
{% if theme_navbar_title -%}{{ theme_navbar_title|e }}{%- else -%}{{ project|e }}{%- endif -%}
</a>
<span class="navbar-text navbar-version pull-left"><b>{{ version|e }}</b></span>
<p class="navbar-text navbar-version navbar-left"><strong>{{ version|e }}</strong></p>
</div>

<div class="collapse navbar-collapse nav-collapse">
Expand All @@ -30,11 +30,6 @@
{% include "navbartoc.html" %}
{% endif %}
{% endblock %}
{% if theme_navbar_sidebarrel %}
{% block sidebarrel %}
{% include "relations.html" %}
{% endblock %}
{% endif %}
{% block navbarextra %}
{% endblock %}
{% if theme_source_link_position == "nav" %}
Expand Down
8 changes: 4 additions & 4 deletions sphinx_bootstrap_theme/bootstrap/relations.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
{%- if prev %}
<li>
<a href="{{ prev.link|e }}" title="{{ _('Previous Chapter: ') + prev.title|striptags }}">
{%- if theme_bootstrap_version == "3" -%}<span class="glyphicon glyphicon-chevron-left visible-sm"></span>{%- endif -%}
<span class="hidden-sm">{{ "&laquo;"|safe }} {{ prev.title|striptags|truncate(length=16, killwords=True) }}</span>
<i class="fa fa-chevron-left fa-fw"></i>
<span class="hidden-xs">{{ prev.title|striptags|truncate(length=16, killwords=True) }}</span>
</a>
</li>
{%- endif %}
{%- if next %}
<li>
<a href="{{ next.link|e }}" title="{{ _('Next Chapter: ') + next.title|striptags }}">
{%- if theme_bootstrap_version == "3" -%}<span class="glyphicon glyphicon-chevron-right visible-sm"></span>{%- endif -%}
<span class="hidden-sm">{{ next.title|striptags|truncate(length=16, killwords=True) }} {{ "&raquo;"|safe }}</span>
<span class="hidden-xs">{{ next.title|striptags|truncate(length=16, killwords=True) }}</span>
<i class="fa fa-chevron-right fa-fw"></i>
</a>
</li>
{%- endif %}
4 changes: 3 additions & 1 deletion sphinx_bootstrap_theme/bootstrap/sourcelink.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{%- if show_source and has_source and sourcename %}
<div id="sourcelink">
<a href="{{ pathto('_sources/' + sourcename, true)|e }}"
rel="nofollow">{{ _('Source') }}</a>
rel="nofollow">
<i class="fa fa-code fa-fw"></i> <span class="hidden-sm hidden-xs">{{ _('Source') }}</span>
</a>
</div>
{%- endif %}
Loading