Add selection of Manual version

This commit is contained in:
Richard Berger
2021-05-14 11:10:15 -04:00
parent e5cc4409a5
commit cf18ec6cc6
3 changed files with 32 additions and 15 deletions

View File

@ -138,10 +138,6 @@
{% if READTHEDOCS and current_version %}
{%- set nav_version = current_version %}
{% endif %}
{% if nav_version %}
<div class="lammps_version">Version: <b>{{ nav_version }}</b></div>
<div class="lammps_release">git info: {{ release }}</div>
{% endif %}
{% endif %}
{% include "searchbox.html" %}

View File

@ -1,9 +1,9 @@
{% if READTHEDOCS %}
{% if READTHEDOCS or display_manual_versions %}
{# 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-book"> Version</span>
{{ current_version }}
<span class="fa fa-caret-down"></span>
</span>
<div class="rst-other-versions">
@ -20,14 +20,8 @@
{% endfor %}
</dl>
<dl>
{# Translators: The phrase "Read the Docs" is not translated #}
<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>
<dt>Git Info</dt>
<dd><a href="https://github.com/lammps/lammps/tree/{{ git_commit }}" target="_blank">{{ release }}</a></dd>
</dl>
</div>
</div>

View File

@ -99,6 +99,16 @@ def get_git_info():
pass
return git_n_date
def get_git_commit():
import subprocess,time
try:
commit = subprocess.run(['git','rev-parse','HEAD'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
if commit.returncode == 0:
return commit.stdout.decode()
except:
pass
return ''
# 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.
@ -108,6 +118,8 @@ version = get_lammps_version()
# The full version, including alpha/beta/rc tags.
release = get_git_info()
git_commit = get_git_commit()
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
@ -389,3 +401,18 @@ breathe_domain_by_extension = { 'h' : 'cpp',
'cpp' : 'cpp',
'c' : 'c',
}
# allows showing multiple versions
try:
html_context
except NameError:
html_context = dict()
html_context['display_manual_versions'] = True
html_context['current_version'] = version
html_context['git_commit'] = git_commit
html_context['versions'] = [
('latest', 'https://docs.lammps.org/'),
('8 Apr 2021', 'https://lammps.sandia.gov/doc/')
]
html_context['downloads'] = [('PDF', 'Manual.pdf')]