Skip to content

Commit 14336c2

Browse files
maciej-szlosarczykbenoitc
authored andcommitted
Reformat documentation for hackney_url (#572)
A couple of things that I did here: * Always use URL in place of url or Url. * Use `an` article when referring to URL. * Add link under normalize to pathencode. * End a few sentences with a full stop, start with a capital letter.
1 parent 3e4e49d commit 14336c2

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

doc/hackney_url.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* [Function Index](#index)
77
* [Function Details](#functions)
88

9-
module to manage urls.
9+
module to manage URLs.
1010

1111
<a name="types"></a>
1212

@@ -37,10 +37,8 @@ qs_vals() = [{binary(), binary() | true}]
3737
## Function Index ##
3838

3939

40-
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#fix_path-1">fix_path/1</a></td><td></td></tr><tr><td valign="top"><a href="#idnconvert_hostname-1">idnconvert_hostname/1</a></td><td></td></tr><tr><td valign="top"><a href="#make_url-3">make_url/3</a></td><td> construct an url from a base url, a path and a list of
41-
properties to give to the url.</td></tr><tr><td valign="top"><a href="#normalize-1">normalize/1</a></td><td>Normalizes the encoding of a Url
42-
use the hackney_url:pathencode/1 to encode an url.</td></tr><tr><td valign="top"><a href="#normalize-2">normalize/2</a></td><td>Normalizes the encoding of a Url.</td></tr><tr><td valign="top"><a href="#parse_qs-1">parse_qs/1</a></td><td></td></tr><tr><td valign="top"><a href="#parse_url-1">parse_url/1</a></td><td>Parse an url and return a #hackney_url record.</td></tr><tr><td valign="top"><a href="#pathencode-1">pathencode/1</a></td><td>encode a URL path.</td></tr><tr><td valign="top"><a href="#qs-1">qs/1</a></td><td>encode query properties to binary.</td></tr><tr><td valign="top"><a href="#qs-2">qs/2</a></td><td>encode query properties to binary
43-
Opts are passed to urlencode.</td></tr><tr><td valign="top"><a href="#transport_scheme-1">transport_scheme/1</a></td><td></td></tr><tr><td valign="top"><a href="#unparse_url-1">unparse_url/1</a></td><td></td></tr><tr><td valign="top"><a href="#urldecode-1">urldecode/1</a></td><td>Decode a URL encoded binary.</td></tr><tr><td valign="top"><a href="#urldecode-2">urldecode/2</a></td><td>Decode a URL encoded binary.</td></tr><tr><td valign="top"><a href="#urlencode-1">urlencode/1</a></td><td>URL encode a string binary.</td></tr><tr><td valign="top"><a href="#urlencode-2">urlencode/2</a></td><td>URL encode a string binary.</td></tr></table>
40+
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#fix_path-1">fix_path/1</a></td><td></td></tr><tr><td valign="top"><a href="#idnconvert_hostname-1">idnconvert_hostname/1</a></td><td></td></tr><tr><td valign="top"><a href="#make_url-3">make_url/3</a></td><td>Construct an URL from a base URL, a path and a list of
41+
properties to give to the URL.</td></tr><tr><td valign="top"><a href="#normalize-1">normalize/1</a></td><td>Normalizes the encoding of an URL.</td></tr><tr><td valign="top"><a href="#normalize-2">normalize/2</a></td><td>Normalizes the encoding of an URL.</td></tr><tr><td valign="top"><a href="#parse_qs-1">parse_qs/1</a></td><td></td></tr><tr><td valign="top"><a href="#parse_url-1">parse_url/1</a></td><td>Parse an URL and return a #hackney_url record.</td></tr><tr><td valign="top"><a href="#pathencode-1">pathencode/1</a></td><td>Encode an URL path.</td></tr><tr><td valign="top"><a href="#qs-1">qs/1</a></td><td>Encode query properties to binary.</td></tr><tr><td valign="top"><a href="#qs-2">qs/2</a></td><td>Encode query properties to binary.</td></tr><tr><td valign="top"><a href="#transport_scheme-1">transport_scheme/1</a></td><td></td></tr><tr><td valign="top"><a href="#unparse_url-1">unparse_url/1</a></td><td></td></tr><tr><td valign="top"><a href="#urldecode-1">urldecode/1</a></td><td>Decode an URL encoded binary.</td></tr><tr><td valign="top"><a href="#urldecode-2">urldecode/2</a></td><td>Decode an URL encoded binary.</td></tr><tr><td valign="top"><a href="#urlencode-1">urlencode/1</a></td><td>URL encode a string binary.</td></tr><tr><td valign="top"><a href="#urlencode-2">urlencode/2</a></td><td>URL encode a string binary.</td></tr></table>
4442

4543

4644
<a name="functions"></a>
@@ -68,8 +66,8 @@ make_url(Url::binary(), Path::binary() | [binary()], Query::binary() | <a href="
6866
</code></pre>
6967
<br />
7068

71-
construct an url from a base url, a path and a list of
72-
properties to give to the url.
69+
Construct an URL from a base URL, a path and a list of
70+
properties to give to the URL.
7371

7472
<a name="normalize-1"></a>
7573

@@ -81,8 +79,8 @@ normalize(URL) -&gt; NormalizedUrl
8179

8280
<ul class="definitions"><li><code>URL = binary() | list() | <a href="#type-hackney_url">hackney_url()</a></code></li><li><code>NormalizedUrl = <a href="#type-hackney_url">hackney_url()</a></code></li></ul>
8381

84-
Normalizes the encoding of a Url
85-
use the hackney_url:pathencode/1 to encode an url
82+
Normalizes the encoding of an URL.
83+
Use the [`hackney_url:pathencode/1`](hackney_url.md#pathencode-1) to encode an URL.
8684

8785
<a name="normalize-2"></a>
8886

@@ -94,7 +92,7 @@ normalize(URL, Fun) -&gt; NormalizedUrl
9492

9593
<ul class="definitions"><li><code>URL = binary() | list() | <a href="#type-hackney_url">hackney_url()</a></code></li><li><code>Fun = function()</code></li><li><code>NormalizedUrl = <a href="#type-hackney_url">hackney_url()</a></code></li></ul>
9694

97-
Normalizes the encoding of a Url
95+
Normalizes the encoding of an URL.
9896

9997
<a name="parse_qs-1"></a>
10098

@@ -114,7 +112,7 @@ parse_url(URL::binary() | list()) -&gt; <a href="#type-hackney_url">hackney_url(
114112
</code></pre>
115113
<br />
116114

117-
Parse an url and return a #hackney_url record.
115+
Parse an URL and return a #hackney_url record.
118116

119117
<a name="pathencode-1"></a>
120118

@@ -127,7 +125,7 @@ pathencode(Bin::binary()) -&gt; binary()
127125

128126
Equivalent to [`pathencode(Bin, [])`](#pathencode-2).
129127

130-
encode a URL path
128+
Encode an URL path.
131129

132130
<a name="qs-1"></a>
133131

@@ -138,7 +136,7 @@ qs(KVs::<a href="#type-qs_vals">qs_vals()</a>) -&gt; binary()
138136
</code></pre>
139137
<br />
140138

141-
encode query properties to binary
139+
Encode query properties to binary.
142140

143141
<a name="qs-2"></a>
144142

@@ -149,8 +147,8 @@ qs(KVs::<a href="#type-qs_vals">qs_vals()</a>, Opts::[<a href="#type-qs_opt">qs_
149147
</code></pre>
150148
<br />
151149

152-
encode query properties to binary
153-
Opts are passed to urlencode.
150+
Encode query properties to binary.
151+
Opts are passed to [`urlencode/2`](#urlencode-2)
154152

155153
<a name="transport_scheme-1"></a>
156154

@@ -175,7 +173,7 @@ urldecode(Bin::binary()) -&gt; binary()
175173

176174
Equivalent to [`urldecode(Bin, crash)`](#urldecode-2).
177175

178-
Decode a URL encoded binary.
176+
Decode an URL encoded binary.
179177

180178
<a name="urldecode-2"></a>
181179

@@ -186,7 +184,7 @@ urldecode(Bin::binary(), OnError::crash | skip) -&gt; binary()
186184
</code></pre>
187185
<br />
188186

189-
Decode a URL encoded binary.
187+
Decode an URL encoded binary.
190188
The second argument specifies how to handle percent characters that are not
191189
followed by two valid hex characters. Use `skip` to ignore such errors,
192190
if `crash` is used the function will fail with the reason `badarg`.

src/hackney_url.erl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
%%% Copyright (c) 2011, Magnus Klaar <[email protected]>
88
%%%
99

10-
%% @doc module to manage urls.
10+
%% @doc module to manage URLs.
1111

1212
-module(hackney_url).
1313

@@ -30,7 +30,7 @@
3030
-type qs_vals() :: [{binary(), binary() | true}].
3131
-type qs_opt() :: noplus | upper.
3232

33-
%% @doc Parse an url and return a #hackney_url record.
33+
%% @doc Parse an URL and return a #hackney_url record.
3434
-spec parse_url(URL::binary()|list()) -> hackney_url().
3535
parse_url(URL) when is_list(URL) ->
3636
case unicode:characters_to_binary(URL) of
@@ -63,15 +63,15 @@ parse_url(URL, S) ->
6363
fragment = Fragment})
6464
end.
6565

66-
%% @doc Normalizes the encoding of a Url
67-
%% use the hackney_url:pathencode/1 to encode an url
66+
%% @doc Normalizes the encoding of an URL.
67+
%% Use the {@link hackney_url:pathencode/1} to encode an URL.
6868
-spec normalize(URL) -> NormalizedUrl when
6969
URL :: binary() | list() | hackney_url(),
7070
NormalizedUrl :: hackney_url().
7171
normalize(Url) ->
7272
normalize(Url, fun hackney_url:pathencode/1).
7373

74-
%% @doc Normalizes the encoding of a Url
74+
%% @doc Normalizes the encoding of an URL.
7575
-spec normalize(URL, Fun) -> NormalizedUrl when
7676
URL :: binary() | list() | hackney_url(),
7777
Fun :: fun(),
@@ -256,13 +256,13 @@ parse_fragment(S) ->
256256
end.
257257

258258

259-
%% @doc Decode a URL encoded binary.
259+
%% @doc Decode an URL encoded binary.
260260
%% @equiv urldecode(Bin, crash)
261261
-spec urldecode(binary()) -> binary().
262262
urldecode(Bin) when is_binary(Bin) ->
263263
urldecode(Bin, <<>>, crash).
264264

265-
%% @doc Decode a URL encoded binary.
265+
%% @doc Decode an URL encoded binary.
266266
%% The second argument specifies how to handle percent characters that are not
267267
%% followed by two valid hex characters. Use `skip' to ignore such errors,
268268
%% if `crash' is used the function will fail with the reason `badarg'.
@@ -341,7 +341,7 @@ tohexl(C) when C < 10 -> $0 + C;
341341
tohexl(C) when C < 16 -> $a + C - 10.
342342

343343

344-
%% parse a query or a form from a binary and return a list of properties
344+
%% Parse a query or a form from a binary and return a list of properties.
345345
-spec parse_qs(binary()) -> qs_vals().
346346
parse_qs(<<>>) ->
347347
[];
@@ -355,13 +355,13 @@ parse_qs(Bin) ->
355355
end || Token <- Tokens].
356356

357357

358-
%% @doc encode query properties to binary
358+
%% @doc Encode query properties to binary.
359359
-spec qs(qs_vals()) -> binary().
360360
qs(KVs) ->
361361
qs(KVs, []).
362362

363-
%% @doc encode query properties to binary
364-
%% Opts are passed to urlencode.
363+
%% @doc Encode query properties to binary.
364+
%% Opts are passed to {@link urlencode/2.}
365365
-spec qs(qs_vals(), [qs_opt()]) -> binary().
366366
qs(KVs, Opts) ->
367367
qs(KVs, Opts, []).
@@ -374,8 +374,8 @@ qs([{K, V}|R], Opts, Acc) ->
374374
Line = << K1/binary, "=", V1/binary >>,
375375
qs(R, Opts, [Line | Acc]).
376376

377-
%% @doc construct an url from a base url, a path and a list of
378-
%% properties to give to the url.
377+
%% @doc Construct an URL from a base URL, a path and a list of
378+
%% properties to give to the URL.
379379
-spec make_url(binary(), binary() | [binary()], binary() | qs_vals())
380380
-> binary().
381381
make_url(Url, Path, Query) when is_list(Query) ->
@@ -409,7 +409,7 @@ fix_path(Path) ->
409409
_ -> Path
410410
end.
411411

412-
%% @doc encode a URL path
412+
%% @doc Encode an URL path.
413413
%% @equiv pathencode(Bin, [])
414414
-spec pathencode(binary()) -> binary().
415415
pathencode(Bin) ->

0 commit comments

Comments
 (0)