Skip to content

Commit c93b95f

Browse files
committed
update docs
1 parent 2ba0dda commit c93b95f

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ build
1111
.env
1212
.env3
1313
.coverage
14+
dist
1415

1516
# docs
1617
docs/_*

README.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Name Parser
66
.. image:: https://badge.fury.io/py/nameparser.svg
77
:target: http://badge.fury.io/py/nameparser
88

9-
A simple Python module for parsing human names into their individual
9+
A simple Python (3.2+ & 2.6+) module for parsing human names into their individual
1010
components. The HumanName class splits a name string up into name parts
1111
based on placement in the string and matches against known name pieces
1212
like titles. It joins name pieces on conjunctions and special prefixes to
@@ -19,7 +19,8 @@ Unicode is supported, but the parser is not likely to be useful for languages
1919
that to not share the same structure as English names. It's not perfect, but it
2020
gets you pretty far.
2121

22-
**Quick Start Example**
22+
Quick Start Example
23+
-------------------
2324

2425
::
2526

@@ -35,9 +36,12 @@ gets you pretty far.
3536
nickname: 'Doc Vega'
3637
]>
3738
>>> name.last
38-
u'de la Vega'
39+
'de la Vega'
3940
>>> name.as_dict()
40-
{u'last': u'de la Vega', u'suffix': u'III', u'title': u'Dr.', u'middle': u'Q. Xavier', u'nickname': u'Doc Vega', u'first': u'Juan'}
41+
{'last': 'de la Vega', 'suffix': 'III', 'title': 'Dr.', 'middle': 'Q. Xavier', 'nickname': 'Doc Vega', 'first': 'Juan'}
42+
>>> name.string_format = "{first} {last}"
43+
>>> str(name)
44+
'Juan de la Vega'
4145

4246

4347
3 different comma placement variations are supported for the string that you pass.
@@ -46,9 +50,10 @@ gets you pretty far.
4650
* Lastname [Suffix], Title Firstname (Nickname) Middle Middle[,] Suffix [, Suffix]
4751
* Title Firstname M Lastname [Suffix], Suffix [Suffix] [, Suffix]
4852

49-
The parser does not make any attempt to clean the data that you provide. It mostly just puts
50-
things in buckets based on their position between the white spaces in the string. This also means
51-
the difference between 'title' and 'suffix' is positional, not semantic.
53+
The parser does not make any attempt to clean the data. It mostly just splits on white
54+
space and puts things in buckets based on their position in the string. This also means
55+
the difference between 'title' and 'suffix' is positional, not semantic. ("Pre-nominal"
56+
and "post-nominal" would probably be better names.)
5257

5358
::
5459

@@ -63,19 +68,19 @@ the difference between 'title' and 'suffix' is positional, not semantic.
6368
nickname: ''
6469
]>
6570

71+
Customization
72+
-------------
73+
6674
Your project may need a bit of adjustments for your dataset. You can
6775
do this in your own pre- or post-processing, by `customizing the configured pre-defined
6876
sets`_ of titles, prefixes, etc., or by subclassing the `HumanName` class. See the
6977
`full documentation`_ for more information.
7078

71-
.. _customizing the configured pre-defined sets: http://nameparser.readthedocs.org/en/latest/customize.html
72-
.. _full documentation: http://nameparser.readthedocs.org/en/latest/
73-
74-
Documentation
75-
-------------
7679

7780
`Full documentation`_
81+
~~~~~~~~~~~~~~~~~~~~~
7882

83+
.. _customizing the configured pre-defined sets: http://nameparser.readthedocs.org/en/latest/customize.html
7984
.. _Full documentation: http://nameparser.readthedocs.org/en/latest/
8085

8186

docs/usage.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,19 @@ available from the nickname attribute. (Added in v0.2.9)
117117
String Format
118118
-------------
119119

120-
The format of the strings returned with ``unicode()`` can be adjusted
120+
The format of the strings returned with ``str()`` or ``unicode()`` can be adjusted
121121
using standard python string formatting. The string's ``format()``
122122
method will be passed a dictionary of names.
123123

124124
.. doctest:: string format
125125

126126
>>> name = HumanName("Rev John A. Kenneth Doe III")
127-
>>> unicode(name)
128-
u'Rev John A. Kenneth Doe III'
127+
>>> str(name)
128+
'Rev John A. Kenneth Doe III'
129129
>>> name.string_format = "{last}, {title} {first} {middle}, {suffix}"
130-
>>> unicode(name)
131-
u'Doe, Rev John A. Kenneth, III'
130+
>>> str(name)
131+
'Doe, Rev John A. Kenneth, III'
132+
>>> name.string_format = "{first} {last}"
133+
>>> str(name)
134+
'John Doe'
132135

0 commit comments

Comments
 (0)