Skip to content

Commit

Permalink
refc: Restructured the output format
Browse files Browse the repository at this point in the history
  • Loading branch information
sauravpanda committed Apr 2, 2024
1 parent dbbd178 commit cab9e76
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions codecheck/helpers/output.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@

COLLAPSIBLE_TEMPLATE = '''
<details>
<summary>{comment}</summary>
### Reason
{reasoning}
### Confidence
{confidence}
</details>
'''

def json_to_markdown(data):
markdown_output = "## Code Review Feedback\n\n"

for category, comments in data["review"].items():
markdown_output += f"### {category}\n\n"
for comment in comments:
markdown_output += f"- {comment}\n"
if type(comments) == dict:
COLLAPSIBLE_TEMPLATE.format(
comment=comments.get("comment", "NA"),
reasoning=comments.get("reasoning", "NA"),
confidence=comments.get("confidence", "NA"),
)
else:
for comment in comments:
markdown_output += f"- {comment}\n"
markdown_output += "\n"

# Print the markdown output
Expand Down

0 comments on commit cab9e76

Please sign in to comment.