Open
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds support for rendering Doxygen parameter direction tags (in, out, inout) into the generated markdown by prefixing parameter descriptions with a formatted direction label. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- You access
name.attribbefore checking thatnameis notNone, so ifparameteritem.find("parameternamelist").find("parametername")returnsNonethis will raise an exception; consider moving thedirectionhandling below the existingif name is not Noneguard. - The special-casing of only the
"inout"direction while directly echoing any otherdirectionattribute value could surface unexpected tags; if the valid values are known, consider validating or normalizing them (e.g., mapping onlyin,out, andinout) rather than blindly interpolating.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- You access `name.attrib` before checking that `name` is not `None`, so if `parameteritem.find("parameternamelist").find("parametername")` returns `None` this will raise an exception; consider moving the `direction` handling below the existing `if name is not None` guard.
- The special-casing of only the `"inout"` direction while directly echoing any other `direction` attribute value could surface unexpected tags; if the valid values are known, consider validating or normalizing them (e.g., mapping only `in`, `out`, and `inout`) rather than blindly interpolating.
## Individual Comments
### Comment 1
<location> `mkdoxy/xml_parser.py:240` </location>
<code_context>
name = parameteritem.find("parameternamelist").find("parametername")
description = parameteritem.find("parameterdescription").findall("para")
par = MdParagraph([])
+ if "direction" in name.attrib:
+ if name.attrib["direction"] == "inout":
+ par.append(Text("[in/out] "))
</code_context>
<issue_to_address>
**issue:** Guard against `name` being `None` before accessing `.attrib` to avoid potential runtime errors.
The new logic uses `name.attrib` before the `if name is not None` check. If `parameteritem.find("parameternamelist").find("parametername")` returns `None`, this will raise an `AttributeError`. Consider moving the `direction` handling inside the existing `if name is not None` block, or explicitly guarding it:
```python
if name is not None and "direction" in name.attrib:
if name.attrib["direction"] == "inout":
par.append(Text("[in/out] "))
else:
par.append(Text(f"[{name.attrib['direction']}] "))
```
This preserves the behavior while avoiding crashes on malformed or unexpected XML.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for parameter direction tags (in, out, and in,out). This closes out issue #78.
Summary by Sourcery
New Features: