Skip to content

Commit abea45d

Browse files
CopilotK20shores
andauthored
Parse CMake version automatically for documentation (#139)
* Initial plan * Implement automatic CMake version parsing for documentation Co-authored-by: K20shores <[email protected]> * Parse CMake version automatically for documentation Co-authored-by: K20shores <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: K20shores <[email protected]>
1 parent 1e8c99b commit abea45d

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33

44
cmake_minimum_required(VERSION 3.17)
55

6-
project(
7-
tuv-x
8-
VERSION 0.12.0
9-
LANGUAGES Fortran CXX C
10-
)
6+
# project and version must be on the same line so that the docs can extract it
7+
project(tuv-x VERSION 0.12.0 LANGUAGES Fortran CXX C)
118

129
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
1310
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")

docs/source/_static/favicon.ico

-1 Bytes
Binary file not shown.

docs/source/_static/logo.svg

Lines changed: 7 additions & 7 deletions
Loading

docs/source/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import sys
1515
import datetime
16+
import re
1617
sys.path.insert(0, os.path.abspath('.'))
1718

1819
from generate_logo import make_logo
@@ -25,8 +26,16 @@
2526

2627
suffix = os.getenv("SWITCHER_SUFFIX", "")
2728

28-
# The full version, including alpha/beta/rc tags
29-
release = f'v0.12.0{suffix}'
29+
# the suffix is required. This is controlled by the dockerfile that builds the docs
30+
regex = r'project\(.*VERSION\s+(\d+\.\d+\.\d+)'
31+
version = '0.0.0'
32+
# read the version from the cmake files
33+
with open(f'../../CMakeLists.txt', 'r') as f:
34+
for line in f:
35+
match = re.match(regex, line)
36+
if match:
37+
version = match.group(1)
38+
release = f'v{version}{suffix}'
3039

3140

3241
# -- General configuration ---------------------------------------------------

0 commit comments

Comments
 (0)