Skip to content

Commit 87bdc5d

Browse files
authored
Merge pull request #327 from prkumar/migrate-to-mkdocs
Migrate our docs to mkdocs
2 parents e462437 + 5681809 commit 87bdc5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4115
-3618
lines changed

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@ instance/
6161
# Scrapy stuff:
6262
.scrapy
6363

64-
# Sphinx documentation
65-
docs/source/.doctrees/
66-
docs/source/_build/
67-
docs/_build/
68-
6964
# PyBuilder
7065
target/
7166

@@ -96,7 +91,9 @@ ENV/
9691
.ropeproject
9792

9893
# mkdocs documentation
94+
/docs/changelog.md
9995
/site
96+
/site.zip
10097

10198
# mypy
10299
.mypy_cache/

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ uv sync --all-extras
2525
uv tool install pre-commit --with pre-commit-uv --force-reinstall
2626
```
2727

28-
If you are unfamiliar with [pipenv](https://docs.pipenv.org/) but are comfortable with [virtualenvs](https://virtualenv.pypa.io/en/stable/), you can alternatively run `pip install pipenv` inside the virtualenv you are already using then invoke the commands from above. This will setup your virtualenv correctly.
28+
If you are unfamiliar with [uv](https://github.com/astral-sh/uv) but are comfortable with [virtualenvs](https://virtualenv.pypa.io/en/stable/), you can alternatively run `pip install uv` inside the virtualenv you are already using then invoke the commands from above. This will setup your virtualenv correctly.
2929

3030
Before submitting a pull request, run all tests with [tox](https://tox.readthedocs.io/en/latest/):
3131

@@ -168,6 +168,4 @@ assert {"id": 123, "username": "prkumar"} == response.json()
168168

169169
## Style Guide
170170

171-
To maintain a consistent code style with the rest of Uplink, follow the [Google Python Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md).
172-
173-
Notably, we use a Sphinx plugin that can parse docstrings adherent to this style. Checkout [this page](http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for examples of Google Python Style Guide docstrings.
171+
To maintain a consistent code style with the rest of Uplink, follow the [Google Python Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md).

Pipfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,11 @@ Ready to launch your first API client with Uplink? Start with this [quick tutori
7575
- Built-in support for [Basic Authentication](https://uplink.readthedocs.io/en/latest/user/auth.html#basic-authentication)
7676
- Use existing auth libraries for supported clients (e.g., [`requests-oauthlib`](https://github.com/requests/requests-oauthlib))
7777

78-
Uplink officially supports Python 2.7 and 3.5+.
79-
80-
**Note:** Python 2.7 support will be removed in v0.10.0.
78+
Uplink officially supports Python 3.10+.
8179

8280
## Installation
8381

84-
To install the latest stable release, you can use `pip` (or `pipenv`):
82+
To install the latest stable release, you can use `pip` (or `uv`):
8583

8684
```bash
8785
pip install -U uplink
@@ -135,3 +133,4 @@ We're migrating our community from [Gitter](https://gitter.im/python-uplink/Lobb
135133

