From 3e44fd3593b3731b211d6bbe049a33e8b9e068ac Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 20 May 2022 14:54:37 -0400 Subject: [PATCH] ENH: Add pydata-sphinx-theme. Add example download link. Remove unused templates from old theme. --- Formatting/conf.py.in | 68 ++--------------- Formatting/templates/globaltoc.html | 10 --- Formatting/templates/layout.html | 3 + Formatting/templates/navbartoc.html | 11 --- Formatting/templates/page.html | 35 +++++++++ Formatting/templates/relations.html | 73 ------------------- Superbuild/External-Python.cmake | 2 +- .../SphinxExtensions/pydata-sphinx-theme | 1 - 8 files changed, 44 insertions(+), 159 deletions(-) delete mode 100644 Formatting/templates/globaltoc.html delete mode 100644 Formatting/templates/navbartoc.html create mode 100644 Formatting/templates/page.html delete mode 100644 Formatting/templates/relations.html delete mode 160000 Utilities/SphinxExtensions/pydata-sphinx-theme diff --git a/Formatting/conf.py.in b/Formatting/conf.py.in index 2db8708a1..e5064b6bb 100644 --- a/Formatting/conf.py.in +++ b/Formatting/conf.py.in @@ -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 ----------------------------------------------------- @@ -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
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 # " v documentation". html_title = project + ' v' + release diff --git a/Formatting/templates/globaltoc.html b/Formatting/templates/globaltoc.html deleted file mode 100644 index 6c21a34f3..000000000 --- a/Formatting/templates/globaltoc.html +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/Formatting/templates/layout.html b/Formatting/templates/layout.html index bbe145199..792c54a0f 100644 --- a/Formatting/templates/layout.html +++ b/Formatting/templates/layout.html @@ -37,4 +37,7 @@ sphinx_version|e }}, and CMake.
+ + {% endblock %} diff --git a/Formatting/templates/navbartoc.html b/Formatting/templates/navbartoc.html deleted file mode 100644 index e54703f75..000000000 --- a/Formatting/templates/navbartoc.html +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/Formatting/templates/page.html b/Formatting/templates/page.html new file mode 100644 index 000000000..bc3fc8566 --- /dev/null +++ b/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 %} +

+ + + +

+ {%- endif %} + {{ body }} +{% endblock %} \ No newline at end of file diff --git a/Formatting/templates/relations.html b/Formatting/templates/relations.html deleted file mode 100644 index c87f26861..000000000 --- a/Formatting/templates/relations.html +++ /dev/null @@ -1,73 +0,0 @@ -{# 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)%} - -{%- if prev %} - {%- if slashcount == 4 %} -
  • - - {%- if theme_bootstrap_version == "2" -%}{%- endif -%} - {%- if theme_bootstrap_version == "3" -%}{%- endif -%} - - -
  • - {%- else %} -
  • - - {%- if theme_bootstrap_version == "2" -%}{%- endif -%} - {%- if theme_bootstrap_version == "3" -%}{%- endif -%} - - -
  • - {%- endif %} -{%- endif %} -{%- if next %} - {%- if slashcount == 4 %} -
  • - - {%- if theme_bootstrap_version == "2" -%}{%- endif -%} - {%- if theme_bootstrap_version == "3" -%}{%- endif -%} - - -
  • - {%- else %} -
  • - - {%- if theme_bootstrap_version == "2" -%}{%- endif -%} - {%- if theme_bootstrap_version == "3" -%}{%- endif -%} - - - {%- endif %} -{%- endif %} - - -{%- if slashcount == 4 %} -
  • -{%- endif %} - - - diff --git a/Superbuild/External-Python.cmake b/Superbuild/External-Python.cmake index d07269de5..ffd0f1c99 100644 --- a/Superbuild/External-Python.cmake +++ b/Superbuild/External-Python.cmake @@ -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 ) diff --git a/Utilities/SphinxExtensions/pydata-sphinx-theme b/Utilities/SphinxExtensions/pydata-sphinx-theme deleted file mode 160000 index b806673af..000000000 --- a/Utilities/SphinxExtensions/pydata-sphinx-theme +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b806673afbcc5e13a68d2a28b1dde92c8729cbd7