From 3eb695484bddc8ed1cdae766d53871bc089777cc Mon Sep 17 00:00:00 2001 From: Wan Liuyang Date: Tue, 21 Aug 2018 16:03:35 +0800 Subject: [PATCH] Set up example docs skeleton --- doc/examples.rst | 8 ++++++++ doc/examples/Commit.rst | 17 ++++++++++++++++ doc/examples/MainClass.rst | 40 +++++++++++++++++++++++++++++++++++++ doc/examples/Repository.rst | 11 ++++++++++ doc/index.rst | 1 + doc/introduction.rst | 5 +++++ 6 files changed, 82 insertions(+) create mode 100644 doc/examples.rst create mode 100644 doc/examples/Commit.rst create mode 100644 doc/examples/MainClass.rst create mode 100644 doc/examples/Repository.rst diff --git a/doc/examples.rst b/doc/examples.rst new file mode 100644 index 00000000..49374a5c --- /dev/null +++ b/doc/examples.rst @@ -0,0 +1,8 @@ +Examples +======== + + +.. toctree:: + examples/MainClass + examples/Repository + examples/Commit \ No newline at end of file diff --git a/doc/examples/Commit.rst b/doc/examples/Commit.rst new file mode 100644 index 00000000..927330d7 --- /dev/null +++ b/doc/examples/Commit.rst @@ -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" + ) \ No newline at end of file diff --git a/doc/examples/MainClass.rst b/doc/examples/MainClass.rst new file mode 100644 index 00000000..98f99945 --- /dev/null +++ b/doc/examples/MainClass.rst @@ -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' \ No newline at end of file diff --git a/doc/examples/Repository.rst b/doc/examples/Repository.rst new file mode 100644 index 00000000..f1e3def2 --- /dev/null +++ b/doc/examples/Repository.rst @@ -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'] \ No newline at end of file diff --git a/doc/index.rst b/doc/index.rst index 097b8505..0a8aa75b 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -5,5 +5,6 @@ PyGithub :maxdepth: 1 introduction + examples reference changes \ No newline at end of file diff --git a/doc/introduction.rst b/doc/introduction.rst index 0d3ae295..a181080f 100644 --- a/doc/introduction.rst +++ b/doc/introduction.rst @@ -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 --------------------