Skip to content

Commit c6c4240

Browse files
authored
Fix version information in doc selection (brucefan1983#438)
* Added parsing of version information when compiling documentation * Changed "latest stable release" to "latest release" * Cleaned up conf.py * Keep "v" in version
1 parent 5e38f8f commit c6c4240

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

doc/conf.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55
import sys
66
import re
77
import sphinx_rtd_theme
8+
import subprocess
89

910
project = 'GPUMD'
1011
author = 'The GPUMD developer team'
11-
version = ''
1212
copyright = '2023'
1313
site_url = 'https://gpumd.org'
1414

15+
process = subprocess.Popen(['git', 'tag'], stdout=subprocess.PIPE)
16+
stdout, _ = process.communicate()
17+
versions = [s for s in stdout.decode().split('\n') if len(s)]
18+
if len(versions) > 0:
19+
version = versions[-1]
20+
else:
21+
version = ''
22+
1523
extensions = [
1624
'sphinx_sitemap',
1725
'sphinx.ext.autodoc',
@@ -47,7 +55,7 @@
4755
html_context = {
4856
'current_version': version,
4957
'versions':
50-
[('latest stable release',
58+
[('latest release',
5159
'{}'.format(site_url)),
5260
('development version',
5361
'{}/dev'.format(site_url))]}

0 commit comments

Comments
 (0)