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/master Commit: 8baf5eb03d57ed1cd15678a779b129d7ad696446 Parents: d282c82 Author: Alexander Shorin <[email protected]> Authored: Sat Sep 28 10:04:47 2013 +0400 Committer: Alexander Shorin <[email protected]> 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):
