Skip to content

Suggest documentation updates during review#139

Open
subhajitlucky wants to merge 1 commit into
zigcBenx:masterfrom
subhajitlucky:docs-suggestion-on-review-87
Open

Suggest documentation updates during review#139
subhajitlucky wants to merge 1 commit into
zigcBenx:masterfrom
subhajitlucky:docs-suggestion-on-review-87

Conversation

@subhajitlucky
Copy link
Copy Markdown

Summary

  • Add a second AI pass during review to detect documentation impact from the diff.
  • Post documentation suggestions to the merge request when user-facing behavior, setup, configuration, commands, or workflow changes should be documented.
  • Add unit tests for documentation suggestion formatting and OpenAI request wiring.
  • Document the new review behavior in the README.

Fixes #87

Verification

  • python3 -m unittest discover -s tests -v
  • python3 -m py_compile ai_code_review.py gitHappens.py
  • git diff --check HEAD~1..HEAD

Copilot AI review requested due to automatic review settings May 12, 2026 06:39
Copy link
Copy Markdown

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

Adds a second AI pass during gh review to detect documentation impact from the diff and (when applicable) post documentation update suggestions to the merge request.

Changes:

  • Added a documentation-focused OpenAI prompt + request path, plus formatting/display helpers for documentation suggestions.
  • Wired the new documentation pass into both terminal review and MR review flows.
  • Added unit tests for documentation comment formatting and OpenAI request wiring; updated README to describe the new behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ai_code_review.py Adds documentation-impact prompt, OpenAI call, formatting helpers, and MR/terminal integration.
tests/test_ai_code_review.py Adds unit tests covering documentation suggestion formatting and request message contents.
README.md Documents the new review behavior (docs-impact detection and suggestion posting).
Comments suppressed due to low confidence (1)

ai_code_review.py:454

  • run_review_for_mr returns early when diff refs can't be fetched, which prevents posting the documentation suggestions comment even though it doesn't depend on diff refs. This also means you still pay for the documentation OpenAI call but never surface the result. Consider posting the documentation comment before this early return (or moving the diff-refs check before calling suggest_documentation_updates).
    documentation_results = suggest_documentation_updates(diff_content)

    # Get diff refs for inline comments
    diff_refs = get_diff_refs(project_id, mr_id, gitlab_token, api_url)
    if not diff_refs or not all(diff_refs.values()):
        print(f"{Colors.HIGH}⚠ Could not get diff refs, posting summary only{Colors.RESET}")
        comment = format_gitlab_comment(results)
        post_to_merge_request(comment, project_id, mr_id, gitlab_token, api_url)
        return

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ai_code_review.py
Comment on lines +271 to +274
def format_documentation_comment(results):
"""Format documentation suggestions as a GitLab markdown comment."""
if not results or not results.get('needed') or not results.get('suggestions'):
return None
@subhajitlucky subhajitlucky force-pushed the docs-suggestion-on-review-87 branch from 8033669 to 023fe8f Compare May 12, 2026 06:45
@subhajitlucky
Copy link
Copy Markdown
Author

Updated to handle the missing diff-refs path from the Copilot note: documentation suggestions are now posted even when inline review comments cannot be positioned.\n\nFresh verification:\n- python3 -m unittest discover -s tests -v (4 tests)\n- python3 -m py_compile ai_code_review.py gitHappens.py\n- git diff --check HEAD~1..HEAD

@subhajitlucky subhajitlucky force-pushed the docs-suggestion-on-review-87 branch from 023fe8f to 4b8d965 Compare May 12, 2026 06:55
@subhajitlucky
Copy link
Copy Markdown
Author

Handled the latest review edge case in format_documentation_comment: when the documentation pass returns needed: true with an empty suggestions list, the formatter now still posts the summary plus a generic documentation follow-up instead of dropping the comment. Added a regression test for that path.\n\nVerification run after the update:\n- python3 -m unittest discover -s tests -v\n- python3 -m py_compile ai_code_review.py gitHappens.py\n- git diff --check

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.

On Review generate suggestion for documentation about the diff

2 participants