Skip to content

Commit f79ecd0

Browse files
committed
Show example of separate display of the response for inline sources
1 parent 833ea08 commit f79ecd0

2 files changed

Lines changed: 132 additions & 9 deletions

File tree

docs/index.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ The following example is of external sources.
5151
5252
To display the response outside of the tabbed interface, then don't include it in the ``http:example`` directive, but instead list it separately.
5353

54-
.. note::
55-
Currently only external sources support a separate display of the HTTP response.
56-
The users of sphinxcontrib.httpexample would appreciate a contribution to add this feature as indicated in `issue 120 <https://github.com/collective/sphinxcontrib-httpexample/issues/120>`_.
54+
For inline sources, use ``code-block`` with the ``http-response`` lexer.
5755

58-
For external sources, use ``literalinclude`` with the ``http`` lexer.
56+
.. code-block:: rst
57+
58+
.. http:example:: space separated list of tools
59+
A required inline source of a raw plain text HTTP request example.
60+
This is required.
61+
62+
.. code-block:: http
63+
An optional inline source of a raw plain text HTTP response example.
64+
65+
For external sources, use ``literalinclude`` with either the ``http`` or ``http-response`` lexer.
5966

6067
.. code-block:: rst
6168

docs/usage.rst

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,123 @@ Result
241241
}
242242

243243

244+
Separate response
245+
^^^^^^^^^^^^^^^^^
246+
247+
The following example is exactly the same as the previous one, except the response is displayed separately from the tabbed interface in its own block.
248+
249+
For inline sources, use ``code-block`` with the ``http-response`` lexer.
250+
251+
Markup
252+
``````
253+
254+
.. code-block:: rst
255+
256+
.. http:example:: curl wget httpie requests plone-client
257+
258+
GET /Plone/front-page HTTP/1.1
259+
Host: localhost:8080
260+
Accept: application/json
261+
Authorization: Basic YWRtaW46YWRtaW4=
262+
263+
.. code-block:: http-response
264+
265+
HTTP 200 OK
266+
Content-Type: application/json
267+
268+
{
269+
"@id": "http://localhost:8080/Plone/front-page",
270+
"@type": "Document",
271+
"UID": "1f699ffa110e45afb1ba502f75f7ec33",
272+
"allow_discussion": null,
273+
"changeNote": "",
274+
"contributors": [],
275+
"created": "2016-01-21T01:14:48+00:00",
276+
"creators": [
277+
"test_user_1_",
278+
"admin"
279+
],
280+
"description": "Congratulations! You have successfully installed Plone.",
281+
"effective": null,
282+
"exclude_from_nav": false,
283+
"expires": null,
284+
"id": "front-page",
285+
"language": "",
286+
"modified": "2016-01-21T01:24:11+00:00",
287+
"parent": {
288+
"@id": "http://localhost:8080/Plone",
289+
"@type": "Plone Site",
290+
"description": "",
291+
"title": "Plone site"
292+
},
293+
"relatedItems": [],
294+
"review_state": "private",
295+
"rights": "",
296+
"subjects": [],
297+
"table_of_contents": null,
298+
"text": {
299+
"content-type": "text/plain",
300+
"data": "If you're seeing this instead of the web site you were expecting, the owner of this web site has just installed Plone. Do not contact the Plone Team or the Plone mailing lists about this.",
301+
"encoding": "utf-8"
302+
},
303+
"title": "Welcome to Plone"
304+
}
305+
306+
307+
Result
308+
``````
309+
310+
.. http:example:: curl wget httpie requests plone-client
311+
312+
GET /Plone/front-page HTTP/1.1
313+
Host: localhost:8080
314+
Accept: application/json
315+
Authorization: Basic YWRtaW46YWRtaW4=
316+
317+
.. code-block:: http-response
318+
319+
HTTP 200 OK
320+
Content-Type: application/json
321+
322+
{
323+
"@id": "http://localhost:8080/Plone/front-page",
324+
"@type": "Document",
325+
"UID": "1f699ffa110e45afb1ba502f75f7ec33",
326+
"allow_discussion": null,
327+
"changeNote": "",
328+
"contributors": [],
329+
"created": "2016-01-21T01:14:48+00:00",
330+
"creators": [
331+
"test_user_1_",
332+
"admin"
333+
],
334+
"description": "Congratulations! You have successfully installed Plone.",
335+
"effective": null,
336+
"exclude_from_nav": false,
337+
"expires": null,
338+
"id": "front-page",
339+
"language": "",
340+
"modified": "2016-01-21T01:24:11+00:00",
341+
"parent": {
342+
"@id": "http://localhost:8080/Plone",
343+
"@type": "Plone Site",
344+
"description": "",
345+
"title": "Plone site"
346+
},
347+
"relatedItems": [],
348+
"review_state": "private",
349+
"rights": "",
350+
"subjects": [],
351+
"table_of_contents": null,
352+
"text": {
353+
"content-type": "text/plain",
354+
"data": "If you're seeing this instead of the web site you were expecting, the owner of this web site has just installed Plone. Do not contact the Plone Team or the Plone mailing lists about this.",
355+
"encoding": "utf-8"
356+
},
357+
"title": "Welcome to Plone"
358+
}
359+
360+
244361
HTTP ``POST``
245362
^^^^^^^^^^^^^
246363

@@ -409,9 +526,8 @@ Separate response
409526
^^^^^^^^^^^^^^^^^
410527
The following example is exactly the same as the previous one, except the HTTP response is displayed separately from the tabbed interface.
411528

412-
.. note::
413-
Currently only external sources support a separate display of the HTTP response.
414-
The users of sphinxcontrib.httpexample would appreciate a contribution to add this feature as indicated in `issue 120 <https://github.com/collective/sphinxcontrib-httpexample/issues/120>`_.
529+
For external sources, use ``literalinclude`` with either the ``http`` or ``http-response`` lexer.
530+
415531

416532
Markup
417533
``````
@@ -422,7 +538,7 @@ Markup
422538
:request: ../tests/fixtures/001.request.txt
423539
424540
.. literalinclude:: ../tests/fixtures/001.response.txt
425-
:language: http
541+
:language: http-response
426542
427543
Result
428544
``````
@@ -431,7 +547,7 @@ Result
431547
:request: ../tests/fixtures/001.request.txt
432548

433549
.. literalinclude:: ../tests/fixtures/001.response.txt
434-
:language: http
550+
:language: http-response
435551

436552

437553
HTTP ``POST``

0 commit comments

Comments
 (0)