Set up example docs skeleton

This commit is contained in:
Wan Liuyang
2018-08-21 16:03:35 +08:00
parent f3abadae08
commit 3eb695484b
6 changed files with 82 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
Examples
========
.. toctree::
examples/MainClass
examples/Repository
examples/Commit
+17
View File
@@ -0,0 +1,17 @@
Commit
======
Create commit status check
--------------------------
.. code-block:: python
# sha -> commit on which the status check will be created
# For example, for a webhook payload
# sha = data["pull_request"]["head"]["sha"]
repo.get_commit(sha=sha).create_status(
state="pending",
target_url="https://FooCI.com",
description="FooCI is building",
context="ci/FooCI"
)
+40
View File
@@ -0,0 +1,40 @@
Main Class
==========
This is the main class.
Get current user
----------------
.. code-block:: python
>>> user = g.get_user()
>>> user.login
u'sfdye'
Get user by name
----------------
.. code-block:: python
>>> user = g.get_user("sfdye")
>>> user.name
u'Wan Liuyang'
Get repository by name
----------------------
.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.name
u'PyGithub'
Get organization by name
------------------------
.. code-block:: python
>>> org = g.get_organization("PyGithub")
>>> org.login
u'PyGithub'
+11
View File
@@ -0,0 +1,11 @@
Repository
==========
Get repository topics
---------------------
.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.get_topics()
[u'pygithub', u'python', u'github', u'github-api']
+1
View File
@@ -5,5 +5,6 @@ PyGithub
:maxdepth: 1
introduction
examples
reference
changes
+5
View File
@@ -21,11 +21,16 @@ First create a Github instance::
# or using an access token
g = Github("access_token")
# Github Enterprise with custom hostname
g = Github(base_url="https://{hostname}/api/v3", login_or_token="access_token")
Then play with your Github objects::
for repo in g.get_user().get_repos():
print(repo.name)
repo.edit(has_wiki=False)
# to see all the available attributes and methods
print(dir(repo))
Download and install
--------------------