Skip to content

Commit 4dd99c1

Browse files
derek73claude
andcommitted
docs: name the customize sections after the reader's problem
v1's customize.rst used task-shaped headings — "Removing a Title", "Don't Remove Emojis", "Bound First Names" — so a reader scanning for their problem found it. The 2.0 rewrite named its three sections after the architecture instead (Vocabulary / Behavior / Presentation), which teaches the model better but leaves nothing to scan: the word "emoji" appeared nowhere outside a table cell, and the Policy section ran 150 lines without a subheading. Keep the three architectural sections and add task-shaped subheadings under them, so the page works for both reading and lookup. All eight terms a reader would search for (emoji, title, order, suffix, nickname, maiden, case, lexicon) now appear in a heading. Also fixes a seam left by the previous commit: the original maiden/nickname precedence paragraph had ended up orphaned after the strip-flag examples, several screens below the doctest it explains, and its closing sentence duplicated the additive-delimiter example added alongside it. Moved back to introduce its own example, duplicate dropped. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b20059b commit 4dd99c1

1 file changed

Lines changed: 35 additions & 9 deletions

File tree

docs/customize.rst

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ why the split is drawn there.
1111
Vocabulary: Lexicon
1212
--------------------
1313

14+
Adding and removing words
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
1417
.. doctest::
1518

1619
>>> from nameparser import Lexicon, Parser
@@ -40,8 +43,12 @@ appear in the base field too, so add to both and remove from the marker
4043
first; anything else raises ``ValueError`` naming the orphans rather
4144
than leaving a marker entry that no rule will ever consult.
4245

43-
That matters most when clearing a field wholesale. Emptying ``titles``
44-
alone orphans every ``given_name_titles`` entry, so both go together:
46+
Turning title detection off
47+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
48+
49+
The subset rule matters most when clearing a field wholesale. Emptying
50+
``titles`` alone orphans every ``given_name_titles`` entry, so the two
51+
go together:
4552

4653
.. doctest::
4754

@@ -64,6 +71,9 @@ ranks and abbreviations work (see :ref:`abbreviated-titles`):
6471
>>> bare.parse("Dr. John Smith").title # structural, stays
6572
'Dr.'
6673

74+
Combining two lexicons
75+
~~~~~~~~~~~~~~~~~~~~~~~
76+
6777
Whole lexicons compose with ``|``, which unions field by field — handy
6878
for keeping a shared house vocabulary separate from a per-source one
6979
and combining them at parser construction:
@@ -75,6 +85,9 @@ and combining them at parser construction:
7585
>>> sorted((house | per_source).titles)
7686
['dean', 'provost']
7787

88+
Fixing the case of a particular word
89+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
90+
7891
``capitalization_exceptions`` is the one pair-valued field — each entry
7992
maps a lowercase key to its exact-cased replacement (``"phd"`` →
8093
``"PhD"``), so it isn't a fit for ``add()``/``remove()``. Change it with
@@ -104,6 +117,9 @@ not against the raw text, so one ``"phd"`` entry covers ``"phd"``,
104117
``"Phd"``, and ``"Ph.D."`` alike — you don't need a separate key for
105118
each way a source might punctuate it.
106119

120+
Words that are also ordinary names
121+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122+
107123
Two fields — ``suffix_acronyms_ambiguous`` and ``particles_ambiguous``
108124
— mark entries from ``suffix_acronyms`` and ``particles`` that are also
109125
plausible as ordinary name words on their own (an acronym suffix that
@@ -244,6 +260,9 @@ listed below.
244260
- Excludes bidirectional control characters the same way.
245261
Defaults to ``True``.
246262

263+
Family-first name order
264+
~~~~~~~~~~~~~~~~~~~~~~~~
265+
247266
``name_order`` is the one most likely to matter for non-Western data.
248267
Positional input is assigned in the order you declare, so a
249268
family-first name parses as written instead of needing to be
@@ -268,6 +287,14 @@ family-then-given regardless of the configured order:
268287
>>> family_first.parse("Thomas, John").family
269288
'Thomas'
270289

290+
Nicknames, maiden names, and brackets
291+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
292+
293+
A delimiter pair routes to exactly one field, and ``maiden_delimiters``
294+
states the more specific intent — so listing a pair there drops it from
295+
the effective ``nickname_delimiters`` set automatically, and the
296+
one-liner is the whole recipe:
297+
271298
.. doctest::
272299

273300
>>> policy = Policy(maiden_delimiters={("(", ")")})
@@ -288,6 +315,9 @@ instead of extending them, the same trap as ``capitalization_exceptions``:
288315
>>> Parser(policy=policy).parse("Benjamin {Ben} Franklin").nickname
289316
'Ben'
290317

318+
Suffixes not separated by commas
319+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
320+
291321
``extra_suffix_delimiters`` handles sources that separate post-nominals
292322
with something other than a comma. The default reading of such a name
293323
is bad enough to be the reason you'd go looking:
@@ -302,6 +332,9 @@ is bad enough to be the reason you'd go looking:
302332
>>> name.given, name.family, name.suffix
303333
('Jane', 'Smith', 'RN, CRNA')
304334

335+
Keeping emoji and control characters
336+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337+
305338
The strip flags keep characters the parser removes by default. Note
306339
what happens to an emoji you keep — it becomes a token like any other,
307340
and lands in the middle name:
@@ -318,13 +351,6 @@ and lands in the middle name:
318351
characters, which is occasionally what you want when round-tripping
319352
right-to-left text verbatim.
320353

321-
A pair routes to exactly one field, and ``maiden_delimiters`` states
322-
the specific intent — so listing a pair there automatically drops it
323-
from the effective ``nickname_delimiters`` set, and the one-liner
324-
above is the whole recipe. To *add* delimiters instead of rerouting
325-
them, build on the named default:
326-
``nickname_delimiters=DEFAULT_NICKNAME_DELIMITERS | {("[", "]")}``.
327-
328354
.. _rendering-arguments:
329355

330356
Presentation: rendering arguments

0 commit comments

Comments
 (0)