Skip to content

Commit 37bd461

Browse files
committed
Add documentation linting to tox and Travis CI
This also fixes up the initial issues found by doc8.
1 parent ca67d2b commit 37bd461

24 files changed

Lines changed: 209 additions & 191 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ matrix:
3434
- env: TOXENV=docstrings
3535
- env: TOXENV=notebooks
3636
- env: TOXENV=readme
37-
- env: TOXENV=docs
37+
- env: TOXENV=doclint,docs
3838
fast_finish: true
3939
allow_failures:
4040
- env: TOXENV=docstrings

docs/source/api-reference/git.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Git API Classes
33
=================
44

5-
This part of the documentation covers the module associated with the `Git Data`_
6-
section of the GitHub API.
5+
This part of the documentation covers the module associated with the
6+
`Git Data`_ section of the GitHub API.
77

88
Like much of the GitHub API, many objects have different representations.
99

docs/source/api-reference/search.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Search Results
33
================
44

5-
These classes are meant to expose the entirety of an item returned as a search
5+
These classes are meant to expose the entirety of an item returned as a search
66
result by GitHub's Search API.
77

88
.. autoclass:: github3.search.CodeSearchResult

docs/source/contributing/testing.rst

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ Writing Tests for github3.py
44
Unit Tests
55
----------
66

7-
In computer programming, unit testing is a method by which individual
8-
units of source code, sets of one or more computer program modules
9-
together with associated control data, usage procedures, and operating
10-
procedures are tested to determine if they are fit for use. Intuitively,
7+
In computer programming, unit testing is a method by which individual
8+
units of source code, sets of one or more computer program modules
9+
together with associated control data, usage procedures, and operating
10+
procedures are tested to determine if they are fit for use. Intuitively,
1111
one can view a unit as the smallest testable part of an application.
1212

13-
-- `Unit Testing on Wikipedia
13+
-- `Unit Testing on Wikipedia
1414
<http://en.wikipedia.org/wiki/Unit_testing>`_
1515

16-
In github3.py we use unit tests to make assertions about how the library
17-
behaves without making a request to the internet. For example, one assertion
18-
we might write would check if custom information is sent along in a request to
16+
In github3.py we use unit tests to make assertions about how the library
17+
behaves without making a request to the internet. For example, one assertion
18+
we might write would check if custom information is sent along in a request to
1919
GitHub.
2020

21-
An existing test like this can be found in
21+
An existing test like this can be found in
2222
``tests/unit/test_repos_release.py``:
2323

2424
.. code:: python
@@ -30,63 +30,63 @@ An existing test like this can be found in
3030
headers={'Accept': 'application/vnd.github.manifold-preview'}
3131
)
3232
33-
In this test, we check that the library passes on important headers to the API
34-
to ensure the request will work properly. ``self.instance`` is created for us
35-
and is an instance of the ``Release`` class. The test then calls ``delete`` to
36-
make a request to the API. ``self.session`` is a mock object which fakes out a
37-
normal session. It does not allow the request through but allows us to verify
38-
how github3.py makes a request. We can see that github3.py called ``delete``
39-
on the session. We assert that it was only called once and that the only
33+
In this test, we check that the library passes on important headers to the API
34+
to ensure the request will work properly. ``self.instance`` is created for us
35+
and is an instance of the ``Release`` class. The test then calls ``delete`` to
36+
make a request to the API. ``self.session`` is a mock object which fakes out a
37+
normal session. It does not allow the request through but allows us to verify
38+
how github3.py makes a request. We can see that github3.py called ``delete``
39+
on the session. We assert that it was only called once and that the only
4040
parameters sent were a URL and the custom headers that we are concerned with.
4141

4242
Mocks
4343
~~~~~
4444

4545
Above we talked about mock objects. What are they?
4646

