fix: indent Google-style summary lines in prepare_docstrings.py#3947
Closed
TaiSakuma wants to merge 2 commits into
Closed
fix: indent Google-style summary lines in prepare_docstrings.py#3947TaiSakuma wants to merge 2 commits into
TaiSakuma wants to merge 2 commits into
Conversation
Add summary line, Returns: section, and Examples: section with proper indentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a regex to dodoc() that indents Google-style summary lines (text before the first :param directive) so they sit inside the RST directive. Also add tests for dodoc() with and without summary. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3947 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
|
Member
Author
|
@ianna I opened altarnative PR with another solution: #3948. There is a new Sphinx extension from Read the Docs that solves the same problem as |
Member
Author
|
The alternative solution #3948 has been merged. |
13 tasks
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.
Summary
Sphinx supports Google-style docstrings via
sphinx.ext.napoleon. However,Awkward doesn't use it in the standard way. Because Awkward has compiled C++
extensions (
awkward-cpp), the docs can't import the package at build timeas
sphinx.ext.autodocrequires. Instead,docs/prepare_docstrings.pyparses source files with
astand callssphinx.ext.napoleon.GoogleDocstringdirectly, then applies regex-based transforms for cross-references, code
blocks, and directive indentation (see #187, #158).
This custom processor indents
:param,:type,:returns, and:raisesdirectives to sit inside the RST
.. py:function::block, but it did nothandle Google-style summary lines. Napoleon outputs summary text at column 0,
causing it to render outside the function directive in the built docs. This
is likely why summary lines have been absent from Awkward docstrings.
This PR adds a targeted regex to
dodoc()that indents only the summaryparagraph (non-whitespace text before the first
:paramdirective) by 4spaces. The regex is scoped narrowly to avoid affecting docstrings without
a summary line.
Tests
Two
dodoc()unit tests are added, following the existingtest_signature_*pattern:
test_dodoc_no_summary— verifies existing format is unchanged (noregression)
test_dodoc_with_summary— verifies the summary line is indentedFull document comparison
All RST files were regenerated with and without the fix and diffed. The only
difference across the entire generated documentation was the intended change:
the summary line in
ak.flatten.rstgaining 4-space indentation.This branch includes the commit from #3946 (
ak.flattendocstring update).Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com