Skip to content

Match Google and Numpydoc section titles in any case - #177

Merged
rr- merged 1 commit into
mainfrom
rework/36-title-case
Nov 6, 2026
Merged

rr- merged 1 commit into
mainfrom
rework/36-title-case

Conversation

@rr-

@rr- rr- commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Google and Numpydoc now match section titles in any case, as Sphinx napoleon does. ARGS:, returns:, RaIsEs: and an underlined PARAMETERS start their sections instead of staying in the long description. This also applies to custom SectionSpec titles. If two declared titles differ only in case, the first one declared wins.

In Google, a title written in a different case from its declaration only starts a section at the top of the docstring or after a blank line. Without that rule, three stdlib docstrings broke: prose wrapped as For / example:, or provided / arguments:, turned into a section. A title written exactly as declared works the same as before.

Case diffs

  • numpydoc/unknown_heading_02, corpus/numpy/...can_cast and corpus/numpy/...tril_indices: an underlined See also used to be an unknown heading, a text meta with title: 'See also'. It is now the See Also section, so the title is gone and compose writes See Also. The parse reads back the same. I reworded the case comment in unknown_heading_02 to match.
  • New: google/title_case_01, google/title_case_02 (prose before a lowercase title stays prose) and numpydoc/title_case_01.

test_no_text_is_dropped now compares title words without regard to case. Both exclusion lists are unchanged.

Parity against origin/main

origin differ
case 5 of 1543 (the five files above)
stdlib 1 of 7631
generated 0 of 20000

The stdlib one is _strptime.LocaleTime, which has an indented ATTRIBUTES: after a blank line followed by name -- text items. The Google parser now reads it as an attributes section, and since the items have no colon it raises ParseError. Before, the whole thing went to the long description. Auto-detection still picks the same style for it.

tools/parity.py itself crashes with a KeyError when printing an input that parses in the base but not in the tree, so I got these counts from a small script that calls its outputs().

Bench

Python 3.8, every ratio between 0.98 and 1.03.

Section titles matched only as declared, so "ARGS:", "returns:" or an
underlined "PARAMETERS" stayed in the long description. Napoleon reads
titles in any case, and so do both styles now. Where two declared
titles differ only in case, the first declared wins.

In Google, a title written in another case than declared starts a
section only at the top or after a blank line, so that prose wrapped
as "For" and "example:" on the next line stays prose.

The text invariant now ignores title words in any case.
@rr- rr- self-assigned this Nov 6, 2026
@rr-
rr- merged commit 3c5ce4a into main Nov 6, 2026
26 checks passed
@rr-
rr- deleted the rework/36-title-case branch November 6, 2026 23:51
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