From cf18ec6cc6a491cc75c165884ccf360f2d75081f Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Fri, 14 May 2021 11:10:15 -0400 Subject: [PATCH] Add selection of Manual version --- .../_themes/lammps_theme/layout.html | 4 --- .../_themes/lammps_theme/versions.html | 16 ++++------- doc/utils/sphinx-config/conf.py.in | 27 +++++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/doc/utils/sphinx-config/_themes/lammps_theme/layout.html b/doc/utils/sphinx-config/_themes/lammps_theme/layout.html index 845f213a4c..1dad9ec4a9 100644 --- a/doc/utils/sphinx-config/_themes/lammps_theme/layout.html +++ b/doc/utils/sphinx-config/_themes/lammps_theme/layout.html @@ -138,10 +138,6 @@ {% if READTHEDOCS and current_version %} {%- set nav_version = current_version %} {% endif %} - {% if nav_version %} -
Version: {{ nav_version }}
-
git info: {{ release }}
- {% endif %} {% endif %} {% include "searchbox.html" %} diff --git a/doc/utils/sphinx-config/_themes/lammps_theme/versions.html b/doc/utils/sphinx-config/_themes/lammps_theme/versions.html index 7368659c43..f0ec4fea1a 100644 --- a/doc/utils/sphinx-config/_themes/lammps_theme/versions.html +++ b/doc/utils/sphinx-config/_themes/lammps_theme/versions.html @@ -1,9 +1,9 @@ -{% if READTHEDOCS %} +{% if READTHEDOCS or display_manual_versions %} {# Add rst-badge after rst-versions for small badge style. #}
- Read the Docs - v: {{ current_version }} + Version + {{ current_version }}
@@ -20,14 +20,8 @@ {% endfor %}
- {# Translators: The phrase "Read the Docs" is not translated #} -
{{ _('On Read the Docs') }}
-
- {{ _('Project Home') }} -
-
- {{ _('Builds') }} -
+
Git Info
+
{{ release }}
diff --git a/doc/utils/sphinx-config/conf.py.in b/doc/utils/sphinx-config/conf.py.in index 17cb3c2395..8d3c88e727 100644 --- a/doc/utils/sphinx-config/conf.py.in +++ b/doc/utils/sphinx-config/conf.py.in @@ -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')]