Skip to content

Conversation

@chris-tallman
Copy link

@chris-tallman chris-tallman commented Oct 1, 2025

Change Summary

I wanted to see paragraph sections with custom titles like "Example:" or "Tip:", but the parser was ignoring Doxygen's optional paragraph title.

Sample usage

Paragraph without title (pre-existing functionality)

/*!
 * @par
 * Lorem ipsum dolor sit amet consectetur adipiscing elit.
 */

Paragraph with title

/*!
 * @par Tip:
 * Lorem ipsum dolor sit amet consectetur adipiscing elit.
 */

Summary by Sourcery

New Features:

  • Render user-defined paragraph titles for Doxygen @Par sections instead of always using default headings.

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 1, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Introduces parsing of optional paragraph titles for Doxygen’s @Par by detecting a <title> element and rendering its text as the section header while preserving the existing label fallback.

Sequence diagram for parsing @Par with optional title

sequenceDiagram
    participant "xml_parser.paras()"
    participant "Element <simplesect>"
    participant "Element <title>"
    participant "MdBold"
    participant "Text"
    "xml_parser.paras()"->>"Element <simplesect>": check for <title>
    alt title exists and has text
        "xml_parser.paras()"->>"Element <title>": get title text
        "xml_parser.paras()"->>"MdBold": create bold section header with title
    else kind in SIMPLE_SECTIONS
        "xml_parser.paras()"->>"MdBold": create bold section header with fallback label
        "xml_parser.paras()"->>"Text": get label from SIMPLE_SECTIONS
    end
Loading

File-Level Changes

Change Details Files
Add support for custom paragraph titles in Doxygen @Par sections
  • Detect and extract <title> element from simplesect nodes
  • Render extracted title text as bold markdown with surrounding line breaks
  • Retain fallback to SIMPLE_SECTIONS labels when no title is present
  • Maintain existing spacing logic for 'see' and other kinds
mkdoxy/xml_parser.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `mkdoxy/xml_parser.py:251-255` </location>
<code_context>
                 kind = item.get("kind")
-                ret.extend((Br(), MdBold([Text(SIMPLE_SECTIONS[kind])])))
+                title = item.find("title")
+                if title is not None and title.text:
+                    ret.extend((Br(), MdBold(self.paras(title)), Br()))
+                elif kind in SIMPLE_SECTIONS:
+                    ret.extend((Br(), MdBold([Text(SIMPLE_SECTIONS[kind])])))
</code_context>

<issue_to_address>
**suggestion:** Check for empty or whitespace-only title text.

The current logic does not handle titles that contain only whitespace. Use title.text.strip() to check for non-empty titles before rendering.

```suggestion
                title = item.find("title")
                if title is not None and title.text and title.text.strip():
                    ret.extend((Br(), MdBold(self.paras(title)), Br()))
                elif kind in SIMPLE_SECTIONS:
                    ret.extend((Br(), MdBold([Text(SIMPLE_SECTIONS[kind])])))
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chris-tallman
Copy link
Author

Related to #86

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