Skip to content

Commit 68f9153

Browse files
plexusbbatsov
authored andcommitted
Document content-type ops in mw descriptor + regenerate ops.adoc
Apply the changes to the ops documentation in the middleware descriptor, then regenerate the docs from there. Fix the location of the `:returns` map so it shows up in the docs, and change `content-type-middleware` to `content-type` to be in line with the others (none of them use a `-middleware` suffix in the descriptor).
1 parent 894d320 commit 68f9153

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

doc/modules/ROOT/pages/nrepl-api/ops.adoc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Returns::
156156
{blank}
157157

158158

159-
=== `content-type-middleware`
159+
=== `content-type`
160160

161161
Enhances the ``eval`` op by adding ``content-type`` and ``body`` to certain ``eval`` responses. Not an op in itself.
162162

@@ -171,8 +171,9 @@ Optional parameters::
171171

172172
Returns::
173173
* `:body` The rich response document, if applicable.
174-
* `:content-type` The Media type (MIME type) of the reponse, structured as a pair, `[type {:as attrs}]`
175-
* `:content-transfer-encoding` The encoding of the response body (Optional, currently only one possible value `"base64"`)
174+
* `:content-transfer-encoding` The encoding of the response body (Optional, currently only one possible value: ``"base64"``).
175+
* `:content-type` The Media type (MIME type) of the reponse, structured as a pair, ``[type {:as attrs}]``.
176+
176177

177178

178179
=== `debug-input`
@@ -928,7 +929,10 @@ Optional parameters::
928929
{blank}
929930

930931
Returns::
931-
{blank}
932+
* `:body` The slurped content body.
933+
* `:content-transfer-encoding` The encoding (if any) for the content.
934+
* `:content-type` A MIME type for the response, if one can be detected.
935+
932936

933937

934938
=== `spec-example`
@@ -973,7 +977,7 @@ Required parameters::
973977
{blank}
974978

975979
Optional parameters::
976-
* `:filter-regex` Only the specs that matches filter prefix regex will be returned
980+
* `:filter-regex` Only the specs that matches filter prefix regex will be returned
977981

978982

979983
Returns::
@@ -1199,3 +1203,4 @@ Optional parameters::
11991203

12001204
Returns::
12011205
* `:status` done
1206+

src/cider/nrepl.clj

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,22 @@
109109
{:doc "Middleware that adds `content-type` annotations to the result of the the eval op."
110110
:requires #{#'wrap-print}
111111
:expects #{"eval" "load-file"}
112-
:returns {"content-type" "A MIME type for the response, if one can be detected."
113-
"content-transfer-encoding" "The encoding (if any) of the content."
114-
"body" "The content."}
115-
:handles {"content-type-middleware"
116-
{:doc "Enhances the `eval` op by adding `content-type` and friends to some responses. Not an op in itself."
112+
:handles {"content-type"
113+
{:doc "Enhances the `eval` op by adding `content-type` and `body` to certain `eval` responses. Not an op in itself.
114+
115+
Depending on the type of the return value of the evaluation this middleware may kick in and include a representation of the result in the response, together with a MIME/Media type to indicate how it should be handled by the client. Comes with implementations for `URI`, `URL`, `File`, and `java.awt.Image`. More type handlers can be provided by the user by extending the `cider.nrepl.middleware.content-type/content-type-response` multimethod. This dispatches using `clojure.core/type`, so `:type` metadata on plain Clojure values can be used to provide custom handling."
116+
:returns {"body" "The rich response document, if applicable."
117+
"content-type" "The Media type (MIME type) of the reponse, structured as a pair, `[type {:as attrs}]`."
118+
"content-transfer-encoding" "The encoding of the response body (Optional, currently only one possible value: `\"base64\"`)."}
117119
:optional {"content-type" "If present and non-nil, try to detect and handle content-types."}}}})
118120

119121
(def-wrapper wrap-slurp cider.nrepl.middleware.slurp/handle-slurp
120122
{:doc "Middleware that handles slurp requests."
121-
:returns {"content-type" "A MIME type for the response, if one can be detected."
122-
"content-transfer-encoding" "The encoding (if any) for the content."
123-
"body" "The slurped content body."}
124123
:handles {"slurp"
125-
{:doc "Slurps a URL from the nREPL server, returning MIME data."}}})
124+
{:doc "Slurps a URL from the nREPL server, returning MIME data."
125+
:returns {"content-type" "A MIME type for the response, if one can be detected."
126+
"content-transfer-encoding" "The encoding (if any) for the content."
127+
"body" "The slurped content body."}}}})
126128

127129
(def-wrapper wrap-apropos cider.nrepl.middleware.apropos/handle-apropos
128130
{:doc "Middleware that handles apropos requests"

0 commit comments

Comments
 (0)