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

Use async/await in the readme example #383

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
treq: High-level Twisted HTTP Client API
========================================

|pypi|_
|calver|_
|coverage|_
|documentation|_
|pypi|
Copy link
Member

Choose a reason for hiding this comment

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

I think that this is needed...as otherwise the links are not working

I was testing with https://github.com/twisted/treq/tree/382-async-await-readme?tab=readme-ov-file

see as a playground https://rsted.info.ucl.ac.be/?theme=basic&n=8fd54317743434ab9a96c339c7862241

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I was trying to get rid of the underscores GitHub shows on current trunk:

image

But actually, the links there don't work either. I'll see if I can get that working — I'm a bit rusty on reST.

Copy link
Member

Choose a reason for hiding this comment

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

It looks like a bug in GitHub... I see the same problem with twisted/twisted

For twisted/towncrier we don't use the substitution ... maybe update treq to just use the image directive

.. image:: https://img.shields.io/pypi/v/towncrier
   :alt: PyPI release
   :target: https://pypi.org/project/towncrier/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The substitution seems to work, the key is to make it a link with :target: as you suggested. I guess the link targets .. _calver: were picked up implicitly by docutils? Or maybe this never worked.

|calver|
|coverage|
|documentation|

``treq`` is an HTTP library inspired by
`requests <https://requests.readthedocs.io/>`_ but written on top of
Expand All @@ -18,15 +18,16 @@ using Twisted.

>>> import treq

>>> def done(response):
>>> async def main(reactor):
... response = await treq.get("https://github.com")
... print(response.code)
... reactor.stop()
... body = await response.text()
... print("<!DOCTYPE html>" in body)

>>> treq.get("https://github.com").addCallback(done)

>>> from twisted.internet import reactor
>>> reactor.run()
>>> from twisted.internet.task import react
>>> react(main)
200
True

For more info `read the docs <https://treq.readthedocs.org>`_.

Expand All @@ -35,7 +36,7 @@ Contributing

``treq`` development is hosted on `GitHub <https://github.com/twisted/treq>`_.

We welcome contributions: feel to fork and send contributions over.
We welcome contributions: feel free to fork and send contributions over.
See `CONTRIBUTING.rst <https://github.com/twisted/treq/blob/master/CONTRIBUTING.rst>`_ for more info.

Code of Conduct
Expand Down
Empty file added changelog.d/382.misc.rst
Empty file.
Loading