Skip to content

Commit 1451f01

Browse files
committed
Minor docs improvements and fixes
1 parent e602ad5 commit 1451f01

File tree

11 files changed

+47
-23
lines changed

11 files changed

+47
-23
lines changed

docs/api.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ Here you can find an overview of all avaliable classes and methods.
1010
For example: if you rely on some non-deprecated method in version 3.3, then it's fine to update
1111
once to 3.4. If the method gets deprecated in 3.4, then it will be removed in 3.5!
1212

13+
.. automodule:: pycaching
14+
:members: login
15+
16+
1317
Geocaching
1418
-------------------------------------------------------------------------------
1519

docs/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# documentation root, use os.path.abspath to make it absolute, like shown here.
2424
sys.path.insert(0, os.path.abspath('..'))
2525

26+
from setup import info
27+
2628
# -- General configuration ------------------------------------------------
2729

2830
# If your documentation needs a minimal Sphinx version, state it here.
@@ -62,9 +64,9 @@
6264
# built documents.
6365
#
6466
# The short X.Y version.
65-
version = '3.4'
67+
version = '.'.join(info['version'].split('.')[:2])
6668
# The full version, including alpha/beta/rc tags.
67-
release = '3.4'
69+
release = info['version']
6870

6971
# The language for content autogenerated by Sphinx. Refer to documentation
7072
# for a list of supported languages.

docs/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
===================================================================================================
2+
pycaching - Geocaching for Python
3+
===================================================================================================
4+
5+
Source codes can be found at `GitHub repository <https://github.com/tomasbedrich/pycaching>`_.
6+
17
.. include:: ../README.rst
8+
:start-after: _features:
29
:end-before: _installation:
310

411

pycaching/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99

1010
def login(username=None, password=None):
11-
"""Logs the user in. A shortcut for Geocaching().login()."""
11+
"""A shortcut for user login.
12+
13+
Create a :class:`.Geocaching` instance and try to login a user. See :meth:`.Geocaching.login`.
14+
15+
:return: Created :class:`.Geocaching` instance.
16+
"""
1217
g = Geocaching()
1318
g.login(username, password)
1419
return g