47-
In object-oriented programming, mock objects are simulated objects that
48-
mimic the behavior of real objects in controlled ways. A programmer
49-
typically creates a mock object to test the behavior of some other object,
50-
in much the same way that a car designer uses a crash test dummy to
47+
In object-oriented programming, mock objects are simulated objects that
48+
mimic the behavior of real objects in controlled ways. A programmer
49+
typically creates a mock object to test the behavior of some other object,
50+
in much the same way that a car designer uses a crash test dummy to
5151
simulate the dynamic behavior of a human in vehicle impacts.
5252

5353
-- `Mock Object on Wikipedia <http://en.wikipedia.org/wiki/Mock_object>`_
5454

55-
We use mocks in github3.py to prevent the library from talking directly with
56-
GitHub. The mocks we use intercept requests the library makes so we can verify
57-
the parameters we use. In the example above, we were able to check that
58-
certain parameters were the only ones sent to a session method because we
55+
We use mocks in github3.py to prevent the library from talking directly with
56+
GitHub. The mocks we use intercept requests the library makes so we can verify
57+
the parameters we use. In the example above, we were able to check that
58+
certain parameters were the only ones sent to a session method because we
5959
mocked out the session.
6060

61-
You may have noticed in the example above that we did not have to set up the
62-
mock object. There is a convenient helper written in ``tests/unit/helper.py``
61+
You may have noticed in the example above that we did not have to set up the
62+
mock object. There is a convenient helper written in ``tests/unit/helper.py``
6363
to do this for you.
6464

6565
Example - Testing the Release Object
6666
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6767

68-
Here's a full example of how we test the ``Release`` object in
68+
Here's a full example of how we test the ``Release`` object in
6969
``tests/unit/test_repos_release.py``.
7070

71-
Our first step is to import the ``UnitHelper`` class from
72-
``tests/unit/helper.py`` and the ``Release`` object from
71+
Our first step is to import the ``UnitHelper`` class from
72+
``tests/unit/helper.py`` and the ``Release`` object from
7373
``github3/repos/release.py``.
7474

7575
.. code:: python
7676
7777
from .helper import UnitHelper
7878
from github3.repos.release import Release
7979
80-
Then we construct our test class and indicate which class we will be testing
80+
Then we construct our test class and indicate which class we will be testing
8181
(or describing).
8282

8383
.. code:: python
8484
8585
class TestRelease(UnitHelper):
8686
described_class = Release
8787
88-
We can then use the `GitHub API documentation about Releases
89-
<http://developer.github.com/v3/repos/releases/>`_ to retrieve example release
88+
We can then use the `GitHub API documentation about Releases
89+
<http://developer.github.com/v3/repos/releases/>`_ to retrieve example release
9090
data. We then can use that as example data for our test like so:
9191

9292
.. code:: python
@@ -109,8 +109,8 @@ data. We then can use that as example data for our test like so:
109109
"published_at": "2013-02-27T19:35:32Z"
110110
}
111111
112-
The above code now will handle making clean and brand new instances of the
113-
``Release`` object with the example data and a faked out session. We can now
112+
The above code now will handle making clean and brand new instances of the
113+
``Release`` object with the example data and a faked out session. We can now
114114
construct our first test.
115115

116116
.. code:: python
@@ -126,22 +126,22 @@ construct our first test.
126126
Integration Tests
127127
-----------------
128128

129-
Integration testing is the phase in software testing in which individual
129+
Integration testing is the phase in software testing in which individual
130130
software modules are combined and tested as a group.
131131

132-
The purpose of integration testing is to verify functional, performance,
132+
The purpose of integration testing is to verify functional, performance,
133133
and reliability requirements placed on major design items.
134134

135-
-- `Integration tests on Wikipedia
135+
-- `Integration tests on Wikipedia
136136
<http://en.wikipedia.org/wiki/Integration_tests>`_
137137

138-
In github3.py we use integration tests to ensure that when we make what should
139-
be a valid request to GitHub, it is in fact valid. For example, if we were
140-
testing how github3.py requests a user's information, we would expect a
141-
request for a real user's data to be valid. If the test fails we know either
138+
In github3.py we use integration tests to ensure that when we make what should
139+
be a valid request to GitHub, it is in fact valid. For example, if we were
140+
testing how github3.py requests a user's information, we would expect a
141+
request for a real user's data to be valid. If the test fails we know either
142142
what the library is doing is wrong or the data requested does not exist.
143143

