Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since there doesn't appear to be any existing solution, I have implemented a very simple HTTP domain that I can use to mark up API methods:</p> <pre><code>import re from docutils import nodes from sphinx import addnodes from sphinx.locale import l_, _ from sphinx.domains import Domain, ObjType from sphinx.directives import ObjectDescription http_method_sig_re = re.compile(r'^(GET|POST|PUT|DELETE)?\s?(\S+)(.*)$') class HTTPMethod(ObjectDescription): def handle_signature(self, sig, signode): m = http_method_sig_re.match(sig) if m is None: raise ValueError verb, url, query = m.groups() if verb is None: verb = 'GET' signode += addnodes.desc_addname(verb, verb) signode += addnodes.desc_name(url, url) if query: params = query.strip().split() for param in params: signode += addnodes.desc_optional(param, param) return url class HTTPDomain(Domain): """HTTP language domain.""" name = 'http' label = 'HTTP' object_types = { 'method': ObjType(l_('method'), 'method') } directives = { 'method': HTTPMethod } def setup(app): app.add_domain(HTTPDomain) </code></pre> <p>It allows me to mark up methods like this and they'll be styled somewhat visually nicely:</p> <pre><code>.. http:method:: GET /api/foo/bar/:id/:slug :param id: An id :param slug: A slug Retrieve list of foobars matching given id. </code></pre> <p>This was my first foray into both Sphinx and Python, so this should be considered very rudimentary code. If anybody is interested in fleshing this out, please <a href="https://github.com/deceze/Sphinx-HTTP-domain" rel="noreferrer">fork this project on Github</a>!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload