-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add docs version update script and workflow changes #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a Python script to dynamically update the Sphinx documentation version from multiple sources. Updates the documentation workflow to run this script and deploy from the 'dev' branch. Enhances README with badges and detailed field definitions usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces automated documentation version management and enhances the project's visibility. The main purpose is to create a system that dynamically updates Sphinx documentation versions from multiple sources and improves the project's presentation with badges and comprehensive field definitions documentation.
Key changes:
- Adds automated version detection and updating for Sphinx documentation
- Updates documentation workflow to deploy from 'dev' branch instead of 'main'
- Enhances README with project badges and detailed field definitions usage examples
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
README.md | Adds project status badges and comprehensive field definitions documentation with examples |
.github/workflows/documentation.yml | Updates workflow to run on 'dev' branch and includes version update script |
.github/scripts/update_docs_version.py | New Python script for dynamic version detection and Sphinx documentation updating |
# Look for version = "X.X.X" pattern | ||
match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', content) | ||
if match: | ||
version = match.group(1) | ||
print(f"✓ Found version in pyproject.toml: {version}") | ||
return version |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex pattern for extracting version from pyproject.toml is too generic and may match unintended version fields (e.g., dependencies). Consider making it more specific by looking for version within the [project] section to avoid false matches.
# Look for version = "X.X.X" pattern | |
match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', content) | |
if match: | |
version = match.group(1) | |
print(f"✓ Found version in pyproject.toml: {version}") | |
return version | |
# Extract the [project] section only | |
project_section_match = re.search(r'^\[project\](.*?)(^\[|\Z)', content, re.DOTALL | re.MULTILINE) | |
if project_section_match: | |
project_section = project_section_match.group(1) | |
# Look for version = "X.X.X" pattern within [project] section | |
match = re.search(r'version\s*=\s*["\']([^"\']+)["\']', project_section) | |
if match: | |
version = match.group(1) | |
print(f"✓ Found version in pyproject.toml [project] section: {version}") | |
return version |
Copilot uses AI. Check for mistakes.
# Pattern to match the version line (line 20, 0-indexed as 19) | ||
pattern = re.compile( | ||
r'^(\s*Prompture is currently in development \(version )' | ||
r'[^)]+' | ||
r'(\)\. APIs may change between versions\.\s*)$' | ||
) | ||
|
||
# Update line 20 (index 19) | ||
if len(lines) >= 20: | ||
line_idx = 19 # Line 20 is at index 19 | ||
original_line = lines[line_idx] | ||
|
||
# Check if the line matches the expected pattern | ||
if pattern.match(original_line): | ||
# Replace with new version | ||
new_line = pattern.sub( | ||
rf'\g<1>{version}\g<2>', | ||
original_line | ||
) | ||
lines[line_idx] = new_line | ||
|
||
# Write back to file | ||
index_file.write_text(''.join(lines), encoding='utf-8') | ||
print(f"✓ Updated version in {index_file}") | ||
print(f" Old: {original_line.strip()}") | ||
print(f" New: {new_line.strip()}") | ||
return True | ||
else: | ||
print(f"✗ Line 20 does not match expected pattern", file=sys.stderr) | ||
print(f" Found: {original_line.strip()}", file=sys.stderr) | ||
return False | ||
else: | ||
print(f"✗ File has fewer than 20 lines", file=sys.stderr) |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-coding line number 20 (index 19) makes the script fragile to changes in the documentation structure. Consider searching for the pattern throughout the file instead of relying on a specific line number.
# Pattern to match the version line (line 20, 0-indexed as 19) | |
pattern = re.compile( | |
r'^(\s*Prompture is currently in development \(version )' | |
r'[^)]+' | |
r'(\)\. APIs may change between versions\.\s*)$' | |
) | |
# Update line 20 (index 19) | |
if len(lines) >= 20: | |
line_idx = 19 # Line 20 is at index 19 | |
original_line = lines[line_idx] | |
# Check if the line matches the expected pattern | |
if pattern.match(original_line): | |
# Replace with new version | |
new_line = pattern.sub( | |
rf'\g<1>{version}\g<2>', | |
original_line | |
) | |
lines[line_idx] = new_line | |
# Write back to file | |
index_file.write_text(''.join(lines), encoding='utf-8') | |
print(f"✓ Updated version in {index_file}") | |
print(f" Old: {original_line.strip()}") | |
print(f" New: {new_line.strip()}") | |
return True | |
else: | |
print(f"✗ Line 20 does not match expected pattern", file=sys.stderr) | |
print(f" Found: {original_line.strip()}", file=sys.stderr) | |
return False | |
else: | |
print(f"✗ File has fewer than 20 lines", file=sys.stderr) | |
# Pattern to match the version line | |
pattern = re.compile( | |
r'^(\s*Prompture is currently in development \(version )' | |
r'[^)]+' | |
r'(\)\. APIs may change between versions\.\s*)$' | |
) | |
# Search for the version line by pattern | |
found = False | |
for idx, line in enumerate(lines): | |
if pattern.match(line): | |
new_line = pattern.sub( | |
rf'\g<1>{version}\g<2>', | |
line | |
) | |
lines[idx] = new_line | |
found = True | |
print(f"✓ Updated version in {index_file}") | |
print(f" Old: {line.strip()}") | |
print(f" New: {new_line.strip()}") | |
break | |
if found: | |
# Write back to file | |
index_file.write_text(''.join(lines), encoding='utf-8') | |
return True | |
else: | |
print(f"✗ No line matching the expected version pattern found", file=sys.stderr) |
Copilot uses AI. Check for mistakes.
# Update line 20 (index 19) | ||
if len(lines) >= 20: | ||
line_idx = 19 # Line 20 is at index 19 |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 19/20 is repeated multiple times without a named constant. Consider defining LINE_INDEX = 19 at the module level to improve maintainability and make the intent clearer.
Copilot uses AI. Check for mistakes.
Introduces test_version_diagnosis.py to diagnose version detection methods. Updates docs/requirements.txt to include setuptools_scm for version management. Removes the VERSION file and sets fetch-depth to 0 in documentation workflow for full git history.
Removed setuptools_scm from docs/requirements.txt and added a VERSION file with version 0.0.29.dev1. Also simplified the documentation workflow by removing fetch-depth from the checkout step.
Deleted unnecessary whitespace from the documentation.yml GitHub Actions workflow for improved readability.
Introduces enum field definitions for sentiment, priority, status, and risk_level. Adds `validate_enum_value` and `normalize_enum_value` utilities for enum validation and normalization. Updates `field_from_registry` to handle enum fields and enhance schema metadata. Refactors text analysis example to demonstrate enum usage and adds a test script for enum implementation.
Introduces a new example script demonstrating text classification using enum fields for tone and topic. Adds a 'tone' field definition to BASE_FIELD_DEFINITIONS with allowed values and metadata for improved LLM output consistency.
Changed the GitHub Actions workflow to trigger on pushes to the 'main' branch instead of 'dev', and updated the deployment condition accordingly. This aligns documentation deployment with the primary branch.
Introduces a Python script to dynamically update the Sphinx documentation version from multiple sources. Updates the documentation workflow to run this script and deploy from the 'dev' branch. Enhances README with badges and detailed field definitions usage.