github3.py
github3.py copied to clipboard
Support for fetching README rendered as HTML
The Github API supports fetching a repository's README rendered as HTML, i.e. as displayed in the Github web interface. This feature is described here Contents: custom media types. In fact that seems to work for any file although I haven't actually tested this.
With a bit of trickery this is already possible with github3.py,
import github3
repo = github3.repository('sigmavirus24', 'github3.py')
# Here come the clever bits
repo._session.headers['Accept'] = 'application/vnd.github.v3.html'
url = repo._build_url('readme', base_url=repo._api)
response = repo._get(url)
print response.content
# Don't forget to reset the header!!!
repo._session.headers['Accept'] = 'application/vnd.github.v3.full+json'
This could be added to the API by either
- Adding a
Repository.readme_as_html()method, or - Adding a
format="html"argument toRepository.readme()andRepository.contents()methods.
Any thoughts?
Markus
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Interesting .full used to retrieve plain-text, raw, and html formatted bodies. It's disappointing that they silently broke this