144-
An existing test that demonstrates integration testing can be found in
144+
An existing test that demonstrates integration testing can be found in
145145
``tests/integration/test_repos_release.py``:
146146

147147
.. code:: python
@@ -156,31 +156,31 @@ An existing test that demonstrates integration testing can be found in
156156
assert isinstance(asset, github3.repos.release.Asset)
157157
assert asset is not None
158158
159-
In this test we use ``self.recorder`` to record our interaction with GitHub.
160-
We then proceed to make the request to GitHub that will exercise the code we
161-
wish to test. First we request a ``Repository`` object from GitHub and then
162-
using that we request a ``Release`` object. After receiving that release, we
163-
exercise the code that lists the assets of a ``Release``. We verify that each
164-
asset is an instance of the ``Asset`` class and that at the end the ``asset``
165-
variable is not ``None``. If ``asset`` was ``None``, that would indicate that
166-
GitHub did not return any data and it did not exercise the code we are trying
159+
In this test we use ``self.recorder`` to record our interaction with GitHub.
160+
We then proceed to make the request to GitHub that will exercise the code we
161+
wish to test. First we request a ``Repository`` object from GitHub and then
162+
using that we request a ``Release`` object. After receiving that release, we
163+
exercise the code that lists the assets of a ``Release``. We verify that each
164+
asset is an instance of the ``Asset`` class and that at the end the ``asset``
165+
variable is not ``None``. If ``asset`` was ``None``, that would indicate that
166+
GitHub did not return any data and it did not exercise the code we are trying
167167
to test.
168168

169169
Betamax
170170
~~~~~~~
171171

172-
Betamax_ is the library that we use to create the recorder above. It sets up
173-
the session object to intercept every request and corresponding response and
174-
save them to what it calls cassettes_. After you record the interaction it
172+
Betamax_ is the library that we use to create the recorder above. It sets up
173+
the session object to intercept every request and corresponding response and
174+
save them to what it calls cassettes_. After you record the interaction it
175175
never has to speak to the internet again for that request.
176176

177-
In github3.py there is a helper class (much like ``UnitHelper``) in
177+
In github3.py there is a helper class (much like ``UnitHelper``) in
178178
``tests/integration/helper.py`` which sets everything up for us.
179179

180180
Example - Testing the Release Object
181181
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182182

183-
Here's an example of how we write an integration test for github3.py. The
183+
Here's an example of how we write an integration test for github3.py. The
184184
example can be found in ``tests/integration/test_repos_release.py``.
185185

186186
Our first steps are the necessary imports.
@@ -210,37 +210,37 @@ Then we start writing our test right away.
210210
assert release is not None
211211
assert release.delete() is True
212212
213-
Every test has access to ``self.gh`` which is an instance of ``GitHub``.
214-
``IntegrationHelper`` provides a lot of methods that allow you to focus on
215-
what we are testing instead of setting up for the test. The first of those
216-
methods we see in use is ``self.token_login`` which handles authenticating
217-
with a token. It's sister method is ``self.basic_login`` which handles
218-
authentication with basic credentials. Both of these methods will set up the
219-
authentication for you on ``self.gh``.
213+
Every test has access to ``self.gh`` which is an instance of ``GitHub``.
214+
``IntegrationHelper`` provides a lot of methods that allow you to focus on
215+
what we are testing instead of setting up for the test. The first of those
216+
methods we see in use is ``self.token_login`` which handles authenticating
217+
with a token. It's sister method is ``self.basic_login`` which handles
218+
authentication with basic credentials. Both of these methods will set up the
219+
authentication for you on ``self.gh``.
220220

221-
The next convenience method we see is ``self.cassette_name``. It constructs a
222-
cassette name for you based on the test class name and the string you provide
221+
The next convenience method we see is ``self.cassette_name``. It constructs a
222+
cassette name for you based on the test class name and the string you provide
223223
it.
224224

