Skip to content

Commit 4c58f57

Browse files
committed
Add some exapmles of using the issues API.
1 parent 903f79e commit 4c58f57

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

docs/examples/issue.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Issue Code Examples
22
===================
33

4-
Examples using :class:`Issue <github3.issue.Issue>`\ s
4+
Examples using ``Issue``\ s
55

66
Administrating Issues
77
---------------------
@@ -26,3 +26,14 @@ of the issue you're concerned with in ``num``.
2626
# Assuming issue is the same as above ...
2727
issue.create_comment('This should be fixed in 6d4oe5. Closing as fixed.')
2828
issue.close()
29+
30+
The following shows how you could use github3.py to fetch and display your
31+
issues in your own style and in your webbrowser.
32+
33+
.. include:: source/browser.py
34+
:code: python
35+
36+
Or how to do the same by wrapping the lines in your terminal.
37+
38+
.. include:: source/wrap_text.py
39+
:code: python

docs/examples/source/browser.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import webbrowser
2+
import tempfile
3+
import github3
4+
5+
template = """<html><head></head><body>{0}</body></html>"""
6+
7+
i = github3.issue('kennethreitz', 'requests', 868)
8+
9+
with tempfile.NamedTemporaryFile() as tmpfd:
10+
tmpfd.write(template.format(i.body_html))
11+
webbrowser.open('file://' + tmpfd.name)

docs/examples/source/wrap_text.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import github3
2+
import textwrap
3+
4+
i = github3.issue('kennethreitz', 'requests', 868)
5+
for line in textwrap.wrap(i.body_text, 78, replace_whitespace=False):
6+
print line

0 commit comments

Comments
 (0)