patched-codes / patchwork

Automate code reviews, patching and documentation with self-hosted LLM workflows.
https://patched.codes
GNU Affero General Public License v3.0
1.13k stars 72 forks source link

Support docstring for swift #949

Open codelion opened 1 month ago

patched-codes[bot] commented 1 week ago

Title: Support docstring for Swift

Technical Specifications and Requirements:

  1. Language Support: Extend the existing docstring generation functionality to support Swift programming language.
  2. Integration: Integrate Swift support into the current GenerateDocstring patchflow and related components.
  3. Syntax Compatibility: Ensure compatibility with Swift's syntax and documentation conventions.
  4. File Recognition: Update file extension recognition to include .swift files.
  5. Context Strategy: Implement a SwiftStrategy similar to existing language strategies (e.g., JavaStrategy, PythonStrategy).

Current Situation: The current codebase supports docstring generation for multiple languages, including Python, Java, JavaScript, C++, and Kotlin. However, Swift support is missing, which limits the tool's usefulness for iOS and macOS developers.

Potential Impact: Adding Swift support will:

  1. Expand the tool's user base to include iOS and macOS developers.
  2. Improve code documentation practices in Swift projects.
  3. Enhance the overall value proposition of our product.

Proposed Solution:

  1. Create a new SwiftStrategy class in the context_strategy module:

    • Implement methods for parsing Swift code structure (classes, methods, properties).
    • Define Swift-specific docstring format and conventions.
  2. Update the GenerateDocstring patchflow:

    • Add Swift language detection.
    • Integrate the new SwiftStrategy into the docstring generation process.
  3. Modify relevant utility functions:

    • Update file extension recognition to include .swift files.
    • Adjust any language-specific processing to accommodate Swift syntax.
  4. Implement Swift-specific docstring templates:

    • Create templates that follow Swift documentation best practices.
    • Ensure compatibility with tools like Xcode's Quick Help and jazzy documentation generator.
  5. Add test cases:

    • Create Swift code samples for testing.
    • Implement unit tests for SwiftStrategy and Swift docstring generation.

Action Items:

  1. Create a new SwiftStrategy class in patchwork/common/context_strategy/swift.py
  2. Update GenerateDocstring.py to include Swift language support
  3. Modify utility functions in relevant files (e.g., filter_paths.py) to recognize .swift files
  4. Create Swift docstring templates
  5. Add test cases in the tests/cicd/generate_docstring/ directory
  6. Update documentation to include information about Swift support
  7. Perform thorough testing with various Swift code samples
  8. Update the README.md to mention Swift support in the list of supported languages

Additional Considerations:

By implementing Swift support, we will significantly enhance our tool's capabilities and appeal to a broader range of developers, particularly those working in the Apple ecosystem.