-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Establish basis for examples #762
Conversation
This is a good start! I will review in a bit, got busy recently. |
This contribution may be better off in a tutorials sections. Curious to know what you think about it. Thanks for reviewing when you have a chance!
Add Getting Started with API Key
Hi @sfdye - would love to have your feedback on these first examples. What do you think? |
|
||
In the code snippet above, we import the ``Github`` class from pyGitHub and also import Python's ``os`` package. The ``os`` package gives us a way to pull in the GitHub API key that the computer can now see after sourcing ``secrets.sh``. We then pass the API key in as an argument when creating a new ``Github`` instance called ``g``. From here, we can call `any of the methods that are associated with the Github object <http://pygithub.readthedocs.io/en/latest/github.html>`_ on **our** instance, ``g``. For example, we can call `the get_user() method <http://pygithub.readthedocs.io/en/latest/github.html#github.MainClass.Github.get_user>`_ which returns a `NamedUser object <http://pygithub.readthedocs.io/en/latest/github_objects/NamedUser.html#github.NamedUser.NamedUser>`_, which itself gives us access to attributes like the user's avatar URL, bio, company, email, etc. | ||
|
||
.. codeblock:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this code snippet is not being properly formatted.
|
||
(4) Next, create a new file in your project directory that will hold your code. In this example we'll call it ``try_pygithub.py``. Copy and paste this code into ``try_pygithub.py``. Be sure to read the explanation that follows. | ||
|
||
.. codeblock:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Thanks very much for putting these together. As a general guideline, the examples should be generic enough to accommodate a variety of audiences, and should also conform to some standards. (like variable naming convention and coding style, etc). I suggest we can follow the Python community practice by using |
If you are looking for some inspiration, boto from aws is a good reference. Read the docs: https://boto3.readthedocs.io/en/latest/guide/examples.html |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Sorry stale bot had to close this PR. Now with #874 , we can probably port some of the examples over. What do you think? @BarbourSmith |
Yes! No worries on the stale bot, we do the same things on our projects. How do we feel about me making separate pull requests for specific examples once #875 has created the place for them. I would love a second set of eyes on each example I propose because I'm a little rusty now |
@BarbourSmith That sounds awesome. |
The pyGithub documentation is excellent, but interacting with the Github api for the first time can be confusing without any examples.
There have been a number of requests for more examples of how to use PyGithub.
This pull request establishes an examples.rst file which serves as a place for the community to contribute examples.
The examples file starts off with some from @pconrad showing off the basic use of PyGithub and some from me showing how to interact with pull requests as issues.
This pull request is an attempt to begin to address issue #321