Skip to content

Commit 3440d73

Browse files
committed
Start cleaning up our API documentation
1 parent d4a67ec commit 3440d73

4 files changed

Lines changed: 70 additions & 102 deletions

File tree

docs/source/api-reference/api.rst

Lines changed: 19 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
.. _api:
22

3-
API
4-
===
3+
==========================
4+
Anonymous Functional API
5+
==========================
56

67
.. module:: github3
78
.. module:: github3.api
@@ -11,162 +12,103 @@ beautifully written module which allows the user (developer) to interact with
1112
``github3.py`` elegantly and easily.
1213

1314
Module Contents
14-
---------------
15+
===============
1516

1617
To interact with the GitHub API you can either authenticate to access protected
1718
functionality or you can interact with it anonymously. Authenticating provides
1819
more functionality to the the user (developer).
1920

20-
To authenticate, you simply use :func:`github3.login`.
21+
To authenticate, you may use :func:`github3.login`.
2122

2223
.. autofunction:: github3.login
2324

24-
With the :class:`GitHub <github3.github.GitHub>` object that is returned you have access
25-
to more functionality. See that object's documentation for more information.
25+
With the :class:`~github3.github.GitHub` object that is returned you have
26+
access to more functionality. See that object's documentation for more
27+
information.
2628

27-
To use the API anonymously, you can create a new
28-
:class:`GitHub <github3.github.GitHub>` object, e.g.,
29+
To use the API anonymously, you can also create a new
30+
:class:`~github3.github.GitHub` object, e.g.,
2931

30-
::
32+
.. code-block:: python
3133
3234
from github3 import GitHub
3335
3436
gh = GitHub()
3537
36-
Or you can simply use the following functions
38+
Or you can use the following functions:
3739

38-
------
40+
Anonymous Functions
41+
-------------------
3942

4043
.. autofunction:: github3.authorize
4144

42-
------
43-
4445
.. autofunction:: github3.create_gist
4546

46-
------
47-
4847
.. autofunction:: github3.gist
4948

50-
------
51-
5249
.. autofunction:: github3.gitignore_template
5350

54-
------
55-
5651
.. autofunction:: github3.gitignore_templates
5752

58-
------
59-
6053
.. autofunction:: github3.issue
6154

62-
------
63-
6455
.. autofunction:: github3.issues_on
6556

66-
------
67-
6857
.. autofunction:: github3.all_repositories
6958

70-
------
71-
7259
.. autofunction:: github3.all_users
7360

74-
------
75-
7661
.. autofunction:: github3.all_events
7762

78-
------
79-
8063
.. autofunction:: github3.followers_of
8164

82-
------
83-
8465
.. autofunction:: github3.followed_by
8566

86-
------
87-
8867
.. autofunction:: github3.public_gists
8968

90-
------
91-
9269
.. autofunction:: github3.gists_by
9370

94-
------
95-
9671
.. autofunction:: github3.organizations_with
9772

98-
------
99-
10073
.. autofunction:: github3.repositories_by
10174

102-
------
103-
10475
.. autofunction:: github3.starred_by
10576

106-
------
107-
10877
.. autofunction:: github3.subscriptions_for
10978

110-
------
111-
11279
.. autofunction:: github3.markdown
11380

114-
------
115-
11681
.. autofunction:: github3.octocat
11782

118-
------
119-
12083
.. autofunction:: github3.organization
12184

122-
------
123-
12485
.. autofunction:: github3.pull_request
12586

126-
------
127-
12887
.. autofunction:: github3.rate_limit
12988

130-
------
131-
13289
.. autofunction:: github3.repository
13390

134-
------
135-
13691
.. autofunction:: github3.search_code
13792

138-
------
139-
14093
.. autofunction:: github3.search_issues
14194

142-
------
143-
14495
.. autofunction:: github3.search_repositories
14596

146-
------
147-
14897
.. autofunction:: github3.search_users
14998

150-
------
151-
15299
.. autofunction:: github3.user
153100

154-
------
155-
156101
.. autofunction:: github3.zen
157102

158-
------
159-
160103
Enterprise Use
161-
--------------
104+
==============
162105

