Skip to content

Commit 534cc5f

Browse files
committed
Make first examples work
The examples were broken in several ways, probably due to changes in the library since they were first written: * Replacing `scheme` from 'http' to 'https' seems to also require replacing `port` to match, otherwise it is maintained as port 80 * The `click` function on the github URL (without a trailing slash) takes one to `github.com/` rather than the org URL * The URL referred to has moved, since the project was moved from `github.com/mahmoud` to `github.com/python-hyper` :) * I also thought `str()` is more natural than `to_text()`
1 parent 7ae2e09 commit 534cc5f

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ Then, hyperlink away!
3232
```python
3333
from hyperlink import URL
3434

35-
url = URL.from_text(u'http://github.com/mahmoud/hyperlink?utm_source=README')
35+
url = URL.from_text('http://github.com/python-hyper/hyperlink?utm_source=README')
3636
utm_source = url.get(u'utm_source')
37-
better_url = url.replace(scheme=u'https')
38-
user_url = better_url.click(u'..')
37+
better_url = url.replace(scheme='https', port=443)
38+
org_url = better_url.click('.')
3939
```
4040

4141
See the full API docs on [Read the Docs][docs].

docs/index.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ Then, URLs are just an import away::
4141

4242
url = URL.from_text('http://github.com/python-hyper/hyperlink?utm_souce=readthedocs')
4343

44-
better_url = url.replace(scheme='https')
45-
user_url = better_url.click('..')
44+
better_url = url.replace(scheme='https', port=443)
45+
org_url = better_url.click('.')
4646

47-
print(user_url.to_text())
48-
# prints: https://github.com/mahmoud
47+
print(str(org_url))
48+
# prints: https://github.com/python-hyper/
4949

50-
print(user_url.get('utm_source'))
50+
print(better_url.get('utm_source'))
5151
# prints: readthedocs
5252

5353
See :ref:`the API docs <hyperlink_api>` for more usage examples.

0 commit comments

Comments
 (0)