Skip to content

Commit 2f70890

Browse files
kianmengteamon
authored andcommitted
Misc doc changes
List of changes: - Bump license year - Use common source url - Fix typos - Fix markdown - Add release changelog to readme - Add hexdocs badge - Use and set ex_doc to latest version - Update gitignore
1 parent 13e58ac commit 2f70890

30 files changed

+229
-159
lines changed

.gitignore

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
1-
/_build
2-
/deps
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# If you run "mix test --cover", coverage assets end up here.
5+
/cover/
6+
7+
# The directory Mix downloads your dependencies sources to.
8+
/deps/
9+
10+
# Where third-party dependencies like ExDoc output generated docs.
11+
/doc/
12+
13+
# If the VM crashes, it generates a dump, let's ignore it too.
314
erl_crash.dump
15+
16+
# Also ignore archive artifacts (built via "mix archive.build").
417
*.ez
5-
/doc
6-
/cover
7-
.tool-versions
8-
/sandbox
9-
.elixir_ls
18+
19+
# Ignore package tarball (built via "mix hex.build").
20+
tesla-*.tar
21+
22+
# Temporary files for e.g. tests
23+
/tmp

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2020 Tymon Tobolski
3+
Copyright (c) 2015-2021 Tymon Tobolski
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+25-25
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build Status](https://github.com/teamon/tesla/workflows/Test/badge.svg?branch=master)](https://github.com/teamon/tesla/actions)
44
[![Hex.pm](https://img.shields.io/hexpm/v/tesla.svg)](http://hex.pm/packages/tesla)
5+
[![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/tesla/)
56
[![Hex.pm](https://img.shields.io/hexpm/dt/tesla.svg)](https://hex.pm/packages/tesla)
67
[![Hex.pm](https://img.shields.io/hexpm/dw/tesla.svg)](https://hex.pm/packages/tesla)
78
[![codecov](https://codecov.io/gh/teamon/tesla/branch/master/graph/badge.svg)](https://codecov.io/gh/teamon/tesla)
@@ -14,11 +15,7 @@ It embraces the concept of middleware when processing the request/response cycle
1415
released version on Hex. See [the documentation](http://hexdocs.pm/tesla) for
1516
the documentation of the version you're using.
1617

17-
---
18-
19-
## [`0.x` to `1.0` Migration Guide](https://github.com/teamon/tesla/wiki/0.x-to-1.0-Migration-Guide)
20-
21-
[Documentation for 0.x branch](https://github.com/teamon/tesla/tree/0.x)
18+
For the list of changes, checkout the latest [release notes](https://github.com/teamon/tesla/releases).
2219

2320
---
2421

@@ -59,7 +56,7 @@ See below for documentation.
5956

6057
## Installation
6158

62-
Add `tesla` as dependency in `mix.exs`:
59+
Add `:tesla` as dependency in `mix.exs`:
6360

6461
```elixir
6562
defp deps do
@@ -73,7 +70,6 @@ defp deps do
7370
{:jason, ">= 1.0.0"}
7471
]
7572
end
76-
7773
```
7874

7975
Tesla uses [Semantic Versioning](https://semver.org) 2.0.
@@ -115,17 +111,17 @@ This is very similar to how [Plug Router](https://github.com/elixir-plug/plug#th
115111
- [`Tesla.Middleware.Headers`](https://hexdocs.pm/tesla/Tesla.Middleware.Headers.html) - set request headers
116112
- [`Tesla.Middleware.Query`](https://hexdocs.pm/tesla/Tesla.Middleware.Query.html) - set query parameters
117113
- [`Tesla.Middleware.Opts`](https://hexdocs.pm/tesla/Tesla.Middleware.Opts.html) - set request options
118-
- [`Tesla.Middleware.FollowRedirects`](https://hexdocs.pm/tesla/Tesla.Middleware.FollowRedirects.html) - follow 3xx redirects
119-
- [`Tesla.Middleware.MethodOverride`](https://hexdocs.pm/tesla/Tesla.Middleware.MethodOverride.html) - set X-Http-Method-Override
120-
- [`Tesla.Middleware.Logger`](https://hexdocs.pm/tesla/Tesla.Middleware.Logger.html) - log requests (method, url, status, time)
121-
- [`Tesla.Middleware.KeepRequest`](https://hexdocs.pm/tesla/Tesla.Middleware.KeepRequest.html) - keep request body & headers
114+
- [`Tesla.Middleware.FollowRedirects`](https://hexdocs.pm/tesla/Tesla.Middleware.FollowRedirects.html) - follow HTTP 3xx redirects
115+
- [`Tesla.Middleware.MethodOverride`](https://hexdocs.pm/tesla/Tesla.Middleware.MethodOverride.html) - set `X-Http-Method-Override` header
116+
- [`Tesla.Middleware.Logger`](https://hexdocs.pm/tesla/Tesla.Middleware.Logger.html) - log requests (method, url, status, and time)
117+
- [`Tesla.Middleware.KeepRequest`](https://hexdocs.pm/tesla/Tesla.Middleware.KeepRequest.html) - keep request `body` and `headers`
122118
- [`Tesla.Middleware.PathParams`](https://hexdocs.pm/tesla/Tesla.Middleware.PathParams.html) - use templated URLs
123119

124120
### Formats
125121

126122
- [`Tesla.Middleware.FormUrlencoded`](https://hexdocs.pm/tesla/Tesla.Middleware.FormUrlencoded.html) - urlencode POST body, useful for POSTing a map/keyword list
127123
- [`Tesla.Middleware.JSON`](https://hexdocs.pm/tesla/Tesla.Middleware.JSON.html) - JSON request/response body
128-
- [`Tesla.Middleware.Compression`](https://hexdocs.pm/tesla/Tesla.Middleware.Compression.html) - gzip & deflate
124+
- [`Tesla.Middleware.Compression`](https://hexdocs.pm/tesla/Tesla.Middleware.Compression.html) - `gzip` and `deflate`
129125
- [`Tesla.Middleware.DecodeRels`](https://hexdocs.pm/tesla/Tesla.Middleware.DecodeRels.html) - decode `Link` header into `opts[:rels]` field in response
130126

131127
### Auth
@@ -141,7 +137,7 @@ This is very similar to how [Plug Router](https://github.com/elixir-plug/plug#th
141137

142138
## Runtime middleware
143139

144-
All HTTP functions (`get`, `post`, etc.) can take a dynamic client as the first argument.
140+
All HTTP functions, such as `Tesla.get/3` and `Tesla.post/4`, can take a dynamic client as the first argument.
145141
This allow to use convenient syntax for modifying the behaviour in runtime.
146142

147143
Consider the following case: GitHub API can be accessed using OAuth token authorization.
@@ -196,13 +192,14 @@ Tesla supports multiple HTTP adapter that do the actual HTTP request processing.
196192
- [`Tesla.Adapter.Mint`](https://hexdocs.pm/tesla/Tesla.Adapter.Mint.html) - [mint](https://github.com/elixir-mint/mint), "Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2"
197193
- [`Tesla.Adapter.Finch`](https://hexdocs.pm/tesla/Tesla.Adapter.Finch.html) - [finch](https://github.com/keathley/finch), "An HTTP client with a focus on performance, built on top of [Mint](https://github.com/elixir-mint/mint) and [NimblePool](https://github.com/dashbitco/nimble_pool)."
198194

199-
When using adapter other than httpc remember to add it to the dependencies list in `mix.exs`
195+
When using adapter other than `:httpc` remember to add it to the dependencies list in `mix.exs`
200196

201197
```elixir
202198
defp deps do
203-
[{:tesla, "~> 1.4.0"},
204-
{:jason, ">= 1.0.0"}, # optional, required by JSON middleware
205-
{:hackney, "~> 1.10"}] # or :gun etc.
199+
[
200+
{:tesla, "~> 1.4.0"},
201+
{:hackney, "~> 1.10"} # when using hackney adapter
202+
]
206203
end
207204
```
208205

@@ -230,7 +227,7 @@ def new(...) do
230227
end
231228
```
232229

233-
Passing directly to `get`/`post`/etc.
230+
Passing directly to request functions such as `MyClient.get/3` or `Tesla.get/3`.
234231

235232
```elixir
236233
MyClient.get("/", opts: [adapter: [recv_timeout: 30_000]])
@@ -255,11 +252,11 @@ defmodule ElasticSearch do
255252
end
256253
```
257254

258-
Each piece of stream will be encoded as JSON and sent as a new line (conforming to JSON stream format)
255+
Each piece of stream will be encoded as JSON and sent as a new line (conforming to JSON stream format).
259256

260257
## Multipart
261258

262-
You can pass a `Tesla.Multipart` struct as the body.
259+
You can pass a `Tesla.Multipart` struct as the body:
263260

264261
```elixir
265262
alias Tesla.Multipart
@@ -280,7 +277,7 @@ mp =
280277

281278
## Testing
282279

283-
You can set the adapter to `Tesla.Mock` in tests.
280+
You can set the adapter to `Tesla.Mock` in tests:
284281

285282
```elixir
286283
# config/test.exs
@@ -320,8 +317,7 @@ end
320317

321318
## Writing middleware
322319

323-
A Tesla middleware is a module with `c:Tesla.Middleware.call/3` function, that at some point calls `Tesla.run/2` with `env` and `next` to process
324-
the rest of stack.
320+
A Tesla middleware is a module with `c:Tesla.Middleware.call/3` function, that at some point calls `Tesla.run/2` with `env` and `next` to process the rest of stack.
325321

326322
```elixir
327323
defmodule MyMiddleware do
@@ -384,7 +380,7 @@ defmodule Tesla.Middleware.SomeMiddleware do
384380
Longer description, including e.g. additional dependencies.
385381
386382
387-
### Example usage
383+
### Examples
388384
389385
```
390386
defmodule MyClient do
@@ -503,6 +499,10 @@ defmodule Tesla.Middleware.MyCustomMiddleware do
503499
end
504500
```
505501

502+
## [`0.x` to `1.0` Migration Guide](https://github.com/teamon/tesla/wiki/0.x-to-1.0-Migration-Guide)
503+
504+
[Documentation for 0.x branch](https://github.com/teamon/tesla/tree/0.x)
505+
506506
## Contributing
507507

508508
1. Fork it (https://github.com/teamon/tesla/fork)
@@ -515,7 +515,7 @@ end
515515

516516
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details
517517

518-
Copyright (c) 2015-2020 [Tymon Tobolski](https://teamon.me/about/)
518+
Copyright (c) 2015-2021 [Tymon Tobolski](https://teamon.me/about/)
519519

520520
---
521521

lib/tesla.ex

+13-12
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666

6767
defmodule Tesla.Middleware do
6868
@moduledoc """
69-
The middleware specification
69+
The middleware specification.
7070
7171
Middleware is an extension of basic `Tesla` functionality. It is a module that must
7272
implement `c:Tesla.Middleware.call/3`.
@@ -77,7 +77,7 @@ defmodule Tesla.Middleware do
7777
7878
plug Tesla.Middleware.BaseUrl, "https://example.com"
7979
80-
or inside tuple in case of dynamic middleware (`Tesla.client/1`)
80+
or inside tuple in case of dynamic middleware (`Tesla.client/1`):
8181
8282
Tesla.client([{Tesla.Middleware.BaseUrl, "https://example.com"}])
8383
@@ -87,7 +87,7 @@ defmodule Tesla.Middleware do
8787
8888
See `c:Tesla.Middleware.call/3` for details.
8989
90-
### Example
90+
### Examples
9191
9292
defmodule MyProject.InspectHeadersMiddleware do
9393
@behaviour Tesla.Middleware
@@ -138,7 +138,7 @@ defmodule Tesla.Adapter do
138138
139139
See `c:Tesla.Adapter.call/2` for details.
140140
141-
### Example
141+
### Examples
142142
143143
defmodule MyProject.CustomAdapter do
144144
alias Tesla.Multipart
@@ -215,18 +215,19 @@ defmodule Tesla do
215215
@default_adapter Tesla.Adapter.Httpc
216216

217217
@moduledoc """
218-
A HTTP toolkit for building API clients using middlewares
218+
A HTTP toolkit for building API clients using middlewares.
219219
220220
## Building API client
221221
222-
`use Tesla` macro will generate basic http functions (e.g. get, post) inside your module.
222+
`use Tesla` macro will generate basic HTTP functions (e.g. `get/3`, `post/4`, etc.) inside your module.
223+
223224
It supports following options:
224225
225226
- `:only` - builder will generate only functions included in the given list
226227
- `:except` - builder will not generate the functions that are listed in the options
227228
- `:docs` - when set to false builder will not add documentation to generated functions
228229
229-
### Example
230+
### Examples
230231
231232
defmodule ExampleApi do
232233
use Tesla, only: [:get], docs: false
@@ -277,16 +278,16 @@ defmodule Tesla do
277278
end
278279
end
279280
280-
call to `ExampleApi.fetch_data/0` will fail, because request will be missing base url.
281+
call to `ExampleApi.fetch_data/0` will fail, because request will be missing base URL.
281282
282283
## Default adapter
283284
284285
By default `Tesla` is using `Tesla.Adapter.Httpc`, because `:httpc` is included in Erlang/OTP and
285-
doen not require installation of any additional dependency. It can be changed globally with config
286+
does not require installation of any additional dependency. It can be changed globally with config:
286287
287288
config :tesla, :adapter, Tesla.Adapter.Hackney
288289
289-
or by `Tesla.Builder.adapter/2` macro for given API client module
290+
or by `Tesla.Builder.adapter/2` macro for given API client module:
290291
291292
defmodule ExampleApi do
292293
use Tesla
@@ -380,7 +381,7 @@ defmodule Tesla do
380381
381382
Useful when there's need to store additional middleware data in `Tesla.Env`
382383
383-
## Example
384+
## Examples
384385
385386
iex> %Tesla.Env{opts: []} |> Tesla.put_opt(:option, "value")
386387
%Tesla.Env{opts: [option: "value"]}
@@ -509,7 +510,7 @@ defmodule Tesla do
509510
510511
Useful when you need to create an URL with dynamic query params from a Keyword list
511512
512-
## Example
513+
## Examples
513514
514515
iex> Tesla.build_url("http://api.example.com", [user: 3, page: 2])
515516
"http://api.example.com?user=3&page=2"

lib/tesla/adapter/finch.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if Code.ensure_loaded?(Finch) do
1111
mix compile
1212
```
1313
14-
## Example usage
14+
## Examples
1515
1616
In order to use Finch, you must start it and provide a `:name`. For example,
1717
in your supervision tree:
@@ -43,10 +43,10 @@ if Code.ensure_loaded?(Finch) do
4343
## [Finch options](https://hexdocs.pm/finch/Finch.html#request/3)
4444
4545
* `:pool_timeout` - This timeout is applied when a connection is checekd
46-
out from the pool. Default value is `5_000`.
46+
out from the pool. Default value is `5_000`.
4747
4848
* `:receive_timeout` - The maximum time to wait for a response before
49-
returning an error. Default value is `15_000`.
49+
returning an error. Default value is `15_000`.
5050
5151
"""
5252
@behaviour Tesla.Adapter

0 commit comments

Comments
 (0)