@@ -26,18 +26,19 @@ class HumanName(object):
2626 """
2727 Parse a person's name into individual components.
2828
29+ Instantiation assigns to ``full_name``, and assignment to :py:attr:`full_name`
30+ triggers :py:func:`parse_full_name`. After parsing the name, these instance
31+ attributes are available.
32+
2933 **HumanName Instance Attributes**
3034
31- * o. title
32- * o. first
33- * o. middle
34- * o. last
35- * o. suffix
36- * o. nickname
35+ * :py:attr:` title`
36+ * :py:attr:` first`
37+ * :py:attr:` middle`
38+ * :py:attr:` last`
39+ * :py:attr:` suffix`
40+ * :py:attr:` nickname`
3741
38- Instantiation assigns to ``full_name``, and assignment to :py:attr:`full_name`
39- triggers :py:func:`parse_full_name`, where most of the action happens.
40-
4142 :param str full_name: The name string to be parsed.
4243 :param constants constants:
4344 a :py:class:`~nameparser.config.Constants` instance. Pass ``None`` for
@@ -144,26 +145,53 @@ def _dict(self):
144145
145146 @property
146147 def title (self ):
148+ """
149+ The person's titles. Any string of consecutive pieces in
150+ :py:mod:`~nameparser.config.titles` or :py:mod:`~nameparser.config.conjunctions`
151+ at the beginning of :py:attr:`full_name`.
152+ """
147153 return " " .join (self .title_list )
148154
149155 @property
150156 def first (self ):
157+ """
158+ The person's first name. The first name piece after any known
159+ :py:attr:`title` pieces parsed from :py:attr:`full_name`.
160+ """
151161 return " " .join (self .first_list )
152162
153163 @property
154164 def middle (self ):
165+ """
166+ The person's middle names. All name pieces after the first name and before
167+ the last name parsed from :py:attr:`full_name`.
168+ """
155169 return " " .join (self .middle_list )
156170
157171 @property
158172 def last (self ):
173+ """
174+ The person's last name. The last name piece parsed from
175+ :py:attr:`full_name`.
176+ """
159177 return " " .join (self .last_list )
160178
161179 @property
162180 def suffix (self ):
181+ """
182+ The persons's suffixes. Pieces at the end of the name that are found in
183+ :py:mod:`~nameparser.config.suffixes`, or pieces that are at the end
184+ of comma separated formats, e.g. "Lastname, Title Firstname Middle[,] Suffix
185+ [, Suffix]" parsed from :py:attr:`full_name`.
186+ """
163187 return ", " .join (self .suffix_list )
164188
165189 @property
166190 def nickname (self ):
191+ """
192+ The person's nicknames. Any text found inside of quotes (``""``) or
193+ parenthesis (``()``)
194+ """
167195 return " " .join (self .nickname_list )
168196
169197 ### setter methods
@@ -198,19 +226,19 @@ def nickname(self, value):
198226 ### Parse helpers
199227
200228 def is_title (self , value ):
201- """Is in the titles set"""
229+ """Is in the :py:data:`~nameparser.config. titles.TITLES` set. """
202230 return lc (value ) in self .C .titles
203231
204232 def is_conjunction (self , piece ):
205- """Is in the conjuctions set or :py:func:`is_an_initial()`"""
233+ """Is in the conjuctions set or :py:func:`is_an_initial()`. """
206234 return lc (piece ) in self .C .conjunctions and not self .is_an_initial (piece )
207235
208236 def is_prefix (self , piece ):
209- """Is in the prefixes set or :py:func:`is_an_initial()`"""
237+ """Is in the prefixes set or :py:func:`is_an_initial()`. """
210238 return lc (piece ) in self .C .prefixes and not self .is_an_initial (piece )
211239
212240 def is_suffix (self , piece ):
213- """Is in the suffixes set or :py:func:`is_an_initial()`"""
241+ """Is in the suffixes set or :py:func:`is_an_initial()`. """
214242 return lc (piece ) in self .C .suffixes and not self .is_an_initial (piece )
215243
216244 def is_rootname (self , piece ):
@@ -219,7 +247,10 @@ def is_rootname(self, piece):
219247 and not self .is_an_initial (piece )
220248
221249 def is_an_initial (self , value ):
222- """Matches the regular expression for initials."""
250+ """
251+ Matches the ``initial`` regular expression in
252+ :py:data:`~nameparser.config.regexes.REGEXES`.
253+ """
223254 return self .C .regexes .initial .match (value ) or False
224255
225256 # def is_a_roman_numeral(value):
@@ -230,6 +261,7 @@ def is_an_initial(self, value):
230261
231262 @property
232263 def full_name (self ):
264+ """The name string to be parsed."""
233265 return self ._full_name
234266
235267 @full_name .setter
@@ -242,15 +274,16 @@ def pre_process(self):
242274 """
243275 This method happens at the beginning of the :py:func:`parse_full_name` before
244276 any other processing of the string aside from unicode normalization, so
245- it's a good place to do any custom handling in a subclass.
277+ it's a good place to do any custom handling in a subclass.
278+ Runs :py:func:`parse_nicknames`.
246279 """
247280 self .parse_nicknames ()
248281
249282
250283 def post_process (self ):
251284 """
252285 This happens at the end of the :py:func:`parse_full_name` after
253- all other processing has taken place.
286+ all other processing has taken place. Runs :py:func:`handle_firstnames`.
254287 """
255288 self .handle_firstnames ()
256289
@@ -274,20 +307,19 @@ def handle_firstnames(self):
274307 a first name.
275308 """
276309 if self .title \
277- and len (self ) == 2 \
278- and not lc (self .title ) in self .C .first_name_titles :
310+ and len (self ) == 2 \
311+ and not lc (self .title ) in self .C .first_name_titles :
279312 self .last , self .first = self .first , self .last
280313
281314 def parse_full_name (self ):
282315 """
283316 The main parse method for the parser. This method is run upon assignment to the
284317 :py:attr:`full_name` attribute or instantiation.
285318
286- Basic flow is the hand off to :py:func:`pre_process` to handle nicknames, split
287- on commas to figure out which comma format to work with. :py:func:`parse_pieces`
288- splits on spaces and :py:func:`join_on_conjunctions` joins any pieces next to
289- conjunctions.
290- """
319+ Basic flow is the hand off to :py:func:`pre_process` to handle nicknames. It
320+ then splits on commas and chooses a code path depending on the number of commas.
321+ :py:func:`parse_pieces` then splits those parts on spaces and
322+ :py:func:`join_on_conjunctions` joins any pieces next to conjunctions. """
291323
292324 self .title_list = []
293325 self .first_list = []
@@ -406,6 +438,7 @@ def parse_pieces(self, parts, additional_parts_count=0):
406438 Split parts on spaces and remove commas, join on conjunctions and
407439 lastname prefixes.
408440
441+ :param list parts: name part strings from the comma split
409442 :param int additional_parts_count:
410443
411444 if the comma format contains other parts, we need to know
@@ -435,6 +468,8 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0):
435468 Join conjunctions to surrounding pieces, e.g.:
436469 ['Mr. and Mrs.'], ['King of the Hill'], ['Jack and Jill'], ['Velasquez y Garcia']
437470
471+ :param list pieces: name pieces strings after split on spaces
472+ :param int additional_parts_count:
438473 :return: new list with piece next to conjunctions merged into one piece with spaces in it.
439474 :rtype: list
440475
0 commit comments