jfinkels avatar jfinkels committed d84f7bb

[httpdomain] Added support and documentation for PATCH method.

Comments (0)

Files changed (2)

httpdomain/doc/index.rst

    Describes a HTTP resource's :http:method:`PUT` method.
    It can also be referred by :rst:role:`http:put` role.
 
+.. rst:directive:: .. http:patch:: path
+
+   Describes a HTTP resource's :http:method:`PATCH` method.
+   It can also be referred by :rst:role:`http:patch` role.
+
 .. rst:directive:: .. http:delete:: path
 
    Describes a HTTP resource's :http:method:`DELETE` method.
 
    Refers to the :rst:dir:`http:put` directive.
 
+.. rst:role:: http:patch
+
+   Refers to the :rst:dir:`http:patch` directive.
+
 .. rst:role:: http:delete
 
    Refers to the :rst:dir:`http:delete` directive.

httpdomain/sphinxcontrib/httpdomain.py

     method = 'head'
 
 
+class HTTPPatch(HTTPResource):
+
+    method = 'patch'
+
+
 class HTTPPost(HTTPResource):
 
     method = 'post'
 def http_method_role(name, rawtext, text, lineno, inliner,
                      options={}, content=[]):
     references = {
+        'patch': '2',
         'options': '9.2',
         'get': '9.3',
         'head': '9.4',
         prb = inliner.problematic(rawtext, rawtext, msg)
         return [prb], [msg]
     url = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec' + sec
+    if method == 'patch':
+        url = 'http://tools.ietf.org/html/rfc5789#section-' + sec
     node = nodes.reference(rawtext, umethod, refuri=url, **options)
     return [node], []
 
         'post': ObjType('post', 'post', 'obj'),
         'get': ObjType('get', 'get', 'obj'),
         'put': ObjType('put', 'put', 'obj'),
+        'patch': ObjType('patch', 'patch', 'obj'),
         'delete': ObjType('delete', 'delete', 'obj'),
         'trace': ObjType('trace', 'trace', 'obj')
     }
         'post': HTTPPost,
         'get': HTTPGet,
         'put': HTTPPut,
+        'patch': HTTPPatch,
         'delete': HTTPDelete,
         'trace': HTTPTrace
     }
         'post': HTTPXRefRole('post'),
         'get': HTTPXRefRole('get'),
         'put': HTTPXRefRole('put'),
+        'patch': HTTPXRefRole('patch'),
         'delete': HTTPXRefRole('delete'),
         'trace': HTTPXRefRole('trace'),
         'statuscode': http_statuscode_role,
         'post': {},
         'get': {},
         'put': {},
+        'patch': {},
         'delete': {},
         'trace': {}
     }
 
     tokens = {
         'root': [
-            (r'(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE)( +)([^ ]+)( +)'
+            (r'(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|TRACE)( +)([^ ]+)( +)'
              r'(HTTPS?)(/)(1\.[01])(\r?\n|$)',
              bygroups(Name.Function, Text, Name.Namespace, Text,
                       Keyword.Reserved, Operator, Number, Text),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.