Skip to content

Conversation

@leakec
Copy link
Contributor

@leakec leakec commented Dec 3, 2025

This PR implements #25. It modifies how docstrings are parsed/formatted so that the output for the parameters, return type, and exceptions comes out as a Google-style docstring. In addition, it contains a few other fixes:

  • Adds back MKD_DOC6, which seems to be missing
  • Fixes up uvx hatch fmt errors from to get CI working again
  • Uses thruth files to make updating expected values for unit tests easier.

@leakec
Copy link
Contributor Author

leakec commented Dec 3, 2025

Tagging @henryiii for review.

Noting also that the uvx hatch fmt issues fixed should also get the checks in #48 passing so that can be merged as well.

In addition to unit tests, I also ran this on a rather large codebase at work (which is where I found the missing MKD_DOC6) to ensure everything parsed correctly: did this to hopefully pick up any corner cases missed by the simpler unit tests.

@henryiii henryiii requested a review from Copilot December 3, 2025 22:00
Copilot finished reviewing on behalf of henryiii December 3, 2025 22:03
Copy link

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

This PR converts the docstring output format from a custom style to Google-style docstrings, implementing issue #25. The changes restructure how Doxygen-style comments (@param, @return, @throws, etc.) are parsed and reformatted into Google-style sections (Args:, Returns:, Raises:, etc.).

Key changes include:

  • Refactored docstring parsing to use regex patterns for extracting parameter, return, and exception documentation
  • Implemented new paragraph wrapping logic to properly handle indentation and list formatting
  • Added the missing MKD_DOC6 macro definition
  • Migrated tests to use truth files for easier maintenance of expected outputs

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pybind11_mkdoc/mkdoc_lib.py Core implementation of Google-style docstring formatting with new regex patterns and paragraph wrapping logic
tests/sample_header_test.py Refactored to use truth files and added test_generate_headers_2 for new test case
tests/sample_header_docs/sample_header_truth.h Truth file for sample_header test with MKD_DOC6 added and improved list formatting
tests/sample_header_docs/sample_header_2.h New test input file with comprehensive Doxygen-style comments
tests/sample_header_docs/sample_header_2_truth.h Expected output for sample_header_2 demonstrating Google-style formatting
tests/long_parameter_test.py Updated expected output to match new Google-style format (Args: instead of Parameter)
tests/cli_test.py Refactored to use truth file instead of inline string for expected output

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

Copy link
Collaborator

@henryiii henryiii left a comment

Choose a reason for hiding this comment

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

A couple of optional nitpicks. Format might have to be rerun if applied.

@leakec
Copy link
Contributor Author

leakec commented Dec 3, 2025

A couple of optional nitpicks. Format might have to be rerun if applied.

@henryiii These all look good to me. I've approved them, made some minor tweaks, and all checks are passing.

@henryiii henryiii merged commit eae336e into pybind:master Dec 4, 2025
8 checks passed
@leakec
Copy link
Contributor Author

leakec commented Dec 4, 2025

Thank you!

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.

2 participants