Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
push:
branches: [master]
branches: [master, dev]
pull_request_target:
branches: [master]
branches: [master, dev]

jobs:
test:
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:

report:
name: Report Coverage
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: test
steps:
Expand All @@ -77,3 +78,22 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage-artifacts/
fail_ci_if_error: false

check-version:
name: Check for accidental version bump
if: github.base_ref == 'dev'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Verify that version was not bumped
run: |
if ! git diff --quiet origin/dev HEAD -- pyproject.toml; then
echo "::error::Version in pyproject.toml was changed in a PR to dev."
echo "Version bumping should only happen in a release PR to master."
exit 1
fi
echo "Version check passed for pyproject.toml"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
/git_diff.txt
git_diff.txt
temporary/

# PyInstaller
# Usually these files are written by a small stub bootstrap script and should be
Expand Down
335 changes: 176 additions & 159 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion agent_docstrings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
Attributes:
__version__ (str): Current version of the *agent-docstrings* package.
"""
__version__ = "1.3.0"
__version__ = "1.3.1"
29 changes: 23 additions & 6 deletions agent_docstrings/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def process_file(path: Path, verbose: bool = False, beta: bool = False) -> None:
idx += 1
# Check for manual docstring start
if idx < len(body_lines) and body_lines[idx].strip().startswith(('"""', "'''")):
delim = body_lines[idx].strip()
delim_line = body_lines[idx].strip()
# Ensure it's not an existing auto-generated docstring
marker_present = False
for i in range(idx, min(idx + 5, len(body_lines))):
Expand All @@ -422,12 +422,29 @@ def process_file(path: Path, verbose: bool = False, beta: bool = False) -> None:
if not marker_present:
# Find end of manual docstring
end_idx = None
for j in range(idx + 1, len(body_lines)):
if body_lines[j].strip() == delim:
end_idx = j
break
manual_inner = []
delim = None

delim_quotes = '"""' if delim_line.startswith('"""') else "'''"
is_single_line = delim_line.endswith(delim_quotes) and delim_line != delim_quotes

if is_single_line:
end_idx = idx
content_part = delim_line[len(delim_quotes):-len(delim_quotes)]
if content_part:
manual_inner = [content_part]
delim = delim_quotes
else:
# Multi-line docstring
delim = delim_line
for j in range(idx + 1, len(body_lines)):
if body_lines[j].strip() == delim:
end_idx = j
break
if end_idx is not None:
manual_inner = body_lines[idx + 1:end_idx]

if end_idx is not None:
manual_inner = body_lines[idx + 1:end_idx]
# Compute auto header content lines with correct offset for merge
# temp_header_lines holds the auto header lines including delimiters
# content_lines length is temp_header_lines minus start/end markers
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "agent-docstrings"
version = "1.3.0"
version = "1.3.1"
description = "A command-line tool to auto-generate and update file-level docstrings summarizing classes and functions. Useful for maintaining a high-level overview of your files, especially in projects with code generated or modified by AI assistants."
readme = { file = "README.md", content-type = "text/markdown" }
license = { file = "LICENSE" }
Expand Down Expand Up @@ -148,7 +148,7 @@ exclude_lines = [
]

[tool.bumpversion]
current_version = "1.3.0"
current_version = "1.3.1"
commit = false
tag = false

Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/python_with_manual_docstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""This is a manual docstring.
It has multiple lines.
The generator should not break it.
"""

class MyClass:
"""A simple example class."""
def my_method(self, arg1: int) -> str:
"""A simple example method."""
return f"Hello {arg1}"
Loading