163-
If you're using github3.py to interact with an enterprise installation of
164-
GitHub, you must use the
165-
:class:`GitHubEnterprise <github3.github.GitHubEnterprise>` object. Upon
166-
initialization, the only parameter you must supply is the URL of your
106+
If you're using github3.py to interact with an enterprise installation of
107+
GitHub, you **must** use the :class:`~github3.github.GitHubEnterprise` object.
108+
Upon initialization, the only parameter you must supply is the URL of your
167109
enterprise installation, e.g.
168110

169-
::
111+
.. code-block:: python
170112
171113
from github3 import GitHubEnterprise
172114
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
.. module:: github3
2-
.. module:: github3.auths
3-
4-
Authorization
5-
=============
1+
============================
2+
Authorizations API Classes
3+
============================
64

75
This part of the documentation covers the
8-
:class:`Authorization <Authorization>` object.
6+
:class:`~github3.auths.Authorization` object.
97

10-
.. autoclass:: Authorization
8+
.. autoclass:: github3.auths.Authorization
119
:inherited-members:
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
.. _decorators:
22

3-
Decorators
4-
==========
3+
============
4+
Decorators
5+
============
56

6-
.. module:: github3
7-
.. module:: github3.decorators
8-
9-
This part of the documentation covers the decorators module which contains all
7+
This part of the documentation covers the decorators module which contains all
108
of the decorators used in github3.py.
119

10+
.. warning::
11+
12+
These decorators are only to be used internally in development of this
13+
library.
14+
1215

13-
Contents
14-
--------
16+
Decorator Functions
17+
===================
1518

1619
.. autofunction:: github3.decorators.requires_auth
20+
21+
.. autofunction:: github3.decorators.requires_basic_auth
22+
23+
.. autofunction:: github3.decorators.requires_app_credentials
Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,58 @@
1-
Events
2-
======
1+
====================
2+
Events API Classes
3+
====================
34

4-
.. module:: github3
5-
.. module:: github3.events
6-
7-
This part of the documentation covers the :class:`Event <Event>` object.
5+
This part of the documentation covers the objects that represent data returned
6+
by the Events API.
87

98
Event Objects
10-
-------------
9+
=============
1110

12-
.. autoclass:: Event
11+
.. autoclass:: github3.events.Event
1312
:inherited-members:
1413

1514
When accessing the payload of the event, you should notice that you receive a
1615
dictionary where the keys depend on the event type_. Note:
1716

1817
- where they reference an array in the documentation but index it like a
1918
dictionary, you are given a regular dictionary
19+
2020
- where they reference a key as returning an object, you receive the equivalent
21-
object from the dictionary, e.g., for a Fork Event::
21+
object from the dictionary, e.g., for a Fork Event
22+
23+
.. code-block:: python
2224
2325
>>> event
2426
<Event [Fork]>
2527
>>> event.payload
2628
{u'forkee': <Repository [eweap/redactor-js]>}
2729
>>> event.payload['forkee']
28-
<Repository [eweap/redactor-js]>
30+
<ShortRepository [eweap/redactor-js]>
2931
3032
Using the dictionary returned as the payload makes far more sense than creating
3133
an object for the payload in this instance. For one, creating a class for each
3234
payload type would be insanity. I did it once, but it isn't worth the effort.
3335
Having individual handlers as we have now which modify the payload to use our
3436
objects when available is more sensible.
3537

38+
The following objects are returned as part of an
39+
:class:`~github3.events.Event`. These objects all have methods to convert them
40+
to full representations of the object. For example,
41+
:class:`~github3.events.EventUser` has
42+
:meth:`~github3.events.EventUser.to_user` and aliases
43+
:meth:`~github3.events.EventUser.refresh` to behave similarly.
44+
45+
.. autoclass:: github3.events.EventUser
46+
47+
.. autoclass:: github3.events.EventOrganization
48+
49+
.. autoclass:: github3.events.EventPullRequest
50+
51+
.. autoclass:: github3.events.EventReviewComment
52+
53+
.. autoclass:: github3.events.EventIssue
54+
55+
.. autoclass:: github3.events.EventIssueComment
56+
3657
.. links
3758
.. _type: https://developer.github.com/v3/activity/events/types

0 commit comments

Comments
 (0)