Skip to content
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

Closed
wants to merge 11 commits into from
Closed

Establish basis for examples #762

wants to merge 11 commits into from

Conversation

BarbourSmith
Copy link

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

@sfdye
Copy link
Member

sfdye commented Apr 25, 2018

This is a good start! I will review in a bit, got busy recently.

allardbrain and others added 2 commits May 13, 2018 19:45
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
@erinallard-infoscout
Copy link

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@sfdye
Copy link
Member

sfdye commented May 21, 2018

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 some_var instead of someVar, and follow PEP8 for coding style.

@sfdye
Copy link
Member

sfdye commented May 21, 2018

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
Source: https://github.com/boto/boto3/tree/develop/docs/source/guide

@stale
Copy link

stale bot commented Jul 20, 2018

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.

@sfdye
Copy link
Member

sfdye commented Aug 21, 2018

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

@BarbourSmith
Copy link
Author

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

@sfdye
Copy link
Member

sfdye commented Aug 22, 2018

@BarbourSmith That sounds awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants