mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 10:51:14 +00:00
Set up example docs skeleton
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
Examples
|
||||
========
|
||||
|
||||
|
||||
.. toctree::
|
||||
examples/MainClass
|
||||
examples/Repository
|
||||
examples/Commit
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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'
|
||||
@@ -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']
|
||||
@@ -5,5 +5,6 @@ PyGithub
|
||||
:maxdepth: 1
|
||||
|
||||
introduction
|
||||
examples
|
||||
reference
|
||||
changes
|
||||
@@ -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
|
||||
--------------------
|
||||
|
||||
Reference in New Issue
Block a user