Skip to content

Commit

Permalink
ENH: Add pydata-sphinx-theme. Add example download link.
Browse files Browse the repository at this point in the history
Remove unused templates from old theme.
  • Loading branch information
PaulHax committed May 23, 2022
1 parent 7f48a1c commit 3e44fd3
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 159 deletions.
68 changes: 5 additions & 63 deletions Formatting/conf.py.in
Expand Up @@ -24,12 +24,10 @@ sys.path.insert(0, os.path.abspath(os.path.join('@ITKSphinxExamples_BINARY_DIR@'
'Utilities', 'SphinxExtensions', 'sphinxcontrib')))
sys.path.insert(0, os.path.abspath(os.path.join('@ITKSphinxExamples_BINARY_DIR@',
'Utilities', 'SphinxExtensions')))
sys.path.insert(0, os.path.abspath(os.path.join('@ITKSphinxExamples_BINARY_DIR@',
'Utilities', 'SphinxExtensions', 'sphinx-bootstrap-theme')))
sys.path.insert(0, os.path.abspath(os.path.join('@ITKSphinxExamples_BINARY_DIR@',
'Utilities', 'SphinxExtensions', 'breathelink')))

import sphinx_bootstrap_theme
import pydata_sphinx_theme

# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -133,78 +131,22 @@ html_favicon = os.path.join('static', 'itk_favicon.ico')

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'bootstrap'
html_theme = 'pydata_sphinx_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.

html_theme_options = {
'navbar_title': "",

# Tab name for entire site. (Default: "Site")
'navbar_site_name': "Site",

# A list of tuples containing pages or urls to link to.
# Valid tuples should be in the following forms:
# (name, page) # a link to a page
# (name, "/aa/bb", 1) # a link to an arbitrary relative url
# (name, "https://example.com", True) # arbitrary absolute url
# Note the "1" or "True" value above as the third argument to indicate
# an arbitrary url.
'navbar_links': [
# ("ITK", "https://itk.org", True),
# ("Examples", "src/index"),
"external_links": [
{"name": "ITK", "url": "https://itk.org"},
],

# Render the next and previous page links in navbar. (Default: true)
'navbar_sidebarrel': True,

# Render the current pages TOC in the navbar. (Default: true)
'navbar_pagenav': True,

# Tab name for the current pages TOC. (Default: "Page")
'navbar_pagenav_name': "Page",

# Global TOC depth for "site" navbar tab. (Default: 1)
# Switching to -1 shows all levels.
'globaltoc_depth': 2,

# Include hidden TOCs in Site navbar?
#
# Note: If this is "false", you cannot have mixed ``:hidden:`` and
# non-hidden ``toctree`` directives in the same page, or else the build
# will break.
#
# Values: "true" (default) or "false"
'globaltoc_includehidden': "true",

# HTML navbar class (Default: "navbar") to attach to <div> element.
# For black navbar, do "navbar navbar-inverse"
'navbar_class': "navbar navbar-inverse",

# Fix navigation bar to top of page?
# Values: "true" (default) or "false"
'navbar_fixed_top': "true",

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

# Bootswatch (https://bootswatch.com/) theme.
#
# Options are nothing (default) or the name of a valid theme
# such as "amelia" or "cosmo".
'bootswatch_theme': "cerulean",

# Choose Bootstrap version.
# Values: "3" (default) or "2" (in quotes)
'bootstrap_version': "3",
'show_nav_level': 2,
}

# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = project + ' v' + release
Expand Down
10 changes: 0 additions & 10 deletions Formatting/templates/globaltoc.html

This file was deleted.

3 changes: 3 additions & 0 deletions Formatting/templates/layout.html
Expand Up @@ -37,4 +37,7 @@
sphinx_version|e }},
and <a href="https://cmake.org/">CMake</a>.
</div>

<canvas id="testCanvas" width="8" height="8" hidden>
</canvas>
{% endblock %}
11 changes: 0 additions & 11 deletions Formatting/templates/navbartoc.html

This file was deleted.

35 changes: 35 additions & 0 deletions Formatting/templates/page.html
@@ -0,0 +1,35 @@
{% extends "layout.html" %}

{# emit a * for every slash so they can be counted #}
{%- macro countslashes(str) %}
{%- set slashcount = 0 %}
{%- for char in str %}
{%- if char == '/' -%}
*
{%- endif %}
{%- endfor -%}
{%- endmacro %}
{%- set slashcount = countslashes(pagename)|length %}

{%- macro examplename(str) %}
{%- set slashcount = 0 %}
{%- for char in str %}
{%- if char == '/' -%}
{%- set slashcount = slashcount + 1 %}
{%- else %}
{%- if slashcount > 2 and slashcount < 4 %}{{ char }}{%- endif %}
{%- endif %}
{%- endfor -%}
{%- endmacro %}
{%- set archivename = examplename(pagename)%}

{% block body %}
{%- if slashcount == 4 %}
<p>
<a href="{{ meta.get("name") ~ ".zip" }}">
<i class="fas fa-download"></i> <span class="hidden-sm hidden-tablet">&nbsp; {{ _('Download this example') }}</span>
</a>
</p>
{%- endif %}
{{ body }}
{% endblock %}
73 changes: 0 additions & 73 deletions Formatting/templates/relations.html

This file was deleted.

2 changes: 1 addition & 1 deletion Superbuild/External-Python.cmake
Expand Up @@ -17,6 +17,6 @@ ExternalProject_Add(ITKPython
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ${PYTHON_EXECUTABLE} -m venv "${_itk_venv}"
BUILD_COMMAND ${ITKPYTHON_EXECUTABLE} -m pip install --upgrade pip
INSTALL_COMMAND ${ITKPYTHON_EXECUTABLE} -m pip install --ignore-installed itk>=5.3rc4 sphinx==4.4.0 docutils<0.18 six black nbsphinx ipython sphinx-contributors ipykernel matplotlib itkwidgets
INSTALL_COMMAND ${ITKPYTHON_EXECUTABLE} -m pip install --ignore-installed itk>=5.3rc4 sphinx==4.4.0 docutils<0.18 six black nbsphinx ipython sphinx-contributors ipykernel matplotlib itkwidgets pydata-sphinx-theme
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/ITKBlackConfig.cmake
)
1 change: 0 additions & 1 deletion Utilities/SphinxExtensions/pydata-sphinx-theme
Submodule pydata-sphinx-theme deleted from b80667

0 comments on commit 3e44fd3

Please sign in to comment.