136134
Want to report a bug, request a feature, or contribute code to Uplink? Checkout the [Contribution Guide](https://github.com/prkumar/uplink/blob/master/CONTRIBUTING.md) for where to start.
137135
Thank you for taking the time to improve an open source project 💜
136+

docs/Makefile

Lines changed: 0 additions & 23 deletions
This file was deleted.

docs/api/auth.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Authentication
2+
3+
The `auth` parameter of the `Consumer` constructor offers a way to
4+
define an auth method to use for all requests.
5+
6+
``` python
7+
auth_method = SomeAuthMethod(...)
8+
github = GitHub(BASE_URL, auth=auth_method)
9+
```
10+
11+
::: uplink.auth.BasicAuth
12+
options:
13+
show_bases: false
14+
members: false
15+
inherited_members: false
16+
17+
::: uplink.auth.ProxyAuth
18+
options:
19+
show_bases: false
20+
members: false
21+
inherited_members: false
22+
23+
::: uplink.auth.BearerToken
24+
options:
25+
show_bases: false
26+
members: false
27+
inherited_members: false
28+
29+
::: uplink.auth.MultiAuth
30+
options:
31+
show_bases: false
32+
members: false
33+
inherited_members: false
34+
35+
::: uplink.auth.ApiTokenParam
36+
options:
37+
show_bases: false
38+
members: false
39+
inherited_members: false

docs/api/clients.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# HTTP Clients
2+
3+
The `client` parameter of the `Consumer` constructor offers a way
4+
to swap out Requests with another HTTP client, including those listed here:
5+
6+
```python
7+
github = GitHub(BASE_URL, client=...)
8+
```
9+
10+
## Requests
11+
12+
::: uplink.RequestsClient
13+
options:
14+
members: false
15+
inherited_members: false
16+
17+
## Aiohttp
18+
19+
::: uplink.AiohttpClient
20+
options:
21+
members: false
22+
inherited_members: false
23+
24+
## Twisted
25+
26+
::: uplink.TwistedClient
27+
options:
28+
members: false
29+
inherited_members: false

docs/api/consumer.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# The Base Consumer Class
2+
3+
## Consumer
4+
5+
::: uplink.Consumer
6+
options:
7+
members:
8+
- exceptions
9+
- session
10+
inherited_members: false
11+
12+
## Session
13+
14+
::: uplink.session.Session
15+
options:
16+
members:
17+
- auth
18+
- base_url
19+
- context
20+
- headers
21+
- inject
22+
- params

docs/api/converters.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Converters
2+
3+
The `converter` parameter of the `uplink.Consumer` constructor accepts a custom adapter class that handles serialization of HTTP request properties and deserialization of HTTP response objects:
4+
5+
```python
6+
github = GitHub(BASE_URL, converter=...)
7+
```
8+
9+
Starting with version v0.5, some out-of-the-box converters are included automatically and don't need to be explicitly provided through the `converter` parameter. These implementations are detailed below.
10+
11+
## Marshmallow
12+
13+
Uplink comes with optional support for `marshmallow`.
14+
15+
::: uplink.converters.MarshmallowConverter
16+
options:
17+
members: false
18+
inherited_members: false
19+
20+
!!! note
21+
Starting with version v0.5, this converter factory is automatically included if you have `marshmallow` installed, so you don't need to provide it when constructing your consumer instances.
22+
23+
## Pydantic
24+
25+
!!! info "New in version v0.9.2"
26+
Uplink comes with optional support for `pydantic`.
27+
28+
::: uplink.converters.PydanticConverter
29+
options:
30+
members: false
31+
inherited_members: false
32+
33+
!!! note
34+
Starting with version v0.9.2, this converter factory is automatically included if you have `pydantic` installed, so you don't need to provide it when constructing your consumer instances.
35+
36+
## Converting Collections
37+
38+
!!! info "New in version v0.5.0"
39+
Uplink can convert collections of a type, such as deserializing a response body into a list of users. If you have `typing` installed (the module is part of the standard library starting Python 3.5), you can use type hints (see [PEP 484](https://www.python.org/dev/peps/pep-0484/)) to specify such conversions. You can also leverage this feature without `typing` by using one of the proxy types defined in `uplink.types`.
40+
41+
The following converter factory implements this feature and is automatically included, so you don't need to provide it when constructing your consumer instance:
42+
43+
::: uplink.converters.TypingConverter
44+
options:
45+
members: false
46+
inherited_members: false
47+
48+
Here are the collection types defined in `uplink.types`. You can use these or the corresponding type hints from `typing` to leverage this feature:
49+
50+
::: uplink.types.List
51+
options:
52+
show_bases: false
53+
members: false
54+
inherited_members: false
55+
56+
::: uplink.types.Dict
57+
options:
58+
show_bases: false
59+
members: false
60+
inherited_members: false
61+
62+
## Writing Custom JSON Converters
63+
64+
As a shorthand, you can define custom JSON converters using the `@loads.from_json` (deserialization) and `@dumps.to_json` (serialization) decorators.
65+
66+
These classes can be used as decorators to create converters of a class and its subclasses:
67+
68+
```python
69+
# Creates a converter that can deserialize the given `json` in to an
70+
# instance of a `Model` subtype.
71+
@loads.from_json(Model)
72+
def load_model_from_json(model_type, json):
73+
...
74+
```
75+
76+
!!! note
77+
Unlike consumer methods, these functions should be defined outside of a class scope.
78+
79+
To use the converter, provide the generated converter object when instantiating a `uplink.Consumer` subclass, through the `converter` constructor parameter:
80+
81+
```python
82+
github = GitHub(BASE_URL, converter=load_model_from_json)
83+
```
84+
85+
Alternatively, you can add the `@install` decorator to register the converter function as a default converter, meaning the converter will be included automatically with any consumer instance and doesn't need to be explicitly provided through the `converter` parameter:
86+
87+
```python
88+
from uplink import install, loads
89+
90+
# Register the function as a default loader for the given model class.
91+
@install
92+
@loads.from_json(Model)
93+
def load_model_from_json(model_type, json):
94+
...
95+
```
96+
97+
::: uplink.loads
98+
options:
99+
members: ["from_json"]
100+
101+
::: uplink.dumps
102+
options:
103+
ffmembers: ["to_json"]

0 commit comments

Comments
 (0)