Creating documentation for a RESTful web service with Python

I would like to create documentation for the RESTful web service API written in Python. Ideally, this would look like a Yahoo RESTful web service. Does anyone have any ideas or links?

+4
source share
3 answers

The Sphinx project ( http://sphinx.pocoo.org/ ) is a state of the art in the Python documentation. It is really powerful and flexible ... so also somewhat confusing. However, I think this is your best bet.

Their site has excellent documentation on how to customize the source files of the document and the process of creating them in ready-made documentation such as HTML. The part that interests you is its system for including dockers from a Python source, which I assume you did for methods that serve your REST requests. Please note that this will NOT magically interpret what is happening, but will bring all named elements and their arguments (if necessary) and provide a good basis for posting relevant documentation.

Assuming you have all the REST functions in a module named restapi.py , and it is just in your project src directory, you need to do two things to get Sphinx to automatically generate documentation:

First enable the autodoc extension and add the src directory to the Sphinx path in conf.py :

 import sys, os sys.path.append(os.path.abspath('sphinxext')) extensions = ['sphinx.ext.autodoc'] sys.path.append(os.path.abspath('src')) 

Then at Sphinx

 .. automodule:: restapi :members: 

Note: this information was taken directly from the Sphinx First Steps document with minimal reordering. Look at this document and the rest of the site if it looks like it will meet your needs.

+2
source

Unfortunately, I do not know anything specific that will specifically help you in Python. However, just like control points, you can take the peak in the WADL specification used by the JAX-RS Java specification - https://wadl.dev.java.net/ - In addition, there is xslt that converts wadl to html - http://www.mnot.net/webdesc/

They use the yahoo API as examples.

0
source

It looks like you are not creating a REST API, but just an RPC. Typically, there is no simple, automated way to build a REST API, which should mainly be a description of your media types.

If you mean that you want something to collect all the URIs in your service and put them in an API document, not a REST at all, because of all the URI connection to resources.

0
source

All Articles