Skip to content

Commit

Permalink
New use examples (#920)
Browse files Browse the repository at this point in the history
This PR add the follow code examples

* Issue examples (get list, get specific issue, create issue)
* Milestone examples (get list, get specific milestone, create milestone)

Ref.: #874
  • Loading branch information
mstuttgart authored and sfdye committed Oct 8, 2018
1 parent 8f4f40e commit 228e5e8
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ Examples
examples/MainClass
examples/Repository
examples/Commit
examples/PullRequest
examples/PullRequest
examples/Issue
examples/Milestone
58 changes: 58 additions & 0 deletions doc/examples/Issue.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Issues
======

Get issue
---------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.get_issue(number=874)
Issue(title="PyGithub example usage", number=874)
Create issue
------------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.create_issue(title="This is a new issue")
Issue(title="This is a new issue", number=XXX)
Create issue with body
----------------------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.create_issue(title="This is a new issue", body="This is the issue body")
Issue(title="This is a new issue", number=XXX)
Create issue with labels
------------------------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> label = repo.get_label("My Label")
>>> repo.create_issue(title="This is a new issue", labels=[label])
Issue(title="This is a new issue", number=XXX)
Create issue with assignee
--------------------------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> repo.create_issue(title="This is a new issue", assignee="github-username")
Issue(title="This is a new issue", number=XXX)
Create issue with milestone
---------------------------

.. code-block:: python
>>> repo = g.get_repo("PyGithub/PyGithub")
>>> milestone = repo.create_milestone("New Issue Milestone")
>>> repo.create_issue(title="This is a new issue", milestone=milestone)
Issue(title="This is a new issue", number=XXX)
42 changes: 42 additions & 0 deletions doc/examples/Milestone.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Milestone
==========

Get Milestone list
------------------

.. code-block:: python
>>> repo = g.get_repo('PyGithub/PyGithub')
>>> open_milestones = repo.get_milestones(state='open')
>>> for milestone in open_milestones:
... print(milestone)
...
Milestone(number=1)
Milestone(number=2)
Get Milestone
-------------

.. code-block:: python
>>> repo = g.get_repo('PyGithub/PyGithub')
>>> repo.get_milestone(number=1)
Milestone(number=1)
Create Milestone
----------------

.. code-block:: python
>>> repo = g.get_repo('PyGithub/PyGithub')
>>> repo.create_milestone(title='New Milestone')
Milestone(number=1)
Create Milestone with State and Description
-------------------------------------------

.. code-block:: python
>>> repo = g.get_repo('PyGithub/PyGithub')
>>> repo.create_milestone(title='New Milestone', state='open', description='Milestone description')
Milestone(number=1)

0 comments on commit 228e5e8

Please sign in to comment.