@@ -124,7 +124,8 @@ defmodule Req.Request do
124124
125125 ### Request Steps
126126
127- A **request step** is a function that accepts a `request` and returns one of the following:
127+ A **request step** (`t:request_step/0`) is a function that accepts a `request` and returns one
128+ of the following:
128129
129130 * A `request`.
130131
@@ -152,8 +153,8 @@ defmodule Req.Request do
152153
153154 ### Response and Error Steps
154155
155- A response step is a function that accepts a `{request, response}` tuple and returns one of the
156- following:
156+ A response step (`t:response_step/0`) is a function that accepts a `{request, response}` tuple
157+ and returns one of the following:
157158
158159 * A `{request, response}` tuple.
159160
@@ -368,9 +369,49 @@ defmodule Req.Request do
368369 private: map ( )
369370 }
370371
371- @ typep request_step ( ) :: fun ( ) | { module ( ) , atom ( ) , [ term ( ) ] }
372- @ typep response_step ( ) :: fun ( ) | { module ( ) , atom ( ) , [ term ( ) ] }
373- @ typep error_step ( ) :: fun ( ) | { module ( ) , atom ( ) , [ term ( ) ] }
372+ @ typedoc """
373+ A request step is a function that takes a request and returns a request or a tuple of request
374+ and response/exception.
375+
376+ The function can be an anonymous function, or a `{module, function, args}` tuple. In the latter
377+ case, the step is invoked as `apply(module, function, [request | args])`.
378+
379+ See also the ["Request Steps"](#module-request-steps) section in the module documentation.
380+ """
381+ @ typedoc since: "0.6.0"
382+ @ type request_step ( ) ::
383+ ( t ( ) -> t ( ) | { t ( ) , Req.Response . t ( ) | Exception . t ( ) } ) | { module ( ) , atom ( ) , [ term ( ) ] }
384+
385+ @ typedoc """
386+ A response step is a function that takes a request/response tuple and returns a request/response
387+ or a request/exception tuple.
388+
389+ The function can be an anonymous function, or a `{module, function, args}` tuple. In the latter
390+ case, the step is invoked as `apply(module, function, [request | args])`.
391+
392+ See also the ["Response and Error Steps"](#module-response-and-error-steps) section in the
393+ module documentation.
394+ """
395+ @ typedoc since: "0.6.0"
396+ @ type response_step ( ) ::
397+ ( { t ( ) , Req.Response . t ( ) } -> { t ( ) , Req.Response . t ( ) | Exception . t ( ) } )
398+ | { module ( ) , atom ( ) , [ term ( ) ] }
399+
400+ @ typedoc """
401+ An error step is a function that takes a request/exception tuple and returns a request/response
402+ or a request/exception tuple.
403+
404+ The function can be an anonymous function, or a `{module, function, args}` tuple. In the latter
405+ case, the step is invoked as `apply(module, function, [request | args])`.
406+
407+ See also the ["Response and Error Steps"](#module-response-and-error-steps) section in the
408+ module documentation.
409+ """
410+ @ typedoc since: "0.6.0"
411+ @ type error_step ( ) ::
412+ ( { t ( ) , Exception . t ( ) } -> { t ( ) , Req.Response . t ( ) | Exception . t ( ) } )
413+ | { module ( ) , atom ( ) , [ term ( ) ] }
414+
374415 @ typep options ( ) :: term ( )
375416
376417 defstruct method: :get ,
@@ -653,7 +694,7 @@ defmodule Req.Request do
653694 inspect: &IO.inspect/1
654695 )
655696 """
656- @ spec append_request_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
697+ @ spec append_request_steps ( t ( ) , keyword ( request_step ( ) ) ) :: t ( )
657698 def append_request_steps ( request , steps ) do
658699 % {
659700 request
@@ -675,7 +716,7 @@ defmodule Req.Request do
675716 inspect: &IO.inspect/1
676717 )
677718 """
678- @ spec prepend_request_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
719+ @ spec prepend_request_steps ( t ( ) , keyword ( request_step ( ) ) ) :: t ( )
679720 def prepend_request_steps ( request , steps ) do
680721 % {
681722 request
@@ -697,7 +738,7 @@ defmodule Req.Request do
697738 inspect: &IO.inspect/1
698739 )
699740 """
700- @ spec append_response_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
741+ @ spec append_response_steps ( t ( ) , keyword ( response_step ( ) ) ) :: t ( )
701742 def append_response_steps ( request , steps ) do
702743 % {
703744 request
@@ -718,7 +759,7 @@ defmodule Req.Request do
718759 inspect: &IO.inspect/1
719760 )
720761 """
721- @ spec prepend_response_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
762+ @ spec prepend_response_steps ( t ( ) , keyword ( response_step ( ) ) ) :: t ( )
722763 def prepend_response_steps ( request , steps ) do
723764 % {
724765 request
@@ -739,7 +780,7 @@ defmodule Req.Request do
739780 inspect: &IO.inspect/1
740781 )
741782 """
742- @ spec append_error_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
783+ @ spec append_error_steps ( t ( ) , keyword ( error_step ( ) ) ) :: t ( )
743784 def append_error_steps ( request , steps ) do
744785 % {
745786 request
@@ -760,7 +801,7 @@ defmodule Req.Request do
760801 inspect: &IO.inspect/1
761802 )
762803 """
763- @ spec prepend_error_steps ( t ( ) , keyword ( fun ( ) ) ) :: t ( )
804+ @ spec prepend_error_steps ( t ( ) , keyword ( error_step ( ) ) ) :: t ( )
764805 def prepend_error_steps ( request , steps ) do
765806 % {
766807 request
0 commit comments