225-
Every test also has access to ``self.recorder``. This is the Betamax recorder
226-
that has been set up for you to record your interactions. The recorder is
225+
Every test also has access to ``self.recorder``. This is the Betamax recorder
226+
that has been set up for you to record your interactions. The recorder is
227227
started when you write
228228

229229
.. code:: python
230230
231231
with self.recorder.use_cassette(cassette_name):
232232
# ...
233233
234-
Everything that talks to GitHub should be written inside of the context
235-
created by the context manager there. No requests to GitHub should be made
234+
Everything that talks to GitHub should be written inside of the context
235+
created by the context manager there. No requests to GitHub should be made
236236
outside of that context.
237237

238-
In that context, we then retrieve a repository and create a release for it. We
239-
want to be sure that we will be deleting something that exists so we assert
240-
that what we received back from GitHub is not ``None``. Finally we call
238+
In that context, we then retrieve a repository and create a release for it. We
239+
want to be sure that we will be deleting something that exists so we assert
240+
that what we received back from GitHub is not ``None``. Finally we call
241241
``delete`` and assert that it returns ``True``.
242242

243-
When you write your new test and record a new cassette, be sure to add the new
243+
When you write your new test and record a new cassette, be sure to add the new
244244
cassette file to the repository, like so:
245245

246246
.. code::

docs/source/examples/git.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Git Code Examples
22
=================
33

4-
The GitHub API does not just provide an API to interact with GitHub's
5-
features. A whole section of the API provides a RESTful API to git operations
4+
The GitHub API does not just provide an API to interact with GitHub's
5+
features. A whole section of the API provides a RESTful API to git operations
66
that one might normally perform at the command-line or via your git client.
77

88
Creating a Blob Object
99
----------------------
1010

11-
One of the really cool (and under used, it seems) parts of the GitHub API
11+
One of the really cool (and under used, it seems) parts of the GitHub API
1212
involves the ability to create blob objects.
1313

1414
.. code-block:: python
@@ -30,7 +30,7 @@ involves the ability to create blob objects.
3030
Creating a Tag Object
3131
---------------------
3232

33-
GitHub provides tar files for download via tag objects. You can create one via
33+
GitHub provides tar files for download via tag objects. You can create one via
3434
``git tag`` or you can use the API.
3535

3636
.. code-block:: python

docs/source/examples/github.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ object ``g``. That might look like this::
3838
So anywhere you see ``g`` used, you can safely assume that it is an instance
3939
where a user has authenticated already.
4040

41-
For the cases where we do not need an authenticated user, or where we are trying
42-
to demonstrate the differences between the two, I will use ``anon``. ``anon``
43-
could be instantiated like so::
41+
For the cases where we do not need an authenticated user, or where we are
42+
trying to demonstrate the differences between the two, I will use ``anon``.
43+
``anon`` could be instantiated like so::
4444

4545
anon = GitHub()
4646

docs/source/examples/issue.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ Example issue to comment on
3434
---------------------------
3535

3636
If you would like to test the above, see
37-
`issue #108 <https://github.com/sigmavirus24/github3.py/issues/108>`_. Just
38-
follow the code there and fill in your username, password (or token), and
39-
comment message. Then run the script and watch as the issue opens in your
37+
`issue #108 <https://github.com/sigmavirus24/github3.py/issues/108>`_. Just
38+
follow the code there and fill in your username, password (or token), and
39+
comment message. Then run the script and watch as the issue opens in your
4040
browser focusing on the comment **you** just created.
4141

4242
The following shows how you could use github3.py to fetch and display your
@@ -53,7 +53,9 @@ Or how to do the same by wrapping the lines in your terminal.
5353
Importing an issue
5454
------------------
5555

56-
Not only can you create new issues, but you can import existing ones. When importing, you preserve the timestamp creation date; you can preserve the timestamp(s) for comment(s) too.
56+
Not only can you create new issues, but you can import existing ones. When
57+
importing, you preserve the timestamp creation date; you can preserve the
58+
timestamp(s) for comment(s) too.
5759

5860
::
5961

0 commit comments

Comments
 (0)