Skip to content

Conversation

jhd3197
Copy link
Owner

@jhd3197 jhd3197 commented Oct 1, 2025

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.

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.
@Copilot Copilot AI review requested due to automatic review settings October 1, 2025 00:51
Copy link

@Copilot Copilot AI left a 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

Comment on lines +78 to +83
# 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
Copy link

Copilot AI Oct 1, 2025

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.

Suggested change
# 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.

Comment on lines +145 to +177
# 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)
Copy link

Copilot AI Oct 1, 2025

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.

Suggested change
# 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.

Comment on lines +152 to +154
# Update line 20 (index 19)
if len(lines) >= 20:
line_idx = 19 # Line 20 is at index 19
Copy link

Copilot AI Oct 1, 2025

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.
@jhd3197 jhd3197 merged commit 7050487 into main Oct 12, 2025
1 check passed
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.

1 participant