Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 18, 2025

This PR implements automatic parsing of the CMake project version for use in the documentation, eliminating the need to manually update version numbers in multiple places.

Changes Made

CMakeLists.txt

  • Consolidated the project() declaration from multi-line format to a single line to enable easier regex parsing
  • Added explanatory comment about the requirement for documentation parsing

docs/source/conf.py

  • Added import re for regex processing
  • Replaced hardcoded version string with automated parsing logic that reads the version from CMakeLists.txt
  • Uses regex pattern r'project\(.*VERSION\s+(\d+\.\d+\.\d+)' to extract version number
  • Maintains the same output format: v{version}{suffix}

Before

# The full version, including alpha/beta/rc tags
release = f'v0.12.0{suffix}'

After

# the suffix is required. This is controlled by the dockerfile that builds the docs
regex = r'project\(.*VERSION\s+(\d+\.\d+\.\d+)'
version = '0.0.0'
# read the version from the cmake files
with open(f'../../CMakeLists.txt', 'r') as f:
    for line in f:
        match = re.match(regex, line)
        if match:
            version = match.group(1)
release = f'v{version}{suffix}'

Benefits

  • Documentation version now automatically syncs with CMake project version
  • No more manual updates required when the version changes
  • Consistent versioning across build system and documentation
  • Follows the same approach used successfully in MICM (PR #581)

Testing

  • ✅ Version parsing extracts correct version (0.12.0) from CMakeLists.txt
  • ✅ Documentation builds successfully with Sphinx
  • ✅ Generated HTML displays correct version in title, switcher, and logo
  • ✅ Version automatically updates when CMakeLists.txt version changes
  • ✅ All validation tests pass

Fixes #127.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • ncar.github.io
    • Triggering command: python3 -m sphinx -b html source build (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Parse CMake version for use in the docs Parse CMake version automatically for documentation Jul 18, 2025
@Copilot Copilot AI requested a review from K20shores July 18, 2025 20:30
Copilot finished work on behalf of K20shores July 18, 2025 20:30
@K20shores K20shores requested a review from boulderdaze July 18, 2025 20:36
@K20shores K20shores marked this pull request as ready for review July 18, 2025 20:38
@K20shores K20shores merged commit abea45d into main Jul 18, 2025
18 checks passed
@K20shores K20shores deleted the copilot/fix-127 branch July 18, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse CMake version for use in the docs
3 participants