collective / sphinxcontrib-httpexample

Adds example directive for sphinx-contrib httpdomain
23 stars 20 forks source link

Add URL parameters support #35

Closed ludaavics closed 5 years ago

ludaavics commented 5 years ago

Does httpexample support specifying URL parameters (other than by writing it in the URL)?

So instead of:

..  http:example:: python-requests curl

    GET /items?from=20170101&to=20171231&user_id=12&limit=20&sort=date(asc) HTTP/1.1
        Host: localhost
        Accept: application/json
        Authorization: Basic dXNlcjpwYXNzd29yZA==

Have something along the lines of:

..  http:example:: python-requests curl

        GET /items HTTP/1.1
        Host: localhost
        Accept: application/json
        Authorization: Basic dXNlcjpwYXNzd29yZA==

        :query from: 20170101
        :query to: 20171231
        :query user_id: 12
        :query limit: 20
        :query sort:date(asc)

Besides better readability, would be helpful when including httpexamples in python docstrings (e.g. for use with sphinxcontrib.autohttp) while respecting PEP8.

I'm a newcomer to Sphinx, but happy to help where I can.

Thanks!

datakurre commented 5 years ago

There’s no such support yet, but I would not oppose it :) On 5 Oct 2018, 0.16 +0300, Ludovic Tiako notifications@github.com, wrote:

Does httpexample support specifying URL parameters (other than by writing it in the URL)? So instead of: .. http:example:: python-requests curl

GET /items?from=20170101&to=20171231&user_id=12&limit=20&sort=date(asc) HTTP/1.1 Host: localhost Accept: application/json Authorization: Basic dXNlcjpwYXNzd29yZA== Have something along the lines of: .. http:example:: python-requests curl

   GET /items HTTP/1.1
   Host: localhost
   Accept: application/json
   Authorization: Basic dXNlcjpwYXNzd29yZA==

   :query from: 20170101
   :query to: 20171231
   :query user_id: 12
   :query limit: 20
   :query sort:date(asc)

Besides better readability, would be helpful when including httpexamples in python docstrings (e.g. for use with sphinxcontrib.autohttp) while respecting PEP8. I'm a newcomer to Sphinx, but happy to help where I can. Thanks! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

ludaavics commented 5 years ago

Not sure this is the most elegant approach but took a shot at it. If looks good to you, will add to the doc, etc.

datakurre commented 5 years ago

Merged in 0.10.0. (Probably cut 1.0 release with the current feature set on some day.) Thank you for the contribution!