Skip to content

Commit

Permalink
Removes custom sphinx-rtd-theme uses rst-versions in the sidebar for …
Browse files Browse the repository at this point in the history
…versions
  • Loading branch information
jasonb5 committed Apr 11, 2024
1 parent adebed5 commit d03f00e
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 17 deletions.
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx
sphinxcontrib-programoutput
sphinx-rtd-theme
# git+https://github.com/esmci/sphinx_rtd_theme.git@version-dropdown-with-fixes
gitpython
evv4esm
3 changes: 0 additions & 3 deletions doc/source/_templates/layout.html

This file was deleted.

53 changes: 53 additions & 0 deletions doc/source/_templates/versions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% if READTHEDOCS or display_lower_left %}
{# Add rst-badge after rst-versions for small badge style. #}
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book"> Read the Docs</span>
v: {{ current_version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
{% if languages|length >= 1 %}
<dl>
<dt>{{ _('Languages') }}</dt>
{% for slug, url in languages %}
{% if slug == current_language %} <strong> {% endif %}
<dd><a href="{{ url }}">{{ slug }}</a></dd>
{% if slug == current_language %} </strong> {% endif %}
{% endfor %}
</dl>
{% endif %}
{% if versions|length >= 1 %}
<dl>
<dt>{{ _('Versions') }}</dt>
{% for slug, url in versions %}
{% if slug == current_version %} <strong> {% endif %}
<dd><a href="{{ url }}">{{ slug }}</a></dd>
{% if slug == current_version %} </strong> {% endif %}
{% endfor %}
</dl>
{% endif %}
{% if downloads|length >= 1 %}
<dl>
<dt>{{ _('Downloads') }}</dt>
{% for type, url in downloads %}
<dd><a href="{{ url }}">{{ type }}</a></dd>
{% endfor %}
</dl>
{% endif %}
{% if READTHEDOCS %}
<dl>
<dt>{{ _('On Read the Docs') }}</dt>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/projects/{{ slug }}/?fromdocs={{ slug }}">{{ _('Project Home') }}</a>
</dd>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/builds/{{ slug }}/?fromdocs={{ slug }}">{{ _('Builds') }}</a>
</dd>
</dl>
{% endif %}
<hr/>
{% trans %}Free document hosting provided by <a href="http://www.readthedocs.org">Read the Docs</a>.{% endtrans %}
</div>
</div>
{% endif %}
52 changes: 39 additions & 13 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,25 @@
master_doc = "index"

# General information about the project.
project = u"CIME"
copyright = u"2017, U.S. National Science Foundation and U.S. Department of Energy"
author = u"Staff of the NSF/CESM and DOE/E3SM projects"
project = "CIME"
copyright = "2017, U.S. National Science Foundation and U.S. Department of Energy"
author = "Staff of the NSF/CESM and DOE/E3SM projects"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u"master"
version = "master"
# The full version, including alpha/beta/rc tags.
release = u"master"
release = "master"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down Expand Up @@ -156,8 +156,8 @@
(
master_doc,
"on.tex",
u"on Documentation",
u"Staff of the NSF/CESM and DOE/E3SM projects",
"on Documentation",
"Staff of the NSF/CESM and DOE/E3SM projects",
"manual",
),
]
Expand All @@ -167,7 +167,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "on", u"on Documentation", [author], 1)]
man_pages = [(master_doc, "on", "on Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -179,7 +179,7 @@
(
master_doc,
"on",
u"on Documentation",
"on Documentation",
author,
"on",
"One line description of project.",
Expand All @@ -192,8 +192,34 @@
pdf_documents = [
(
master_doc,
u"CIME_Users_Guide",
u"CIME Users Guide (PDF)",
u"Staff of the NSF/CESM and DOE/E3SM projects",
"CIME_Users_Guide",
"CIME Users Guide (PDF)",
"Staff of the NSF/CESM and DOE/E3SM projects",
),
]

try:
html_context
except NameError:
html_context = dict()

html_context["display_lower_left"] = True

html_context["current_language"] = language

from git import Repo

repo = Repo(search_parent_directories=True)

current_version = repo.active_branch.name

html_context["current_version"] = current_version
html_context["version"] = current_version

html_context["versions"] = (
("master", "versions/master"),
("CESM2.2", "versions/cesm2.2"),
("CESM2.1 (cime5.6)", "versions/maint-5.6"),
("ufs_release_v1.1", "versions/ufs_release_v1.1"),
("ufs_release_v1.0", "versions/ufs_release_v1.0"),
)

0 comments on commit d03f00e

Please sign in to comment.