Skip to content

Commit 8bc7dde

Browse files
committed
Merge branch 'feat/documentation'
* feat/documentation: Fixed Sphinx :see: uses to use domain refs. Added basic release building document. [QA] Missing word in contributing. Initial documentation for the binding objects.
2 parents 6724850 + 04b2497 commit 8bc7dde

File tree

7 files changed

+113
-11
lines changed

7 files changed

+113
-11
lines changed

doc/api/core.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Core
3030

3131
.. autofunction:: repr_string
3232

33-
.. autoclass:: GithubCommand(type)
33+
.. autoclass:: GithubCommand
3434

35-
.. autoclass:: Attribute(type)
35+
.. autoclass:: Attribute
3636

37-
.. autoclass:: DateAttribute(type)
37+
.. autoclass:: DateAttribute(help, format)
3838

39-
.. autoclass:: BaseDataType(type)
39+
.. autoclass:: BaseData()

doc/contributing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ Many assertions, such as :meth:`~unittest.TestCase.assertIn` and
7171
The simple workaround is to evaluate an expression to test with
7272
:meth:`~unittest.TestCase.assertTrue`
7373

74-
The incredibly functions for skipping tests(:func:`~unittest.skip`) and marking
75-
expected failures(:func:`~unittest.expectedFailure`) were only added in 2.7, and
76-
unfortunately can't be used.
74+
The incredibly useful functions for skipping tests(:func:`~unittest.skip`) and
75+
marking expected failures(:func:`~unittest.expectedFailure`) were only added in
76+
2.7, and unfortunately can't be used.
7777

7878
.. todo::
7979
Add topic branches and pull request usage examples, but most git users are

doc/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Contents
4141
bugs
4242
contributing
4343
wild
44+
release
4445
license
4546

4647
Indices and tables

doc/release.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Release HOWTO
2+
=============
3+
4+
.. highlight:: sh
5+
6+
..
7+
Much of this stuff is automated locally, but I'm describing the process for
8+
other people who will not have access to the same release tools I use. The
9+
first thing I recommend that you do is find/write a tool that allows you to
10+
automate all of this, or you're going to miss important steps at some point.
11+
12+
Test
13+
----
14+
15+
In the general case tests can be run via :pypi:`nose`'s :pypi:`distribute`
16+
integration::
17+
18+
$ ./setup.py nosetests
19+
20+
When preparing a release it is important to check that :mod:`github2` works with
21+
all currently supported Python versions, and that the documentation is correct.
22+
To that end you can use :pypi:`tox` to run the full testsuite::
23+
24+
$ tox -v
25+
26+
This will test :mod:`github2` with Python 2.4 → 3.2, check that the ``reST``
27+
syntax is valid and also that the :pypi:`sphinx` documentation builds correctly.
28+
You can run a subset of these options too, see the ``tox`` documentation for
29+
more information.
30+
31+
Prepare release
32+
---------------
33+
34+
With the tests passing, perform the following steps
35+
36+
* Update the version data in :file:`github2/_version.py`, and also the
37+
reference in :file:`README.rst`
38+
* Update :file:`NEWS.rst`, if there are any user visible changes
39+
* Commit the release notes and version changes
40+
* Create a signed tag for the release
41+
* Push the changes, including the new tag, to the GitHub repository
42+
43+
Update PyPI
44+
-----------
45+
46+
..
47+
This is the section you're especially likely to get wrong at some point if you
48+
try to handle all of this manually ;)
49+
50+
Create and upload the new release tarballs to PyPI::
51+
52+
$ ./setup.py sdist --formats=bztar,gztar register upload --sign
53+
54+
You should also update the hosted documentation too::
55+
56+
$ ./setup.py build_sphinx && ./setup.py upload_docs
57+
58+
Fetch the uploaded tarballs, and check for errors.
59+
60+
You should also perform test installations from PyPI, to check the experience
61+
:mod:`github2` users will have.
62+
63+
.. highlight:: python

github2/core.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,24 @@ def enhanced_by_auth(f):
137137
class GithubCommand(object):
138138

