{"id":109,"date":"2014-04-30T23:09:28","date_gmt":"2014-04-30T20:09:28","guid":{"rendered":"http:\/\/gronlier.fr\/blog\/?p=109"},"modified":"2020-03-30T12:43:45","modified_gmt":"2020-03-30T09:43:45","slug":"exporting-api-reference-from-tornado-app-mistakes-to-avoid","status":"publish","type":"post","link":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/","title":{"rendered":"Exporting API reference from Tornado app - Mistakes to avoid"},"content":{"rendered":"<p>I've developed a small RESTful service with <a href=\"http:\/\/www.tornadoweb.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Tornado <\/a>and I wanted to generated doc for the exposed API. Lucky me, someone already thought about it and created the <a href=\"https:\/\/pythonhosted.org\/sphinxcontrib-httpdomain\/#module-sphinxcontrib.autohttp.tornado\" target=\"_blank\" rel=\"noopener noreferrer\">sphinxcontrib.autohttp.tornado<\/a> addon for <a href=\"http:\/\/sphinx-doc.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Sphinx<\/a>.<\/p>\n<p>The next few tips will help getting the work done:<\/p>\n<ol>\n<li>If you're using python-3, you need to use this file <a href=\"https:\/\/bitbucket.org\/birkenfeld\/sphinx-contrib\/src\/940757f22e335f6ae98521621201683d6bab1d60\/httpdomain\/sphinxcontrib\/autohttp\/tornado.py?at=default\" target=\"_blank\" rel=\"noopener noreferrer\">tornado.py<\/a>. The latest release 1.2.1 (as of 30\/04\/2014) doesn't work with python-3, because\n<pre>methods = inspect.getmembers(handler, predicate=inspect.ismethod)  # returns an empty array with python-3<\/pre>\n<p>The predicate needs to be changed to include <tt>ismethod or isfunction<\/tt><\/li>\n<li>In the subclass of the RequestHandler, be sure that the <tt>SUPPORTED_METHODS<\/tt> is defined as a tuple\n<pre>SUPPORTED_METHODS=('GET')  # WRONG\r\nSUPPORTED_METHODS=('GET',)  # CORRECT\r\n<\/pre>\n<\/li>\n<li>If you add a decorator to your handler methodes, be sure to use <tt>functools.wraps<\/tt> or <tt>functools.update_wrapper<\/tt> to copy the docstring of the original method to the function returned by the decorator.<\/li>\n<\/ol>\n<div class='skype-share' data-href='https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/' data-lang='auto' data-style='large' data-source='WordPress' ><\/div><div style='clear:both;padding-bottom:10px;'><\/div>\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=ticapix\" class=\"twitter-share-button\">Tweet<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I've developed a small RESTful service with Tornado and I wanted to generated doc for the exposed API. Lucky me, someone already thought about it and created the sphinxcontrib.autohttp.tornado addon for Sphinx. The next few tips will help getting the work done: If you're using python-3, you need to use this file tornado.py. The latest &hellip; <a href=\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Exporting API reference from Tornado app - Mistakes to avoid<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13,22],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes\" \/>\n<meta property=\"og:description\" content=\"I&#039;ve developed a small RESTful service with Tornado and I wanted to generated doc for the exposed API. Lucky me, someone already thought about it and created the sphinxcontrib.autohttp.tornado addon for Sphinx. The next few tips will help getting the work done: If you&#039;re using python-3, you need to use this file tornado.py. The latest &hellip; Continue reading Exporting API reference from Tornado app - Mistakes to avoid &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\" \/>\n<meta property=\"og:site_name\" content=\"Bits and Bytes\" \/>\n<meta property=\"article:published_time\" content=\"2014-04-30T20:09:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-30T09:43:45+00:00\" \/>\n<meta name=\"author\" content=\"ticapix\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ticapix\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\",\"url\":\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\",\"name\":\"Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes\",\"isPartOf\":{\"@id\":\"https:\/\/gronlier.fr\/blog\/#website\"},\"datePublished\":\"2014-04-30T20:09:28+00:00\",\"dateModified\":\"2020-03-30T09:43:45+00:00\",\"author\":{\"@id\":\"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/9abd8d0260a4d942d7069de75446e2bc\"},\"breadcrumb\":{\"@id\":\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/gronlier.fr\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exporting API reference from Tornado app - Mistakes to avoid\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/gronlier.fr\/blog\/#website\",\"url\":\"https:\/\/gronlier.fr\/blog\/\",\"name\":\"Bits and Bytes\",\"description\":\"As the default template said: &quot;Just another WordPress site&quot;\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/gronlier.fr\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/9abd8d0260a4d942d7069de75446e2bc\",\"name\":\"ticapix\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/94bba7228ec3665afea02078abebfa94?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/94bba7228ec3665afea02078abebfa94?s=96&d=monsterid&r=g\",\"caption\":\"ticapix\"},\"url\":\"https:\/\/gronlier.fr\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/","og_locale":"en_US","og_type":"article","og_title":"Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes","og_description":"I've developed a small RESTful service with Tornado and I wanted to generated doc for the exposed API. Lucky me, someone already thought about it and created the sphinxcontrib.autohttp.tornado addon for Sphinx. The next few tips will help getting the work done: If you're using python-3, you need to use this file tornado.py. The latest &hellip; Continue reading Exporting API reference from Tornado app - Mistakes to avoid &rarr;","og_url":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/","og_site_name":"Bits and Bytes","article_published_time":"2014-04-30T20:09:28+00:00","article_modified_time":"2020-03-30T09:43:45+00:00","author":"ticapix","twitter_card":"summary_large_image","twitter_misc":{"Written by":"ticapix","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/","url":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/","name":"Exporting API reference from Tornado app - Mistakes to avoid - Bits and Bytes","isPartOf":{"@id":"https:\/\/gronlier.fr\/blog\/#website"},"datePublished":"2014-04-30T20:09:28+00:00","dateModified":"2020-03-30T09:43:45+00:00","author":{"@id":"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/9abd8d0260a4d942d7069de75446e2bc"},"breadcrumb":{"@id":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gronlier.fr\/blog\/2014\/04\/exporting-api-reference-from-tornado-app-mistakes-to-avoid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gronlier.fr\/blog\/"},{"@type":"ListItem","position":2,"name":"Exporting API reference from Tornado app - Mistakes to avoid"}]},{"@type":"WebSite","@id":"https:\/\/gronlier.fr\/blog\/#website","url":"https:\/\/gronlier.fr\/blog\/","name":"Bits and Bytes","description":"As the default template said: &quot;Just another WordPress site&quot;","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gronlier.fr\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/9abd8d0260a4d942d7069de75446e2bc","name":"ticapix","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/gronlier.fr\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/94bba7228ec3665afea02078abebfa94?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/94bba7228ec3665afea02078abebfa94?s=96&d=monsterid&r=g","caption":"ticapix"},"url":"https:\/\/gronlier.fr\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/posts\/109"}],"collection":[{"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/comments?post=109"}],"version-history":[{"count":4,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":328,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions\/328"}],"wp:attachment":[{"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gronlier.fr\/blog\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}