Skip to content

Commit 57cea07

Browse files
committed
Refactored the docs for the models and records
1 parent ab428c7 commit 57cea07

File tree

2 files changed

+462
-132
lines changed

2 files changed

+462
-132
lines changed

geoip2/models.py

Lines changed: 211 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,47 @@ class Country(object):
2020
This class provides the following methods, each of which returns a record
2121
object.
2222
23-
:ivar continent: :py:class:`geoip2.records.Continent` object
24-
representing continent data for the requested IP address.
25-
:ivar country: :py:class:`geoip2.records.Country` object representing
26-
country data for the requested IP address. This record represents the
23+
.. attribute:: continent
24+
25+
Continent object for the requested IP address.
26+
27+
:type: :py:class:`geoip2.records.Continent`
28+
29+
.. attribute:: country
30+
31+
Country object for the requested IP address. This record represents the
2732
country where MaxMind believes the IP is located.
28-
:ivar maxmind: :py:class:`geoip2.records.MaxMind` object with
29-
information related to your MaxMind account.
30-
:ivar registered_country: :py:class:`geoip2.records.Country` object
31-
representing the registered country data for the requested IP address.
32-
This record represents the country where the ISP has registered a given
33-
IP block in and may differ from the user's country.
34-
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
35-
object containing details about the country represented by the users
36-
of the IP address when that country is different than the country in
37-
``country``. For instance, the country represented by an
38-
overseas military base or embassy.
39-
:ivar traits: :py:class:`geoip2.records.Traits` object representing
40-
the traits for the requested IP address.
33+
34+
:type: :py:class:`geoip2.records.Country`
35+
36+
.. attribute:: maxmind
37+
38+
Information related to your MaxMind account.
39+
40+
:type: :py:class:`geoip2.records.MaxMind`
41+
42+
.. attribute:: registered_country
43+
44+
The registered country object for the requested IP address. This record
45+
represents the country where the ISP has registered a given IP block in
46+
and may differ from the user's country.
47+
48+
:type: :py:class:`geoip2.records.Country`
49+
50+
.. attribute:: represented_country
51+
52+
Object for the country represented by the users of the IP address
53+
when that country is different than the country in ``country``. For
54+
instance, the country represented by an overseas military base or
55+
embassy.
56+
57+
:type: :py:class:`geoip2.records.RepresentedCountry`
58+
59+
.. attribute:: traits
60+
61+
Object with the traits of the requested IP address.
62+
63+
:type: :py:class:`geoip2.records.Traits`
4164
4265
"""
4366
def __init__(self, raw_response, languages=None):
@@ -68,30 +91,64 @@ def __init__(self, raw_response, languages=None):
6891
class City(Country):
6992
"""Model class for the GeoIP2 Precision City end point
7093
71-
:ivar city: :py:class:`geoip2.records.City` object representing
72-
country data for the requested IP address.
73-
:ivar continent: :py:class:`geoip2.records.Continent` object
74-
representing continent data for the requested IP address.
75-
:ivar country: :py:class:`geoip2.records.Country` object representing
76-
country data for the requested IP address. This record represents the
94+
.. attribute:: city
95+
96+
City object for the requested IP address.
97+
98+
:type: :py:class:`geoip2.records.City`
99+
100+
.. attribute:: continent
101+
102+
Continent object for the requested IP address.
103+
104+
:type: :py:class:`geoip2.records.Continent`
105+
106+
.. attribute:: country
107+
108+
Country object for the requested IP address. This record represents the
77109
country where MaxMind believes the IP is located.
78-
:ivar location: :py:class:`geoip2.records.Location` object
79-
representing country data for the requested IP address.
80-
:ivar maxmind: :py:class:`geoip2.records.MaxMind` object with
81-
information related to your MaxMind account.
82-
:ivar subdivisions: :py:class:`geoip2.records.Subdivisions` object representing
83-
country subdivisions for the requested IP address.
84-
:ivar registered_country: :py:class:`geoip2.records.Country` object
85-
representing the registered country data for the requested IP address.
86-
This record represents the country where the ISP has registered a given
87-
IP block in and may differ from the user's country.
88-
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
89-
object containing details about the country represented by the users
90-
of the IP address when that country is different than the country in
91-
``country``. For instance, the country represented by an
92-
overseas military base or embassy.
93-
:ivar traits: :py:class:`geoip2.records.Traits` object representing
94-
the traits for the requested IP address.
110+
111+
:type: :py:class:`geoip2.records.Country`
112+
113+
.. attribute:: location
114+
115+
Location object for the requested IP address.
116+
117+
.. attribute:: maxmind
118+
119+
Information related to your MaxMind account.
120+
121+
:type: :py:class:`geoip2.records.MaxMind`
122+
123+
.. attribute:: registered_country
124+
125+
The registered country object for the requested IP address. This record
126+
represents the country where the ISP has registered a given IP block in
127+
and may differ from the user's country.
128+
129+
:type: :py:class:`geoip2.records.Country`
130+
131+
.. attribute:: represented_country
132+
133+
Object for the country represented by the users of the IP address
134+
when that country is different than the country in ``country``. For
135+
instance, the country represented by an overseas military base or
136+
embassy.
137+
138+
:type: :py:class:`geoip2.records.RepresentedCountry`
139+
140+
.. attribute:: subdivisions
141+
142+
Object (tuple) representing the subdivisions of the country to which
143+
the location of the requested IP address belongs.
144+
145+
:type: :py:class:`geoip2.records.Subdivisions`
146+
147+
.. attribute:: traits
148+
149+
Object with the traits of the requested IP address.
150+
151+
:type: :py:class:`geoip2.records.Traits`
95152
96153
"""
97154
def __init__(self, raw_response, languages=None):
@@ -110,60 +167,128 @@ def __init__(self, raw_response, languages=None):
110167
class CityISPOrg(City):
111168
"""Model class for the GeoIP2 Precision City/ISP/Org end point
112169
113-
:ivar city: :py:class:`geoip2.records.City` object representing
114-
country data for the requested IP address.
115-
:ivar continent: :py:class:`geoip2.records.Continent` object
116-
representing continent data for the requested IP address.
117-
:ivar country: :py:class:`geoip2.records.Country` object representing
118-
country data for the requested IP address. This record represents the
170+
.. attribute:: city
171+
172+
City object for the requested IP address.
173+
174+
:type: :py:class:`geoip2.records.City`
175+
176+
.. attribute:: continent
177+
178+
Continent object for the requested IP address.
179+
180+
:type: :py:class:`geoip2.records.Continent`
181+
182+
.. attribute:: country
183+
184+
Country object for the requested IP address. This record represents the
119185
country where MaxMind believes the IP is located.
120-
:ivar location: :py:class:`geoip2.records.Location` object
121-
representing country data for the requested IP address.
122-
:ivar maxmind: :py:class:`geoip2.records.MaxMind` object with
123-
information related to your MaxMind account.
124-
:ivar subdivisions: :py:class:`geoip2.records.Subdivisions` object representing
125-
country subdivisions for the requested IP address.
126-
:ivar registered_country: :py:class`geoip2.records.Country` object
127-
representing the registered country data for the requested IP address.
128-
This record represents the country where the ISP has registered a given
129-
IP block in and may differ from the user's country.
130-
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
131-
object containing details about the country represented by the users
132-
of the IP address when that country is different than the country in
133-
``country``. For instance, the country represented by an
134-
overseas military base or embassy.
135-
:ivar traits: :py:class:`geoip2.records.Traits` object representing
136-
the traits for the requested IP address.
186+
187+
:type: :py:class:`geoip2.records.Country`
188+
189+
.. attribute:: location
190+
191+
Location object for the requested IP address.
192+
193+
.. attribute:: maxmind
194+
195+
Information related to your MaxMind account.
196+
197+
:type: :py:class:`geoip2.records.MaxMind`
198+
199+
.. attribute:: registered_country
200+
201+
The registered country object for the requested IP address. This record
202+
represents the country where the ISP has registered a given IP block in
203+
and may differ from the user's country.
204+
205+
:type: :py:class:`geoip2.records.Country`
206+
207+
.. attribute:: represented_country
208+
209+
Object for the country represented by the users of the IP address
210+
when that country is different than the country in ``country``. For
211+
instance, the country represented by an overseas military base or
212+
embassy.
213+
214+
:type: :py:class:`geoip2.records.RepresentedCountry`
215+
216+
.. attribute:: subdivisions
217+
218+
Object (tuple) representing the subdivisions of the country to which
219+
the location of the requested IP address belongs.
220+
221+
:type: :py:class:`geoip2.records.Subdivisions`
222+
223+
.. attribute:: traits
224+
225+
Object with the traits of the requested IP address.
226+
227+
:type: :py:class:`geoip2.records.Traits`
137228
138229
"""
139230

140231

141232
class Omni(CityISPOrg):
142233
"""Model class for the GeoIP2 Precision Omni end point
143234
144-
:ivar city: :py:class:`geoip2.records.City` object representing
145-
country data for the requested IP address.
146-
:ivar continent: :py:class:`geoip2.records.Continent` object
147-
representing continent data for the requested IP address.
148-
:ivar country: :py:class:`geoip2.records.Country` object representing
149-
country data for the requested IP address. This record represents the
235+
.. attribute:: city
236+
237+
City object for the requested IP address.
238+
239+
:type: :py:class:`geoip2.records.City`
240+
241+
.. attribute:: continent
242+
243+
Continent object for the requested IP address.
244+
245+
:type: :py:class:`geoip2.records.Continent`
246+
247+
.. attribute:: country
248+
249+
Country object for the requested IP address. This record represents the
150250
country where MaxMind believes the IP is located.
151-
:ivar location: :py:class:`geoip2.records.Location` object
152-
representing country data for the requested IP address.
153-
:ivar maxmind: :py:class:`geoip2.records.MaxMind` object with
154-
information related to your MaxMind account.
155-
:ivar subdivisions: :py:class:`geoip2.records.Subdivisions` object representing
156-
country subdivisions for the requested IP address.
157-
:ivar registered_country: :py:class:`geoip2.records.Country` object
158-
representing the registered country data for the requested IP address.
159-
This record represents the country where the ISP has registered a given
160-
IP block in and may differ from the user's country.
161-
:ivar represented_country: :py:class:`geoip2.records.RepresentedCountry`
162-
object containing details about the country represented by the users
163-
of the IP address when that country is different than the country in
164-
``country``. For instance, the country represented by an
165-
overseas military base or embassy.
166-
:ivar traits: :py:class:`geoip2.records.Traits` object representing
167-
the traits for the requested IP address.
251+
252+
:type: :py:class:`geoip2.records.Country`
253+
254+
.. attribute:: location
255+
256+
Location object for the requested IP address.
257+
258+
.. attribute:: maxmind
259+
260+
Information related to your MaxMind account.
261+
262+
:type: :py:class:`geoip2.records.MaxMind`
263+
264+
.. attribute:: registered_country
265+
266+
The registered country object for the requested IP address. This record
267+
represents the country where the ISP has registered a given IP block in
268+
and may differ from the user's country.
269+
270+
:type: :py:class:`geoip2.records.Country`
271+
272+
.. attribute:: represented_country
273+
274+
Object for the country represented by the users of the IP address
275+
when that country is different than the country in ``country``. For
276+
instance, the country represented by an overseas military base or
277+
embassy.
278+
279+
:type: :py:class:`geoip2.records.RepresentedCountry`
280+
281+
.. attribute:: subdivisions
282+
283+
Object (tuple) representing the subdivisions of the country to which
284+
the location of the requested IP address belongs.
285+
286+
:type: :py:class:`geoip2.records.Subdivisions`
287+
288+
.. attribute:: traits
289+
290+
Object with the traits of the requested IP address.
291+
292+
:type: :py:class:`geoip2.records.Traits`
168293
169294
"""

0 commit comments

Comments
 (0)