139139
def __init__(self, request):
140+
"""Main API binding interface
141+
142+
:param github2.request.GithubRequest request: HTTP request handler
143+
"""
140144
self.request = request
141145

142146
def make_request(self, command, *args, **kwargs):
147+
"""Make an API request
148+
149+
Various options are supported if they exist in ``kwargs``:
150+
151+
* The value of a ``method`` argument will define the HTTP method
152+
to perform for this request, the default is ``GET``
153+
* The value of a ``filter`` argument will restrict the response to that
154+
data
155+
* The value of a ``page`` argument will be used to fetch a specific
156+
page of results, default of 1 is assumed if not given
157+
"""
143158
filter = kwargs.get("filter")
144159
post_data = kwargs.get("post_data") or {}
145160
page = kwargs.pop("page", 1)
@@ -162,6 +177,11 @@ def make_request(self, command, *args, **kwargs):
162177
return response
163178

164179
def get_value(self, *args, **kwargs):
180+
"""Process a single-value response from the API
181+
182+
If a ``datatype`` parameter is given it defines the
183+
:class:`BaseData`-derived class we should build from the provided data
184+
"""
165185
datatype = kwargs.pop("datatype", None)
166186
value = self.make_request(*args, **kwargs)
167187
if datatype:
@@ -176,6 +196,10 @@ def get_value(self, *args, **kwargs):
176196
return value
177197

178198
def get_values(self, *args, **kwargs):
199+
"""Process a multi-value response from the API
200+
201+
:see: :meth:`get_value`
202+
"""
179203
datatype = kwargs.pop("datatype", None)
180204
values = self.make_request(*args, **kwargs)
181205
if datatype:
@@ -208,8 +232,11 @@ def bullet(title, text):
208232

209233

210234
class Attribute(object):
211-
212235
def __init__(self, help):
236+
"""Generic object attribute for use with :class:`BaseData`
237+
238+
:param str help: Attribute description
239+
"""
213240
self.help = help
214241

215242
def to_python(self, value):
@@ -228,6 +255,11 @@ class DateAttribute(Attribute):
228255
}
229256

230257
def __init__(self, *args, **kwargs):
258+
"""Date handling attribute for use with :class:`BaseData`
259+
260+
:param str format: The date format to support, see
261+
:data:`convertor_for_format` for supported options
262+
"""
231263
self.format = kwargs.pop("format", self.format)
232264
super(DateAttribute, self).__init__(*args, **kwargs)
233265

@@ -280,6 +312,12 @@ def iterate(self):
280312
# Ugly base class definition for Python 2 and 3 compatibility, where metaclass
281313
# syntax is incompatible
282314
class BaseData(BaseDataType('BaseData', (object, ), {})):
315+
"""Wrapper for API responses
316+
317+
.. warning::
318+
Supports subscript attribute access purely for backwards compatibility,
319+
you shouldn't rely on that functionality in new code
320+
"""
283321
def __getitem__(self, key):
284322
"""Access objects's attribute using subscript notation
285323
@@ -296,7 +334,7 @@ def __getitem__(self, key):
296334
def __setitem__(self, key, value):
297335
"""Update object's attribute using subscript notation
298336
299-
:see: ``BaseData.__getitem__``
337+
:see: :meth:`BaseData.__getitem__`
300338
"""
301339
LOGGER.warning("Subscript access on %r is deprecated, use object "
302340
"attributes" % self.__class__.__name__,

tests/test_tz_aware_date_handling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def teardown_module():
2323
def dt_utz(year, month, day, hour, minute, second):
2424
"""Produce a UTC-anchored datetime object
2525
26-
:see: ``datetime.datetime``
26+
:see: :class:`datetime.datetime`
2727
"""
2828
return dt(year, month, day, hour, minute, second, tzinfo=tzutc())
2929

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class HttpMockAuthenticatedTestCase(HttpMockTestCase):
7373
def setUp(self):
7474
"""Prepare test fixtures
7575
76-
:see: ``HttpMockTestCase``
76+
:see: :class:`HttpMockTestCase`
7777
7878
:attr:`client` is an authenticated :obj:`Github` object for easy use
7979
in tests.

0 commit comments

Comments
 (0)