You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by kx...@apache.org on 2013/09/28 13:09:48 UTC
[3/9] git commit: updated refs/heads/1781-reorganize-and-improve-docs
to 5522488
Stabilize order of HTTP API reference entries.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/8baf5eb0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/8baf5eb0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/8baf5eb0
Branch: refs/heads/1781-reorganize-and-improve-docs
Commit: 8baf5eb03d57ed1cd15678a779b129d7ad696446
Parents: d282c82
Author: Alexander Shorin <kx...@apache.org>
Authored: Sat Sep 28 10:04:47 2013 +0400
Committer: Alexander Shorin <kx...@apache.org>
Committed: Sat Sep 28 10:04:47 2013 +0400
----------------------------------------------------------------------
share/doc/ext/httpdomain.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/8baf5eb0/share/doc/ext/httpdomain.py
----------------------------------------------------------------------
diff --git a/share/doc/ext/httpdomain.py b/share/doc/ext/httpdomain.py
index a36493f..a2de686 100644
--- a/share/doc/ext/httpdomain.py
+++ b/share/doc/ext/httpdomain.py
@@ -201,6 +201,16 @@ http_sig_param_re = re.compile(r'\((?:(?P<type>[^:)]+):)?(?P<name>[\w_]+)\)',
re.VERBOSE)
+def sort_by_method(entries):
+ def cmp(item):
+ order = ['HEAD', 'GET', 'POST', 'PUT', 'DELETE', 'COPY', 'OPTIONS']
+ method = item[0].split(' ', 1)[0]
+ if method in order:
+ return order.index(method)
+ return 100
+ return sorted(entries, key=cmp)
+
+
def http_resource_anchor(method, path):
path = re.sub(r'[<>:/]', '-', path)
return method.lower() + '-' + path
@@ -455,7 +465,11 @@ class HTTPIndex(Index):
method.upper() + ' ' + path, 0, info[0],
http_resource_anchor(method, path), '', '', info[1]
])
- return (sorted(content.items()), True)
+ items = sorted(
+ (path, sort_by_method(entries))
+ for path, entries in content.items()
+ )
+ return (items, True)
class HTTPDomain(Domain):