Skip to content

feat: add Attributes section support and configurable docstring style#33

Merged
zzstoatzz merged 1 commit intomainfrom
fix/docstring-attributes-and-style
Dec 18, 2025
Merged

feat: add Attributes section support and configurable docstring style#33
zzstoatzz merged 1 commit intomainfrom
fix/docstring-attributes-and-style

Conversation

@zzstoatzz
Copy link
Copy Markdown
Owner

Summary

Changes

Issue #32 - Attributes section not rendered

Added handler for attributes section kind in format_docstring_with_griffe(). Attributes are now rendered identically to how Args:, Returns:, and Raises: sections are rendered:

**Attributes:**
- `name`: The name of the column.
- `type`: The data type of the column.

Issue #31 - Docstring style configurability

Added --docstring-style CLI option with three choices:

  • google (default) - Google-style docstrings
  • numpy - NumPy-style docstrings
  • sphinx - Sphinx-style docstrings

Example usage:

mdxify mymodule --docstring-style numpy

Test plan

  • Reproduced Attributes section in class docstrings are not rendered #32 bug empirically with stack_data library (has Google-style Attributes in class docstrings)
  • Verified fix works on real library
  • Tested --docstring-style option with numpy-style docstrings
  • Added 6 new unit tests for both features
  • All 69 tests pass

🤖 Generated with Claude Code

Fixes #32: The `Attributes:` section in Google-style class docstrings is now
properly rendered in the generated MDX output, matching the behavior of
`Args:`, `Returns:`, and `Raises:` sections.

Addresses #31: Added `--docstring-style` CLI option to configure the docstring
parsing style. Supports "google" (default), "numpy", and "sphinx" styles.

Changes:
- Add handler for `attributes` section kind in `format_docstring_with_griffe()`
- Add `style` parameter to `format_docstring_with_griffe()` (defaults to "google")
- Add `docstring_style` parameter to `generate_mdx()` function
- Add `--docstring-style` CLI argument with choices: google, numpy, sphinx
- Add comprehensive unit tests for both features

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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

This PR adds support for rendering Attributes: sections in Google-style class docstrings and introduces a configurable --docstring-style CLI option to support multiple docstring formats (Google, NumPy, and Sphinx).

  • Added handler for attributes section in the Griffe-based docstring formatter
  • Introduced --docstring-style CLI argument with validation for three supported styles
  • Added comprehensive test coverage with 6 new unit tests

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/mdxify/formatter.py Added style parameter to format_docstring_with_griffe() function and implemented attributes section handler with colon escaping
src/mdxify/generator.py Added docstring_style parameter to generate_mdx() and propagated it to all format_docstring_with_griffe() calls for functions, classes, and methods
src/mdxify/cli.py Added --docstring-style CLI argument with choices validation and ensured parameter is passed through both serial and parallel processing paths
tests/test_formatter.py Added 6 comprehensive tests covering attributes section rendering, multiple docstring styles (Google, NumPy, Sphinx), and default behavior

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

@zzstoatzz zzstoatzz merged commit 4430f91 into main Dec 18, 2025
14 checks passed
@zzstoatzz zzstoatzz deleted the fix/docstring-attributes-and-style branch December 18, 2025 15:21
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.

Attributes section in class docstrings are not rendered

2 participants