pycaching/cache.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ def load(self):
492492
This method is called automatically when you access a property which isn't yet filled in
493493
(so-called "lazy loading"). You don't have to call it explicitly.
494494
495-
:raise PMOnlyException: If cache is PM only and current user is basic member.
496-
:raise LoadError: If cache loading fails (probably because of not existing cache).
495+
:raise .PMOnlyException: If cache is PM only and current user is basic member.
496+
:raise .LoadError: If cache loading fails (probably because of not existing cache).
497497
"""
498498
try:
499499
# pick url based on what info we have right now
@@ -578,7 +578,7 @@ def load_quick(self):
578578
the only loaded properties are: `name`, `type`, `state`, `size`, `difficulty`, `terrain`,
579579
`hidden`, `author`, `favorites` and `pm_only`.
580580
581-
:raise LoadError: If cache loading fails (probably because of not existing cache).
581+
:raise .LoadError: If cache loading fails (probably because of not existing cache).
582582
"""
583583
res = self.geocaching._request("http://tiles01.geocaching.com/map.details", params={
584584
"i": self.wp
@@ -609,7 +609,7 @@ def _logbook_get_page(self, page=0, per_page=25):
609609
610610
:param int page: Logbook page to load.
611611
:param int per_page: Logs per page (used to calculate start index).
612-
:raise LoadError: If loading fails.
612+
:raise .LoadError: If loading fails.
613613
"""
614614
res = self.geocaching._request("seek/geocache.logbook", params={
615615
"tkn": self._logbook_token, # will trigger lazy_loading if needed
@@ -779,7 +779,7 @@ def from_filename(cls, filename):
779779
def from_string(cls, name):
780780
"""Return a cache type from its human readable name.
781781
782-
:raise ValueError: If cache type cannot be determined.
782+
:raise .ValueError: If cache type cannot be determined.
783783
"""
784784
name = name.replace(" Geocache", "") # with space!
785785
name = name.replace(" Cache", "") # with space!
@@ -837,7 +837,7 @@ def from_filename(cls, filename):
837837
def from_string(cls, name):
838838
"""Return a cache size from its human readable name.
839839
840-
:raise ValueError: If cache size cannot be determined.
840+
:raise .ValueError: If cache size cannot be determined.
841841
"""
842842
name = name.strip().lower()
843843

pycaching/geo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def from_location(cls, geocaching, location):
3737
:param .Geocaching geocaching: Reference to :class:`.Geocaching` instance, used to do
3838
a geocoding request.
3939
:param str location: Location to geocode.
40-
:raise GeocodeError: If location cannot be geocoded (not found).
40+
:raise .GeocodeError: If location cannot be geocoded (not found).
4141
"""
4242
res = geocaching._request("api/geocode", params={"q": location}, expect="json")
4343

@@ -56,7 +56,7 @@ def from_string(cls, string):
5656
- :code:`N 6 52.861 W174 43.327`
5757
5858
:param str string: Coordinates to parse.
59-
:raise ValueError: If string cannot be parsed as coordinates.
59+
:raise .ValueError: If string cannot be parsed as coordinates.
6060
"""
6161

6262
# Make it uppercase for consistency
@@ -90,7 +90,7 @@ def from_string(cls, string):
9090
def from_block(cls, block):
9191
"""Return a new :class:`.Point` instance from :class:`.Block` instance.
9292
93-
:param Block block: UTFGrid block.
93+
:param .Block block: UTFGrid block.
9494
"""
9595
return cls.from_tile(block.tile, block.middle_point)
9696

pycaching/geocaching.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def login(self, username=None, password=None):
7373
and do some checks about currently logged user. As a last thing post the login form and
7474
check result.
7575
76-
:raise LoginFailedException: If login fails either because of bad credentials or
76+
:param str username: User's username or :code:`None` to use data from credentials file.
77+
:param str password: User's password or :code:`None` to use data from credentials file.
78+
:raise .LoginFailedException: If login fails either because of bad credentials or
7779
non-existing credentials file.
7880
"""
7981
if not username or not password:
@@ -139,7 +141,7 @@ def _load_credentials(self):
139141
it as a JSON and return credentials from it.
140142
141143
:return: Tuple of username and password loaded from file.
142-
:raise FileNotFoundError: If credentials file cannot be found.
144+
:raise .FileNotFoundError: If credentials file cannot be found.
143145
"""
144146
credentials_file = self._credentials_file
145147

@@ -313,18 +315,21 @@ def get_cache(self, wp):
313315
def get_trackable(self, tid):
314316
"""Return a :class:`.Trackable` object by its trackable ID.
315317
316-
:param str wp: Trackable ID.
318+
:param str tid: Trackable ID.
317319
"""
318320
return Trackable(self, tid)
319321

320-
def post_log(self, wp, text, type=LogType.found_it, date=datetime.date.today()):
322+
def post_log(self, wp, text, type=LogType.found_it, date=None):
321323
"""Post a log for cache.
322324
323325
:param str wp: Cache waypoint.
324326
:param str text: Log text.
325327
:param .log.Type type: Type of log.
326-
:param datetime.date date: Log date.
328+
:param datetime.date date: Log date. If set to :code:`None`, :meth:`datetime.date.today`
329+
is used instead.
327330
"""
331+
if not date:
332+
date = datetime.date.today()
328333
l = Log(type=type, text=text, visited=date)
329334
self.get_cache(wp).post_log(l)
330335

pycaching/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class Type(enum.Enum):
124124
def from_string(cls, name):
125125
"""Return a log type from its human readable name.
126126
127-
:raise ValueError: If log type cannot be determined.
127+
:raise .ValueError: If log type cannot be determined.
128128
"""
129129
name = name.strip().lower()
130130

pycaching/trackable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def load(self):
160160
This method is called automatically when you access a property which isn't yet filled in
161161
(so-called "lazy loading"). You don't have to call it explicitly.
162162
163-
:raise LoadError: If trackable loading fails (probably because of not existing cache).
163+
:raise .LoadError: If trackable loading fails (probably because of not existing cache).
164164
"""
165165
# pick url based on what info we have right now
166166
if hasattr(self, "url"):

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ def run(self):
3838

3939
root = os.path.dirname(__file__) or "."
4040

41-
with open(os.path.join(root, "README.rst")) as f:
41+
with open(os.path.join(root, "README.rst"), encoding="utf-8") as f:
4242
long_description = f.read()
4343

44-
with open(os.path.join(root, "requirements.txt")) as f:
44+
with open(os.path.join(root, "requirements.txt"), encoding="utf-8") as f:
4545
requirements = list(filter(None, (row.strip() for row in f)))
4646

4747
info = {
@@ -61,4 +61,5 @@ def run(self):
6161
"cmdclass": {"test": NoseTestCommand, "lint": LintCommand},
6262
}
6363

64-
setup(**info)
64+
if __name__ == "__main__":
65+
setup(**info)

0 commit comments

Comments
 (0)