@@ -345,7 +345,9 @@ constant so that "Hon" can be parsed as a first name.
345345 :options: +ELLIPSIS, +NORMALIZE_WHITESPACE
346346
347347 >>> from nameparser import HumanName
348- >>> hn = HumanName(" Hon Solo" )
348+ >>> from nameparser.config import Constants
349+ >>> constants = Constants()
350+ >>> hn = HumanName(" Hon Solo" , constants = constants)
349351 >>> hn
350352 <HumanName : [
351353 title: 'Hon'
@@ -356,10 +358,9 @@ constant so that "Hon" can be parsed as a first name.
356358 nickname: ''
357359 maiden: ''
358360 ]>
359- >>> from nameparser.config import CONSTANTS
360- >>> CONSTANTS .titles.remove(' hon' )
361- SetManager({'right', ..., 'tax'})
362- >>> hn = HumanName(" Hon Solo" )
361+ >>> constants.titles.remove(' hon' )
362+ SetManager({'10th', ..., 'zoologist'})
363+ >>> hn = HumanName(" Hon Solo" , constants = constants)
363364 >>> hn
364365 <HumanName : [
365366 title: ''
@@ -374,7 +375,11 @@ constant so that "Hon" can be parsed as a first name.
374375
375376If you don't want to detect any titles at all, you can remove all of them:
376377
377- >>> CONSTANTS .titles.clear()
378+ .. doctest ::
379+ :options: +ELLIPSIS, +NORMALIZE_WHITESPACE
380+
381+ >>> constants.titles.clear()
382+ SetManager(set())
378383
379384
380385Adding a Title
@@ -399,7 +404,7 @@ making them lower case and removing periods.
399404 >>> from nameparser.config import Constants
400405 >>> constants = Constants()
401406 >>> constants.titles.add(' dean' , ' Chemistry' )
402- SetManager({'right ', ..., 'tax '})
407+ SetManager({'10th ', ..., 'zoologist '})
403408 >>> hn = HumanName(" Assoc Dean of Chemistry Robert Johns" , constants = constants)
404409 >>> hn
405410 <HumanName : [
@@ -427,7 +432,7 @@ the config on one instance could modify the behavior of another instance.
427432 >>> from nameparser import HumanName
428433 >>> instance = HumanName(" " )
429434 >>> instance.C.titles.add(' dean' )
430- SetManager({'right ', ..., 'tax '})
435+ SetManager({'10th ', ..., 'zoologist '})
431436 >>> other_instance = HumanName(" Dean Robert Johns" )
432437 >>> other_instance # Dean parses as title
433438 <HumanName : [
@@ -455,7 +460,7 @@ reference to the module-level config values with the behavior described above.
455460 >>> instance.has_own_config
456461 False
457462 >>> instance.C.titles.add(' dean' )
458- SetManager({'right ', ..., 'tax '})
463+ SetManager({'10th ', ..., 'zoologist '})
459464 >>> other_instance = HumanName(" Dean Robert Johns" , None ) # <-- pass None for per-instance config
460465 >>> other_instance
461466 <HumanName : [
@@ -483,8 +488,8 @@ You can turn this off by setting the ``emoji`` regex to ``False``.
483488 >>> constants = Constants()
484489 >>> constants.regexes.emoji = False
485490 >>> hn = HumanName(" Sam 😊 Smith" , constants = constants)
486- >>> hn
487- " Sam 😊 Smith"
491+ >>> str (hn)
492+ ' Sam 😊 Smith'
488493
489494Config Changes May Need Parse Refresh
490495~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -529,9 +534,9 @@ directly to the attribute.
529534 >>> hn = HumanName("Dr. John A. Kenneth Doe")
530535 >>> hn.title = ["Associate","Professor"]
531536 >>> hn.suffix = "Md."
532- >>> hn.suffix
537+ >>> hn
533538 <HumanName : [
534- title: 'Associate Processor '
539+ title: 'Associate Professor '
535540 first: 'John'
536541 middle: 'A. Kenneth'
537542 last: 'Doe'
0 commit comments