Skip to content

Fix /n literal#19

Merged
Artemonim merged 5 commits intodevfrom
fix/n-literal
Jul 9, 2025
Merged

Fix /n literal#19
Artemonim merged 5 commits intodevfrom
fix/n-literal

Conversation

@Artemonim
Copy link
Owner

Added

  • Placeholder-Based Line Numbering: Implemented a new placeholder system (OFFSET_PLACEHOLDER) for calculating line numbers in generated headers. This ensures deterministic line numbering by first generating headers with placeholders, then calculating the actual offset based on the final header size, and finally replacing placeholders with accurate line numbers.

Fixed

  • Deterministic Line Numbering: Completely reworked the line number calculation algorithm to ensure consistent and accurate line numbers across multiple runs. The new approach uses a two-pass system that measures rather than guesses header sizes, ensuring deterministic results.
  • Docstring Merging Logic: Improved the logic for merging manual docstrings with auto-generated content. Manual content is now properly preserved and formatted without adding unnecessary newlines or reformatting.
  • Multi-Pass Docstring Removal: Enhanced the remove_agent_docstring function to handle complex scenarios where multiple agent-generated docstrings might be present, preventing duplication issues on repeated runs.
  • Whitespace Normalization: Added proper whitespace handling in content comparison to prevent unnecessary file modifications when only minor whitespace differences exist.
  • Manual Content Extraction: Improved the extraction of manual docstring content by properly handling the inner content within triple quotes, preserving original formatting and indentation.

Testing

  • New Test Cases: Added comprehensive test cases for placeholder usage, short manual docstring handling, and merged multiline docstring preservation to ensure the new algorithms work correctly across various scenarios.

Type of Change

  • 🐛 Bug Fix: A change that fixes an issue.
  • New Feature: A change that adds new functionality.
  • ♻️ Refactor: A code change that neither fixes a bug nor adds a feature.
  • 📚 Documentation: Changes to the documentation only.
  • ⚙️ CI/CD: Changes to our CI/CD configuration and scripts.
  • 🔨 Build: Changes that affect the build system or external dependencies.
  • 🎨 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • Revert: Reverts a previous commit.

Checklist

  • My changes follows the Contribution Guide.
  • I have updated CHANGELOG.md under the [NextRelease] section.
  • New unit tests have been added to cover the changes.
  • Manual testing has been performed to verify the changes.

Artemonim added 5 commits July 9, 2025 07:46
- Enhanced the logic for handling manual docstrings to prevent extra newlines during processing.
- Added a new test to ensure that short manual Python docstrings are merged correctly without adding extra newlines and remain unchanged on subsequent runs.
- Updated the logic for generating headers to include placeholders for line numbers, ensuring deterministic output across different runs.
- Improved the handling of manual docstrings to prevent splitting during subsequent processing.
- Added tests to verify the correct usage of placeholders in headers and to ensure merged multi-line docstrings remain intact.
- Adjusted line numbers in auto-generated docstrings for consistency across different runs.
- Enhanced the normalization process to ignore minor whitespace differences when checking for version changes.
- Updated tests to ensure only one docstring block remains after processing and that version changes do not trigger unnecessary file modifications.
…nual content handling

- Updated line numbers in the auto-generated docstrings for consistency with the actual function definitions.
- Enhanced the handling of manual content to strip leading newlines, preventing double empty lines in the output.
- Ensured that the formatting of manual content remains intact during processing.
@Artemonim Artemonim merged commit 7a02cd2 into dev Jul 9, 2025
10 checks passed
@Artemonim Artemonim deleted the fix/n-literal branch July 9, 2025 08:53
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