collective / sphinxcontrib-httpexample

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

Refactor to support pluggable examples #8

Open skyzyx opened 7 years ago

skyzyx commented 7 years ago

Being able to install sphinxcontrib-httpexample followed by sphinxcontrib-httpexample-guzzle would be great.

Specifically, if the examples used something easy to use like Jinja2, it would be much easier for people to develop their own plugins for examples.

datakurre commented 7 years ago

Because Python is dynamic language, you could extend the plugin could already with custom Sphinx-plugins, by adding their own example builder into AVAILABLE_BUILDERS dictionary of sphinxcontrib.httpexample.directives.

https://github.com/collective/sphinxcontrib-httpexample/blob/master/src/sphinxcontrib/httpexample/directives.py#L12

Builder is simply a function, which receives Python built-in BaseHTTPRequestHandler with example request data and should return a string of corresponding example syntax for a similar request.

I agree that documentation for extending the plugin would be nice. I keep that in mind, when I'm working on this extension next time.