diff options
author | Alexander Shorin <kxepal@apache.org> | 2013-09-28 10:04:47 +0400 |
---|---|---|
committer | Alexander Shorin <kxepal@apache.org> | 2013-09-28 10:04:47 +0400 |
commit | 8baf5eb03d57ed1cd15678a779b129d7ad696446 (patch) | |
tree | e08851077e913bc36696dfdafe3bb05cae8ae14a | |
parent | d282c828ab61b8822c0dfc27b370b32977ce0ccd (diff) | |
download | couchdb-8baf5eb03d57ed1cd15678a779b129d7ad696446.tar.gz |
Stabilize order of HTTP API reference entries.
-rw-r--r-- | share/doc/ext/httpdomain.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/share/doc/ext/httpdomain.py b/share/doc/ext/httpdomain.py index a36493ff9..a2de686bb 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): |