couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [05/26] documentation commit: updated refs/heads/master to 5a81ace
Date Fri, 20 Feb 2015 00:26:38 GMT
src/query-server now follows the style


Project: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/commit/e5d2fc8e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/tree/e5d2fc8e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-documentation/diff/e5d2fc8e

Branch: refs/heads/master
Commit: e5d2fc8ec5f905a47e10a4298e21daf5c3e87aeb
Parents: 75787d2
Author: Maria Andersson <maria@dualpose.com>
Authored: Fri Feb 6 22:19:18 2015 +0100
Committer: Maria Andersson <maria@dualpose.com>
Committed: Fri Feb 6 22:19:18 2015 +0100

----------------------------------------------------------------------
 src/query-server/erlang.rst     | 162 ++++----
 src/query-server/index.rst      |   9 +-
 src/query-server/javascript.rst | 268 ++++++------
 src/query-server/protocol.rst   | 782 +++++++++++++++++------------------
 4 files changed, 594 insertions(+), 627 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/e5d2fc8e/src/query-server/erlang.rst
----------------------------------------------------------------------
diff --git a/src/query-server/erlang.rst b/src/query-server/erlang.rst
index 165a341..ca6ef3b 100644
--- a/src/query-server/erlang.rst
+++ b/src/query-server/erlang.rst
@@ -14,126 +14,122 @@
 
 .. _query-server/erlang:
 
+======
 Erlang
 ======
 
 .. note::
-
-   The Erlang query server is disabled by default.
-   Read :ref:`configuration guide <config/native_query_servers>` about
-   reasons why and how to enable it.
+    The Erlang query server is disabled by default.
+    Read :ref:`configuration guide <config/native_query_servers>` about
+    reasons why and how to enable it.
 
 .. function:: Emit(Id, Value)
 
-   Emits `key`-`value` pairs to view indexer process.
-
-   .. code-block:: erlang
+    Emits `key`-`value` pairs to view indexer process.
 
-      fun({Doc}) ->
-        <<K,_/binary>> = proplists:get_value(<<"_rev">>, Doc, null),
-        V = proplists:get_value(<<"_id">>, Doc, null),
-        Emit(<<K>>, V)
-      end.
+    .. code-block:: erlang
 
+        fun({Doc}) ->
+            <<K,_/binary>> = proplists:get_value(<<"_rev">>, Doc, null),
+            V = proplists:get_value(<<"_id">>, Doc, null),
+            Emit(<<K>>, V)
+        end.
 
 .. function:: FoldRows(Fun, Acc)
 
-   Helper to iterate over all rows in a list function.
+    Helper to iterate over all rows in a list function.
 
-   :param Fun: Function object.
-   :param Acc: The value previously returned by `Fun`.
+    :param Fun: Function object.
+    :param Acc: The value previously returned by `Fun`.
 
-   .. code-block:: erlang
-
-      fun(Head, {Req}) ->
-        Fun = fun({Row}, Acc) ->
-          Id = couch_util:get_value(<<"id">>, Row),
-          Send(list_to_binary(io_lib:format("Previous doc id: ~p~n", [Acc]))),
-          Send(list_to_binary(io_lib:format("Current  doc id: ~p~n", [Id]))),
-          {ok, Id}
-        end,
-        FoldRows(Fun, nil),
-        ""
-      end.
+    .. code-block:: erlang
 
+        fun(Head, {Req}) ->
+            Fun = fun({Row}, Acc) ->
+                Id = couch_util:get_value(<<"id">>, Row),
+                Send(list_to_binary(io_lib:format("Previous doc id: ~p~n", [Acc]))),
+                Send(list_to_binary(io_lib:format("Current  doc id: ~p~n", [Id]))),
+                {ok, Id}
+            end,
+            FoldRows(Fun, nil),
+            ""
+        end.
 
 .. function:: GetRow()
 
-   Retrieves the next row from a related view result.
-
-   .. code-block:: erlang
-
-      %% FoldRows background implementation.
-      %% https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=blob;f=src/couchdb/couch_native_process.erl;hb=HEAD#l368
-      %%
-      foldrows(GetRow, ProcRow, Acc) ->
-        case GetRow() of
-          nil ->
-            {ok, Acc};
-          Row ->
-            case (catch ProcRow(Row, Acc)) of
-              {ok, Acc2} ->
-                foldrows(GetRow, ProcRow, Acc2);
-              {stop, Acc2} ->
-                {ok, Acc2}
-            end
-      end.
+    Retrieves the next row from a related view result.
+
+    .. code-block:: erlang
+
+        %% FoldRows background implementation.
+        %% https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=blob;f=src/couchdb/couch_native_process.erl;hb=HEAD#l368
+        %%
+        foldrows(GetRow, ProcRow, Acc) ->
+            case GetRow() of
+                nil ->
+                    {ok, Acc};
+                Row ->
+                    case (catch ProcRow(Row, Acc)) of
+                        {ok, Acc2} ->
+                            foldrows(GetRow, ProcRow, Acc2);
+                        {stop, Acc2} ->
+                            {ok, Acc2}
+                    end
+        end.
 
 .. function:: Log(Msg)
 
-   :param Msg: Log a message at the `INFO` level.
-
-   .. code-block:: erlang
+    :param Msg: Log a message at the `INFO` level.
 
-      fun({Doc}) ->
-        <<K,_/binary>> = proplists:get_value(<<"_rev">>, Doc, null),
-        V = proplists:get_value(<<"_id">>, Doc, null),
-        Log(lists:flatten(io_lib:format("Hello from ~s doc!", [V]))),
-        Emit(<<K>>, V)
-      end.
+    .. code-block:: erlang
 
-   After the map function has run, the following line can be found in
-   CouchDB logs (e.g. at `/var/log/couchdb/couch.log`):
+        fun({Doc}) ->
+            <<K,_/binary>> = proplists:get_value(<<"_rev">>, Doc, null),
+            V = proplists:get_value(<<"_id">>, Doc, null),
+            Log(lists:flatten(io_lib:format("Hello from ~s doc!", [V]))),
+            Emit(<<K>>, V)
+        end.
 
-   .. code-block:: text
+    After the map function has run, the following line can be found in
+    CouchDB logs (e.g. at `/var/log/couchdb/couch.log`):
 
-      [Sun, 04 Nov 2012 11:33:58 GMT] [info] [<0.9144.2>] Hello from 8d300b86622d67953d102165dbe99467 doc!
+    .. code-block:: text
 
+        [Sun, 04 Nov 2012 11:33:58 GMT] [info] [<0.9144.2>] Hello from 8d300b86622d67953d102165dbe99467 doc!
 
 .. function:: Send(Chunk)
 
-   Sends a single string `Chunk` in response.
-
-   .. code-block:: erlang
+    Sends a single string `Chunk` in response.
 
-      fun(Head, {Req}) ->
-        Send("Hello,"),
-        Send(" "),
-        Send("Couch"),
-        "!"
-      end.
+    .. code-block:: erlang
 
-   The function above produces the following response:
+        fun(Head, {Req}) ->
+            Send("Hello,"),
+            Send(" "),
+            Send("Couch"),
+            "!"
+        end.
 
-   .. code-block:: text
+    The function above produces the following response:
 
-      Hello, Couch!
+    .. code-block:: text
 
+        Hello, Couch!
 
 .. function:: Start(Headers)
 
-   :param Headers: Proplist of :ref:`response object<response_object>`.
+    :param Headers: Proplist of :ref:`response object<response_object>`.
 
-   Initialize :ref:`listfun` response. At this point, response code and headers
-   may be defined. For example, this function redirects to the CouchDB web site:
+    Initialize :ref:`listfun` response. At this point, response code and headers
+    may be defined. For example, this function redirects to the CouchDB web site:
 
-   .. code-block:: erlang
+    .. code-block:: erlang
 
-      fun(Head, {Req}) ->
-        Start({[{<<"code">>, 302},
-                {<<"headers">>, {[
-                  {<<"Location">>, <<"http://couchdb.apache.org">>}]
-                }}
-              ]}),
-        "Relax!"
-      end.
+        fun(Head, {Req}) ->
+            Start({[{<<"code">>, 302},
+                    {<<"headers">>, {[
+                        {<<"Location">>, <<"http://couchdb.apache.org">>}]
+                    }}
+                ]}),
+            "Relax!"
+        end.

http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/e5d2fc8e/src/query-server/index.rst
----------------------------------------------------------------------
diff --git a/src/query-server/index.rst b/src/query-server/index.rst
index 835ba1b..657faee 100644
--- a/src/query-server/index.rst
+++ b/src/query-server/index.rst
@@ -32,9 +32,8 @@ are assumed to be of type `javascript`, as are ad hoc queries that are POSTed to
 .. _Mozilla SpiderMonkey: https://developer.mozilla.org/en/docs/SpiderMonkey
 
 .. toctree::
-   :maxdepth: 2
-
-   protocol
-   javascript
-   erlang
+    :maxdepth: 2
 
+    protocol
+    javascript
+    erlang

http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/e5d2fc8e/src/query-server/javascript.rst
----------------------------------------------------------------------
diff --git a/src/query-server/javascript.rst b/src/query-server/javascript.rst
index 386f9c5..ba282ac 100644
--- a/src/query-server/javascript.rst
+++ b/src/query-server/javascript.rst
@@ -14,12 +14,15 @@
 
 .. _query-server/js:
 
+==========
 JavaScript
 ==========
 
-.. note:: While every design function has access to all JavaScript objects,
-   the table below describes appropriate usage cases. For example,
-   you may use :func:`emit` in :ref:`listfun`, but :func:`getRow` is not permitted during :ref:`mapfun`.
+.. note::
+    While every design function has access to all JavaScript objects, the table
+    below describes appropriate usage cases. For example, you may use
+    :func:`emit` in :ref:`listfun`, but :func:`getRow` is not permitted
+    during :ref:`mapfun`.
 
 +--------------------------------+---------------------------------------------+
 | JS Function                    | Reasonable to use in design doc functions   |
@@ -50,192 +53,179 @@ JavaScript
 +--------------------------------+---------------------------------------------+
 
 Design functions context
-------------------------
+========================
 
 Each design function executes in a special context of predefined objects,
 modules and functions:
 
-
 .. function:: emit(key, value)
 
-   Emits a `key`-`value` pair for further processing by CouchDB after the map
-   function is done.
+    Emits a `key`-`value` pair for further processing by CouchDB after the map
+    function is done.
 
-   :param key: The view key
-   :param value: The `key`'s associated value
+    :param key: The view key
+    :param value: The `key`'s associated value
 
-   .. code-block:: javascript
-
-      function(doc){
-        emit(doc._id, doc._rev);
-      }
+    .. code-block:: javascript
 
+        function(doc){
+            emit(doc._id, doc._rev);
+        }
 
 .. function:: getRow()
 
-   Extracts the next row from a related view result.
+    Extracts the next row from a related view result.
 
-   :return: View result row
-   :rtype: object
+    :return: View result row
+    :rtype: object
 
-   .. code-block:: javascript
+    .. code-block:: javascript
 
-      function(head, req){
-        send('[');
-        row = getRow();
-        if (row){
-          send(toJSON(row));
-          while(row = getRow()){
-            send(',');
-            send(toJSON(row));
-          }
+        function(head, req){
+            send('[');
+            row = getRow();
+            if (row){
+                send(toJSON(row));
+                while(row = getRow()){
+                    send(',');
+                    send(toJSON(row));
+                }
+            }
+            return ']';
         }
-        return ']';
-      }
-
 
 .. data:: JSON
 
-   `JSON2 <https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=blob;f=share/server/json2.js>`_
-   object.
-
+    `JSON2 <https://git-wip-us.apache.org/repos/asf?p=couchdb.git;a=blob;f=share/server/json2.js>`_
+    object.
 
 .. function:: isArray(obj)
 
-   A helper function to check if the provided value is an `Array`.
-
-   :param obj: Any Javascript value
-   :return: ``true`` if `obj` is `Array`-typed, ``false`` otherwise
-   :rtype: boolean
+    A helper function to check if the provided value is an `Array`.
 
+    :param obj: Any Javascript value
+    :return: ``true`` if `obj` is `Array`-typed, ``false`` otherwise
+    :rtype: boolean
 
 .. function:: log(message)
 
-   Log a message to the CouchDB log (at the `INFO` level).
+    Log a message to the CouchDB log (at the `INFO` level).
 
-   :param message: Message to be logged
+    :param message: Message to be logged
 
-   .. code-block:: javascript
+    .. code-block:: javascript
 
-      function(doc){
-        log('Procesing doc ' + doc['_id']);
-        emit(doc['_id'], null);
-      }
-
-   After the map function has run, the following line can be found in CouchDB
-   logs (e.g. at `/var/log/couchdb/couch.log`):
+        function(doc){
+            log('Procesing doc ' + doc['_id']);
+            emit(doc['_id'], null);
+        }
 
-   .. code-block:: text
+    After the map function has run, the following line can be found in CouchDB
+    logs (e.g. at `/var/log/couchdb/couch.log`):
 
-      [Sat, 03 Nov 2012 17:38:02 GMT] [info] [<0.7543.0>] OS Process #Port<0.3289> Log :: Processing doc 8d300b86622d67953d102165dbe99467
+    .. code-block:: text
 
+        [Sat, 03 Nov 2012 17:38:02 GMT] [info] [<0.7543.0>] OS Process #Port<0.3289> Log :: Processing doc 8d300b86622d67953d102165dbe99467
 
 .. function:: provides(key, func)
 
-   Registers callable handler for specified MIME key.
-
-   :param key: MIME key previously defined by :func:`registerType`
-   :param func: MIME type handler
+    Registers callable handler for specified MIME key.
 
+    :param key: MIME key previously defined by :func:`registerType`
+    :param func: MIME type handler
 
 .. function:: registerType(key, *mimes)
 
-   Registers list of MIME types by associated `key`.
-
-   :param key: MIME types
-   :param mimes: MIME types enumeration
-
-   Predefined mappings (`key`-`array`):
-
-   - **all**: ``*/*``
-   - **text**: ``text/plain; charset=utf-8``, ``txt``
-   - **html**: ``text/html; charset=utf-8``
-   - **xhtml**: ``application/xhtml+xml``, ``xhtml``
-   - **xml**: ``application/xml``, ``text/xml``, ``application/x-xml``
-   - **js**: ``text/javascript``, ``application/javascript``,
-     ``application/x-javascript``
-   - **css**: ``text/css``
-   - **ics**: ``text/calendar``
-   - **csv**: ``text/csv``
-   - **rss**: ``application/rss+xml``
-   - **atom**: ``application/atom+xml``
-   - **yaml**: ``application/x-yaml``, ``text/yaml``
-   - **multipart_form**: ``multipart/form-data``
-   - **url_encoded_form**: ``application/x-www-form-urlencoded``
-   - **json**: ``application/json``, ``text/x-json``
-
+    Registers list of MIME types by associated `key`.
+
+    :param key: MIME types
+    :param mimes: MIME types enumeration
+
+    Predefined mappings (`key`-`array`):
+
+    - **all**: ``*/*``
+    - **text**: ``text/plain; charset=utf-8``, ``txt``
+    - **html**: ``text/html; charset=utf-8``
+    - **xhtml**: ``application/xhtml+xml``, ``xhtml``
+    - **xml**: ``application/xml``, ``text/xml``, ``application/x-xml``
+    - **js**: ``text/javascript``, ``application/javascript``,
+      ``application/x-javascript``
+    - **css**: ``text/css``
+    - **ics**: ``text/calendar``
+    - **csv**: ``text/csv``
+    - **rss**: ``application/rss+xml``
+    - **atom**: ``application/atom+xml``
+    - **yaml**: ``application/x-yaml``, ``text/yaml``
+    - **multipart_form**: ``multipart/form-data``
+    - **url_encoded_form**: ``application/x-www-form-urlencoded``
+    - **json**: ``application/json``, ``text/x-json``
 
 .. function:: require(path)
 
-   Loads CommonJS module by a specified `path`. The path should not start with
-   a slash.
-
-   :param path: A CommonJS module path started from design document root
-   :return: Exported statements
+    Loads CommonJS module by a specified `path`. The path should not start with
+    a slash.
 
+    :param path: A CommonJS module path started from design document root
+    :return: Exported statements
 
 .. function:: send(chunk)
 
-   Sends a single string `chunk` in response.
-
-   :param chunk: Text chunk
+    Sends a single string `chunk` in response.
 
-   .. code-block:: javascript
+    :param chunk: Text chunk
 
-      function(head, req){
-        send('Hello,');
-        send(' ');
-        send('Couch');
-        return !
-      }
+    .. code-block:: javascript
 
+        function(head, req){
+            send('Hello,');
+            send(' ');
+            send('Couch');
+            return !
+        }
 
 .. function:: start(init_resp)
 
-   Initiates chunked response. As an option, a custom
-   :ref:`response <response_object>` object may be sent at this point.
-   For `list`-functions only!
-
-   .. note::
-
-      list functions may set the `HTTP response code` and `headers` by calling
-      this function. This function must be called before :func:`send`,
-      :func:`getRow` or a `return` statement; otherwise, the query server will
-      implicitly call this function with the empty object (``{}``).
-
-   .. code-block:: javascript
-
-      function(head, req){
-        start({
-          "code": 302,
-          "headers": {
-            "Location": "http://couchdb.apache.org"
-          }
-        });
-        return "Relax!";
-      }
-
+    Initiates chunked response. As an option, a custom
+    :ref:`response <response_object>` object may be sent at this point.
+    For `list`-functions only!
+
+    .. note::
+        list functions may set the `HTTP response code` and `headers` by calling
+        this function. This function must be called before :func:`send`,
+        :func:`getRow` or a `return` statement; otherwise, the query server will
+        implicitly call this function with the empty object (``{}``).
+
+    .. code-block:: javascript
+
+        function(head, req){
+            start({
+                "code": 302,
+                "headers": {
+                    "Location": "http://couchdb.apache.org"
+                }
+            });
+            return "Relax!";
+        }
 
 .. function:: sum(arr)
 
-   Sum `arr`'s items.
-
-   :param arr: Array of numbers
-   :rtype: number
+    Sum `arr`'s items.
 
+    :param arr: Array of numbers
+    :rtype: number
 
 .. function:: toJSON(obj)
 
-   Encodes `obj` to JSON string. This is an alias for the ``JSON.stringify``
-   method.
+    Encodes `obj` to JSON string. This is an alias for the ``JSON.stringify``
+    method.
 
-   :param obj: JSON encodable object
-   :return: JSON string
+    :param obj: JSON encodable object
+    :return: JSON string
 
 .. _commonjs:
 
 CommonJS Modules
-----------------
+================
 
 Support for `CommonJS Modules <http://wiki.commonjs.org/wiki/Modules/1.1.1>`_
 (introduced in CouchDB 0.11.0) allows you to create modular design functions
@@ -246,10 +236,10 @@ Here's a CommonJS module that checks user permissions:
 .. code-block:: javascript
 
     function user_context(userctx, secobj) {
-      var is_admin = function() {
-        return userctx.indexOf('_admin') != -1;
-      }
-      return {'is_admin': is_admin}
+        var is_admin = function() {
+            return userctx.indexOf('_admin') != -1;
+        }
+        return {'is_admin': is_admin}
     }
 
     exports['user'] = user_context
@@ -270,16 +260,16 @@ The CommonJS module can be added to a design document, like so:
 .. code-block:: javascript
 
     {
-       "views": {
-          "lib": {
-             "security": "function user_context(userctx, secobj) { ... }"
-          }
-       },
-       "validate_doc_update": "function(newdoc, olddoc, userctx, secobj) {
-          user = require('lib/security').user(userctx, secobj);
-          return user.is_admin();
-       }"
-       "_id": "_design/test"
+        "views": {
+            "lib": {
+                "security": "function user_context(userctx, secobj) { ... }"
+            }
+        },
+        "validate_doc_update": "function(newdoc, olddoc, userctx, secobj) {
+            user = require('lib/security').user(userctx, secobj);
+            return user.is_admin();
+        }"
+        "_id": "_design/test"
     }
 
 Modules paths are relative to the design document's ``views`` object, but

http://git-wip-us.apache.org/repos/asf/couchdb-documentation/blob/e5d2fc8e/src/query-server/protocol.rst
----------------------------------------------------------------------
diff --git a/src/query-server/protocol.rst b/src/query-server/protocol.rst
index 7b56eb5..049a59d 100644
--- a/src/query-server/protocol.rst
+++ b/src/query-server/protocol.rst
@@ -10,7 +10,6 @@
 .. License for the specific language governing permissions and limitations under
 .. the License.
 
-
 .. _query-server/protocol:
 
 =====================
@@ -27,9 +26,9 @@ the Query Server are always `array`-typed that could be matched by the pattern
 ``[<command>, <*arguments>]\n``.
 
 .. note::
-   To simplify examples reading we omitted trailing ``\n`` character to let
-   Sphinx highlight them well. Also, all examples contain formatted JSON values
-   while real data transfers in compact mode without formatting spaces.
+    To simplify examples reading we omitted trailing ``\n`` character to let
+    Sphinx highlight them well. Also, all examples contain formatted JSON values
+    while real data transfers in compact mode without formatting spaces.
 
 .. _qs/reset:
 
@@ -62,7 +61,6 @@ The Query Server answers::
 
     true
 
-
 .. _qs/add_lib:
 
 ``add_lib``
@@ -77,24 +75,22 @@ in `map` functions.
 
 CouchDB sends::
 
-  [
-    "add_lib",
-    {
-      "utils": "exports.MAGIC = 42;"
-    }
-  ]
+    [
+        "add_lib",
+        {
+            "utils": "exports.MAGIC = 42;"
+        }
+    ]
 
 The Query Server answers::
 
-  true
-
+    true
 
 .. note::
-
-   This library shouldn't have any side effects nor track its own state
-   or you'll have a lot of happy debugging time if something went wrong.
-   Remember that a complete index rebuild is a heavy operation and this is
-   the only way to fix your mistakes with shared state.
+    This library shouldn't have any side effects nor track its own state
+    or you'll have a lot of happy debugging time if something went wrong.
+    Remember that a complete index rebuild is a heavy operation and this is
+    the only way to fix your mistakes with shared state.
 
 .. _qs/add_fun:
 
@@ -114,15 +110,14 @@ actual documents.
 CouchDB sends::
 
     [
-      "add_fun",
-      "function(doc) { if(doc.score > 50) emit(null, {'player_name': doc.name}); }"
+        "add_fun",
+        "function(doc) { if(doc.score > 50) emit(null, {'player_name': doc.name}); }"
     ]
 
 The Query Server answers::
 
     true
 
-
 .. _qs/map_doc:
 
 ``map_doc``
@@ -141,21 +136,21 @@ string.
 CouchDB sends::
 
     [
-      "map_doc",
-      {
-        "_id": "8877AFF9789988EE",
-        "_rev": "3-235256484",
-        "name": "John Smith",
-        "score": 60
-      }
+        "map_doc",
+        {
+            "_id": "8877AFF9789988EE",
+            "_rev": "3-235256484",
+            "name": "John Smith",
+            "score": 60
+        }
     ]
 
 If the function above is the only function stored, the Query Server answers::
 
     [
-      [
-        [null, {"player_name": "John Smith"}]
-      ]
+        [
+            [null, {"player_name": "John Smith"}]
+        ]
     ]
 
 That is, an array with the result for every function for the given document.
@@ -165,20 +160,19 @@ If a document is to be excluded from the view, the array should be empty.
 CouchDB sends::
 
     [
-      "map_doc",
-      {
-        "_id": "9590AEB4585637FE",
-        "_rev": "1-674684684",
-        "name": "Jane Parker",
-        "score": 43
-      }
+        "map_doc",
+        {
+            "_id": "9590AEB4585637FE",
+            "_rev": "1-674684684",
+            "name": "Jane Parker",
+            "score": 43
+        }
     ]
 
 The Query Server answers::
 
     [[]]
 
-
 .. _qs/reduce:
 
 ``reduce``
@@ -186,9 +180,11 @@ The Query Server answers::
 
 :Command: ``reduce``
 :Arguments:
-  - Reduce function source
-  - Array of :ref:`map function <mapfun>` results where each item represented
-    in format ``[[key, id-of-doc], value]``
+
+    - Reduce function source
+    - Array of :ref:`map function <mapfun>` results where each item represented
+      in format ``[[key, id-of-doc], value]``
+
 :Returns: Array with pair values: ``true`` and another array with reduced result
 
 If the view has a reduce function defined, CouchDB will enter into the reduce
@@ -197,24 +193,24 @@ results on which it can apply them.
 
 CouchDB sends::
 
-  [
-    "reduce",
     [
-      "function(k, v) { return sum(v); }"
-    ],
-    [
-      [[1, "699b524273605d5d3e9d4fd0ff2cb272"], 10],
-      [[2, "c081d0f69c13d2ce2050d684c7ba2843"], 20],
-      [[null, "foobar"], 3]
+        "reduce",
+        [
+            "function(k, v) { return sum(v); }"
+        ],
+        [
+            [[1, "699b524273605d5d3e9d4fd0ff2cb272"], 10],
+            [[2, "c081d0f69c13d2ce2050d684c7ba2843"], 20],
+            [[null, "foobar"], 3]
+        ]
     ]
-  ]
 
 The Query Server answers::
 
-  [
-    true,
-    [33]
-  ]
+    [
+        true,
+        [33]
+    ]
 
 Note that even though the view server receives the map results in the form
 ``[[key, id-of-doc], value]``, the function may receive them in a different
@@ -227,9 +223,10 @@ keys and the list of values.
 ============
 
 :Command: ``rereduce``
-:Arguments: 
-  - Reduce function source
-  - List of values
+:Arguments:
+
+    - Reduce function source
+    - List of values
 
 When building a view, CouchDB will apply the reduce step directly to the output
 of the map step and the rereduce step to the output of a previous reduce step.
@@ -239,25 +236,24 @@ document ids, to the rereduce step.
 
 CouchDB sends::
 
-  [
-    "rereduce",
-    [
-      "function(k, v, r) { return sum(v); }"
-    ],
     [
-      33,
-      55,
-      66
+        "rereduce",
+        [
+            "function(k, v, r) { return sum(v); }"
+        ],
+        [
+            33,
+            55,
+            66
+        ]
     ]
-  ]
 
 The Query Server answers::
 
-  [
-    true,
-    [154]
-  ]
-
+    [
+        true,
+        [154]
+    ]
 
 .. _qs/ddoc:
 
@@ -267,25 +263,23 @@ The Query Server answers::
 :Command: ``ddoc``
 :Arguments: Array of objects.
 
-  - First phase (ddoc initialization):
+    - First phase (ddoc initialization):
 
-    - ``"new"``
-    - Design document ``_id``
-    - Design document object
+      - ``"new"``
+      - Design document ``_id``
+      - Design document object
 
-  - Second phase (design function execution):
+    - Second phase (design function execution):
 
-    - Design document ``_id``
-    - Function path as an array of object keys
-    - Array of function arguments
+      - Design document ``_id``
+      - Function path as an array of object keys
+      - Array of function arguments
 
 :Returns:
 
-  - First phase (ddoc initialization): ``true``
-  - Second phase (design function execution): custom object depending on
-    executed function
-
-
+    - First phase (ddoc initialization): ``true``
+    - Second phase (design function execution): custom object depending on
+      executed function
 
 This command acts in two phases: `ddoc` registration and `design function`
 execution.
@@ -295,39 +289,36 @@ Server to let it cache it by ``_id`` value for further function execution.
 
 To do this, CouchDB sends::
 
-  [
-    "ddoc",
-    "new",
-    "_design/temp",
-    {
-      "_id": "_design/temp",
-      "_rev": "8-d7379de23a751dc2a19e5638a7bbc5cc",
-      "language": "javascript",
-      "shows": {
-        "request": "function(doc,req){ return {json: req}; }",
-        "hello": "function(doc,req){ return {body: 'Hello, ' + (doc || {})._id + '!'}; }"
-      }
-    }
-  ]
+    [
+        "ddoc",
+        "new",
+        "_design/temp",
+        {
+            "_id": "_design/temp",
+            "_rev": "8-d7379de23a751dc2a19e5638a7bbc5cc",
+            "language": "javascript",
+            "shows": {
+                "request": "function(doc,req){ return {json: req}; }",
+                "hello": "function(doc,req){ return {body: 'Hello, ' + (doc || {})._id + '!'}; }"
+            }
+        }
+    ]
 
 The Query Server answers::
 
-  true
-
+    true
 
 After than this design document is ready to serve next subcommands - that's the
 second phase.
 
 .. note::
+    Each ``ddoc`` subcommand is the root design document key, so they are not
+    actually subcommands, but first elements of the JSON path that may be handled
+    and processed.
 
-   Each ``ddoc`` subcommand is the root design document key, so they are not
-   actually subcommands, but first elements of the JSON path that may be handled
-   and processed.
-
-   The pattern for subcommand execution is common:
-
-   ``["ddoc", <design_doc_id>, [<subcommand>, <funcname>], [<argument1>, <argument2>, ...]]``
+    The pattern for subcommand execution is common:
 
+    ``["ddoc", <design_doc_id>, [<subcommand>, <funcname>], [<argument1>, <argument2>, ...]]``
 
 .. _qs/ddoc/shows:
 
@@ -338,90 +329,89 @@ second phase.
 :SubCommand: ``shows``
 :Arguments:
 
-  - Document object or ``null`` if document `id` wasn't specified in request
-  - :ref:`request_object`
+    - Document object or ``null`` if document `id` wasn't specified in request
+    - :ref:`request_object`
 
 :Returns: Array with two elements:
 
-  - ``"resp"``
-  - :ref:`response_object`
+    - ``"resp"``
+    - :ref:`response_object`
 
 Executes :ref:`show function <showfun>`.
 
 Couchdb sends::
 
-  [
-    "ddoc",
-    "_design/temp",
-    [
-        "shows",
-        "doc"
-    ],
     [
-      null,
-      {
-        "info": {
-          "db_name": "test",
-          "doc_count": 8,
-          "doc_del_count": 0,
-          "update_seq": 105,
-          "purge_seq": 0,
-          "compact_running": false,
-          "disk_size": 15818856,
-          "data_size": 1535048,
-          "instance_start_time": "1359952188595857",
-          "disk_format_version": 6,
-          "committed_update_seq": 105
-        },
-        "id": null,
-        "uuid": "169cb4cc82427cc7322cb4463d0021bb",
-        "method": "GET",
-        "requested_path": [
-          "api",
-          "_design",
-          "temp",
-          "_show",
-          "request"
-        ],
-        "path": [
-          "api",
-          "_design",
-          "temp",
-          "_show",
-          "request"
+        "ddoc",
+        "_design/temp",
+        [
+            "shows",
+            "doc"
         ],
-        "raw_path": "/api/_design/temp/_show/request",
-        "query": {},
-        "headers": {
-          "Accept": "*/*",
-          "Host": "localhost:5984",
-          "User-Agent": "curl/7.26.0"
-        },
-        "body": "undefined",
-        "peer": "127.0.0.1",
-        "form": {},
-        "cookie": {},
-        "userCtx": {
-          "db": "api",
-          "name": null,
-          "roles": [
-            "_admin"
-          ]
-        },
-        "secObj": {}
-      }
+        [
+            null,
+            {
+                "info": {
+                    "db_name": "test",
+                    "doc_count": 8,
+                    "doc_del_count": 0,
+                    "update_seq": 105,
+                    "purge_seq": 0,
+                    "compact_running": false,
+                    "disk_size": 15818856,
+                    "data_size": 1535048,
+                    "instance_start_time": "1359952188595857",
+                    "disk_format_version": 6,
+                    "committed_update_seq": 105
+                },
+                "id": null,
+                "uuid": "169cb4cc82427cc7322cb4463d0021bb",
+                "method": "GET",
+                "requested_path": [
+                    "api",
+                    "_design",
+                    "temp",
+                    "_show",
+                    "request"
+                ],
+                "path": [
+                    "api",
+                    "_design",
+                    "temp",
+                    "_show",
+                    "request"
+                ],
+                "raw_path": "/api/_design/temp/_show/request",
+                "query": {},
+                "headers": {
+                    "Accept": "*/*",
+                    "Host": "localhost:5984",
+                    "User-Agent": "curl/7.26.0"
+                },
+                "body": "undefined",
+                "peer": "127.0.0.1",
+                "form": {},
+                "cookie": {},
+                "userCtx": {
+                    "db": "api",
+                    "name": null,
+                    "roles": [
+                        "_admin"
+                    ]
+                },
+                "secObj": {}
+            }
+        ]
     ]
-  ]
 
 The Query Server sends::
 
-  [
-    "resp",
-    {
-      "body": "Hello, undefined!"
-    }
-  ]
-
+    [
+        "resp",
+        {
+            "body": "Hello, undefined!"
+        }
+    ]
 
 .. _qs/ddoc/lists:
 
@@ -432,8 +422,8 @@ The Query Server sends::
 :SubCommand: ``lists``
 :Arguments:
 
-  - :ref:`view_head_info_object`:
-  - :ref:`request_object`
+    - :ref:`view_head_info_object`:
+    - :ref:`request_object`
 
 :Returns: Array. See below for details.
 
@@ -444,23 +434,23 @@ an example for illustration.
 
 Let's assume that we have view a function that emits `id-rev` pairs::
 
-  function(doc) {
-    emit(doc._id, doc._rev);
-  }
+    function(doc) {
+        emit(doc._id, doc._rev);
+    }
 
 And we'd like to emulate ``_all_docs`` JSON response with list function. Our
 *first* version of the list functions looks like this::
 
-  function(head, req){
-    start({'headers': {'Content-Type': 'application/json'}});
-    var resp = head;
-    var rows = [];
-    while(row=getRow()){
-      rows.push(row);
+    function(head, req){
+        start({'headers': {'Content-Type': 'application/json'}});
+        var resp = head;
+        var rows = [];
+        while(row=getRow()){
+            rows.push(row);
+        }
+        resp.rows = rows;
+        return toJSON(resp);
     }
-    resp.rows = rows;
-    return toJSON(resp);
-  }
 
 The whole communication session during list function execution could be divided
 on three parts:
@@ -469,7 +459,7 @@ on three parts:
 
    The first returned object from list function is an array of next structure::
 
-      ["start", <chunks>, <headers>]
+       ["start", <chunks>, <headers>]
 
    Where ``<chunks>`` is an array of text chunks that will be sent to client
    and ``<headers>`` is an object with response HTTP headers.
@@ -477,15 +467,15 @@ on three parts:
    This message is sent from the Query Server to CouchDB on the
    :js:func:`start` call which initialize HTTP response to the client::
 
-     [
-       "start",
-       [],
-       {
-         "headers": {
-           "Content-Type": "application/json"
-         }
-       }
-     ]
+       [
+           "start",
+           [],
+           {
+               "headers": {
+                   "Content-Type": "application/json"
+               }
+           }
+       ]
 
    After this, the list function may start to process view rows.
 
@@ -498,29 +488,28 @@ on three parts:
 
    CouchDB sends a special array that carries view row data::
 
-     [
-       "list_row",
-       {
-         "id": "0cb42c267fe32d4b56b3500bc503e030",
-         "key": "0cb42c267fe32d4b56b3500bc503e030",
-         "value": "1-967a00dff5e02add41819138abb3284d"
-       }
-     ]
+       [
+           "list_row",
+           {
+               "id": "0cb42c267fe32d4b56b3500bc503e030",
+               "key": "0cb42c267fe32d4b56b3500bc503e030",
+               "value": "1-967a00dff5e02add41819138abb3284d"
+           }
+       ]
 
    If Query Server has something to return on this, it returns an array with a
    ``"chunks"`` item in the head and an array of data in the tail. Now, for our
    case it has nothing to return, so the response will be::
 
-     [
-       "chunks",
-       []
-     ]
+       [
+         "chunks",
+         []
+       ]
 
    When there is no more view rows to process, CouchDB sends special message,
    that signs about that there is no more data to send from its side::
 
-     ["list_end"]
-
+       ["list_end"]
 
 #. Finalization
 
@@ -530,12 +519,12 @@ on three parts:
 
    For our example the last message will be the next::
 
-     [
-       "end",
        [
-         "{\"total_rows\":2,\"offset\":0,\"rows\":[{\"id\":\"0cb42c267fe32d4b56b3500bc503e030\",\"key\":\"0cb42c267fe32d4b56b3500bc503e030\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"},{\"id\":\"431926a69504bde41851eb3c18a27b1f\",\"key\":\"431926a69504bde41851eb3c18a27b1f\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}]}"
+           "end",
+           [
+               "{\"total_rows\":2,\"offset\":0,\"rows\":[{\"id\":\"0cb42c267fe32d4b56b3500bc503e030\",\"key\":\"0cb42c267fe32d4b56b3500bc503e030\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"},{\"id\":\"431926a69504bde41851eb3c18a27b1f\",\"key\":\"431926a69504bde41851eb3c18a27b1f\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}]}"
+           ]
        ]
-     ]
 
 There, we had made a big mistake: we had returned out result in a single
 message from the Query Server. That's ok when there are only a few rows in the
@@ -544,33 +533,33 @@ rows
 
 Let's fix our list function and see the changes in communication::
 
-  function(head, req){
-    start({'headers': {'Content-Type': 'application/json'}});
-    send('{');
-    send('"total_rows":' + toJSON(head.total_rows) + ',');
-    send('"offset":' + toJSON(head.offset) + ',');
-    send('"rows":[');
-    if (row=getRow()){
-      send(toJSON(row));
-    }
-    while(row=getRow()){
-      send(',' + toJSON(row));
+    function(head, req){
+        start({'headers': {'Content-Type': 'application/json'}});
+        send('{');
+        send('"total_rows":' + toJSON(head.total_rows) + ',');
+        send('"offset":' + toJSON(head.offset) + ',');
+        send('"rows":[');
+        if (row=getRow()){
+            send(toJSON(row));
+        }
+        while(row=getRow()){
+            send(',' + toJSON(row));
+        }
+        send(']');
+        return '}';
     }
-    send(']');
-    return '}';
-  }
 
 "Wait, what?" - you'd like to ask. Yes, we'd build JSON response manually by
 string chunks, but let's take a look on logs::
 
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["start",["{","\"total_rows\":2,","\"offset\":0,","\"rows\":["],{"headers":{"Content-Type":"application/json"}}]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [info] [<0.18963.1>] 127.0.0.1 - - GET /blog/_design/post/_list/index/all_docs 200
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_row",{"id":"0cb42c267fe32d4b56b3500bc503e030","key":"0cb42c267fe32d4b56b3500bc503e030","value":"1-967a00dff5e02add41819138abb3284d"}]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["chunks",["{\"id\":\"0cb42c267fe32d4b56b3500bc503e030\",\"key\":\"0cb42c267fe32d4b56b3500bc503e030\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}"]]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_row",{"id":"431926a69504bde41851eb3c18a27b1f","key":"431926a69504bde41851eb3c18a27b1f","value":"1-967a00dff5e02add41819138abb3284d"}]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["chunks",[",{\"id\":\"431926a69504bde41851eb3c18a27b1f\",\"key\":\"431926a69504bde41851eb3c18a27b1f\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}"]]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_end"]
-  [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["end",["]","}"]]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["start",["{","\"total_rows\":2,","\"offset\":0,","\"rows\":["],{"headers":{"Content-Type":"application/json"}}]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [info] [<0.18963.1>] 127.0.0.1 - - GET /blog/_design/post/_list/index/all_docs 200
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_row",{"id":"0cb42c267fe32d4b56b3500bc503e030","key":"0cb42c267fe32d4b56b3500bc503e030","value":"1-967a00dff5e02add41819138abb3284d"}]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["chunks",["{\"id\":\"0cb42c267fe32d4b56b3500bc503e030\",\"key\":\"0cb42c267fe32d4b56b3500bc503e030\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}"]]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_row",{"id":"431926a69504bde41851eb3c18a27b1f","key":"431926a69504bde41851eb3c18a27b1f","value":"1-967a00dff5e02add41819138abb3284d"}]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["chunks",[",{\"id\":\"431926a69504bde41851eb3c18a27b1f\",\"key\":\"431926a69504bde41851eb3c18a27b1f\",\"value\":\"1-967a00dff5e02add41819138abb3284d\"}"]]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Input  :: ["list_end"]
+    [Wed, 24 Jul 2013 05:45:30 GMT] [debug] [<0.19191.1>] OS Process #Port<0.4444> Output :: ["end",["]","}"]]
 
 Note, that now the Query Server sends response by lightweight chunks and if
 our communication process was extremely slow, the client will see how response
@@ -586,14 +575,14 @@ result, like they have for our previous list function.
 :SubCommand: ``updates``
 :Arguments:
 
-  - Document object or ``null`` if document `id` wasn't specified in request
-  - :ref:`request_object`
+    - Document object or ``null`` if document `id` wasn't specified in request
+    - :ref:`request_object`
 
 :Returns: Array with there elements:
 
-  - ``"up"``
-  - Document object or ``null`` if nothing should be stored
-  - :ref:`response_object`
+    - ``"up"``
+    - Document object or ``null`` if nothing should be stored
+    - :ref:`response_object`
 
 Executes :ref:`update function <updatefun>`.
 
@@ -665,23 +654,22 @@ CouchDB sends::
 
 The Query Server answers::
 
-  [
-    "up",
-    null,
-    {"body": "document id wasn't provided"}
-  ]
+    [
+        "up",
+        null,
+        {"body": "document id wasn't provided"}
+    ]
 
 or in case of successful update::
 
-  [
-    "up",
-    {
-      "_id": "7b695cb34a03df0316c15ab529002e69",
-      "hello": "world!"
-    },
-    {"body": "document was updated"}
-  ]
-
+    [
+        "up",
+        {
+            "_id": "7b695cb34a03df0316c15ab529002e69",
+            "hello": "world!"
+        },
+        {"body": "document was updated"}
+    ]
 
 .. _qs/ddoc/filters:
 
@@ -692,112 +680,110 @@ or in case of successful update::
 :SubCommand: ``filters``
 :Arguments:
 
-  - Array of document objects
-  - :ref:`request_object`
+    - Array of document objects
+    - :ref:`request_object`
 
 :Returns: Array of two elements:
 
-  - ``true``
-  - Array of booleans in the same order of input documents.
+    - ``true``
+    - Array of booleans in the same order of input documents.
 
 Executes :ref:`filter function <filterfun>`.
 
 CouchDB sends::
 
-  [
-      "ddoc",
-      "_design/test",
-      [
-          "filters",
-          "random"
-      ],
-      [
-          [
-              {
-                  "_id": "431926a69504bde41851eb3c18a27b1f",
-                  "_rev": "1-967a00dff5e02add41819138abb3284d",
-                  "_revisions": {
-                      "start": 1,
-                      "ids": [
-                          "967a00dff5e02add41819138abb3284d"
-                      ]
-                  }
-              },
-              {
-                  "_id": "0cb42c267fe32d4b56b3500bc503e030",
-                  "_rev": "1-967a00dff5e02add41819138abb3284d",
-                  "_revisions": {
-                      "start": 1,
-                      "ids": [
-                          "967a00dff5e02add41819138abb3284d"
-                      ]
-                  }
-              }
-          ],
-          {
-              "info": {
-                  "db_name": "test",
-                  "doc_count": 5,
-                  "doc_del_count": 0,
-                  "update_seq": 19,
-                  "purge_seq": 0,
-                  "compact_running": false,
-                  "disk_size": 8056936,
-                  "data_size": 7979745,
-                  "instance_start_time": "1374612186131612",
-                  "disk_format_version": 6,
-                  "committed_update_seq": 19
-              },
-              "id": null,
-              "uuid": "7b695cb34a03df0316c15ab529023a81",
-              "method": "GET",
-              "requested_path": [
-                  "test",
-                  "_changes?filter=test",
-                  "random"
-              ],
-              "path": [
-                  "test",
-                  "_changes"
-              ],
-              "raw_path": "/test/_changes?filter=test/random",
-              "query": {
-                  "filter": "test/random"
-              },
-              "headers": {
-                  "Accept": "application/json",
-                  "Accept-Encoding": "identity, gzip, deflate, compress",
-                  "Content-Length": "0",
-                  "Content-Type": "application/json; charset=utf-8",
-                  "Host": "localhost:5984"
-              },
-              "body": "",
-              "peer": "127.0.0.1",
-              "form": {},
-              "cookie": {},
-              "userCtx": {
-                  "db": "test",
-                  "name": null,
-                  "roles": [
-                      "_admin"
-                  ]
-              },
-              "secObj": {}
-          }
-      ]
-  ]
+    [
+        "ddoc",
+        "_design/test",
+        [
+            "filters",
+            "random"
+        ],
+        [
+            [
+                {
+                    "_id": "431926a69504bde41851eb3c18a27b1f",
+                    "_rev": "1-967a00dff5e02add41819138abb3284d",
+                    "_revisions": {
+                        "start": 1,
+                        "ids": [
+                            "967a00dff5e02add41819138abb3284d"
+                        ]
+                    }
+                },
+                {
+                    "_id": "0cb42c267fe32d4b56b3500bc503e030",
+                    "_rev": "1-967a00dff5e02add41819138abb3284d",
+                    "_revisions": {
+                        "start": 1,
+                        "ids": [
+                            "967a00dff5e02add41819138abb3284d"
+                        ]
+                    }
+                }
+            ],
+            {
+                "info": {
+                    "db_name": "test",
+                    "doc_count": 5,
+                    "doc_del_count": 0,
+                    "update_seq": 19,
+                    "purge_seq": 0,
+                    "compact_running": false,
+                    "disk_size": 8056936,
+                    "data_size": 7979745,
+                    "instance_start_time": "1374612186131612",
+                    "disk_format_version": 6,
+                    "committed_update_seq": 19
+                },
+                "id": null,
+                "uuid": "7b695cb34a03df0316c15ab529023a81",
+                "method": "GET",
+                "requested_path": [
+                    "test",
+                    "_changes?filter=test",
+                    "random"
+                ],
+                "path": [
+                    "test",
+                    "_changes"
+                ],
+                "raw_path": "/test/_changes?filter=test/random",
+                "query": {
+                    "filter": "test/random"
+                },
+                "headers": {
+                    "Accept": "application/json",
+                    "Accept-Encoding": "identity, gzip, deflate, compress",
+                    "Content-Length": "0",
+                    "Content-Type": "application/json; charset=utf-8",
+                    "Host": "localhost:5984"
+                },
+                "body": "",
+                "peer": "127.0.0.1",
+                "form": {},
+                "cookie": {},
+                "userCtx": {
+                    "db": "test",
+                    "name": null,
+                    "roles": [
+                        "_admin"
+                    ]
+                },
+                "secObj": {}
+            }
+        ]
+    ]
 
 The Query Server answers::
 
-  [
-    true,
     [
-      true,
-      false
+        true,
+        [
+            true,
+            false
+        ]
     ]
-  ]
-
-
 
 .. _qs/ddoc/views:
 
@@ -809,8 +795,8 @@ The Query Server answers::
 :Arguments: Array of document objects
 :Returns: Array of two elements:
 
-  - ``true``
-  - Array of booleans in the same order of input documents.
+    - ``true``
+    - Array of booleans in the same order of input documents.
 
 .. versionadded:: 1.2
 
@@ -827,10 +813,10 @@ Acts in the same way as :ref:`qs/ddoc/filters` command.
 :SubCommand: ``validate_doc_update``
 :Arguments:
 
-  - Document object that will be stored
-  - Document object that will be replaced
-  - :ref:`userctx_object`
-  - :ref:`security_object`
+    - Document object that will be stored
+    - Document object that will be replaced
+    - :ref:`userctx_object`
+    - :ref:`security_object`
 
 :Returns: ``1``
 
@@ -838,43 +824,41 @@ Executes :ref:`validation function <vdufun>`.
 
 CouchDB send::
 
-  [
-    "ddoc",
-    "_design/id",
-    ["validate_doc_update"],
     [
-      {
-        "_id": "docid",
-        "_rev": "2-e0165f450f6c89dc6b071c075dde3c4d",
-        "score": 10
-      },
-      {
-        "_id": "docid",
-        "_rev": "1-9f798c6ad72a406afdbf470b9eea8375",
-        "score": 4
-      },
-      {
-        "name": "Mike",
-        "roles": ["player"]
-      },
-      {
-        "admins": {},
-        "members": []
-      }
+        "ddoc",
+        "_design/id",
+        ["validate_doc_update"],
+        [
+            {
+                "_id": "docid",
+                "_rev": "2-e0165f450f6c89dc6b071c075dde3c4d",
+                "score": 10
+            },
+            {
+                "_id": "docid",
+                "_rev": "1-9f798c6ad72a406afdbf470b9eea8375",
+                "score": 4
+            },
+            {
+                "name": "Mike",
+                "roles": ["player"]
+            },
+            {
+                "admins": {},
+                "members": []
+            }
+        ]
     ]
-  ]
 
 The Query Server answers::
 
-  1
+    1
 
 .. note::
-
-   While the only valid response for this command is ``true`` to prevent
-   document save the Query Server need to raise an error: ``forbidden`` or
-   ``unauthorized`` - these errors will be turned into correct ``HTTP 403`` and
-   ``HTTP 401`` responses respectively.
-
+    While the only valid response for this command is ``true`` to prevent
+    document save the Query Server need to raise an error: ``forbidden`` or
+    ``unauthorized`` - these errors will be turned into correct ``HTTP 403`` and
+    ``HTTP 401`` responses respectively.
 
 .. _qs/errors:
 
@@ -904,7 +888,7 @@ to CouchDB. All errors are logically divided into two groups:
 
 To raise an error, the Query Server have to answer::
 
-  ["error", "error_name", "reason why"]
+    ["error", "error_name", "reason why"]
 
 The ``"error_name"`` helps to classify problems by their type e.g. if it's
 ``"value_error"`` so probably user have entered wrong data, ``"not_found"``
@@ -914,11 +898,10 @@ invalid and non expected input from user.
 The ``"reason why"`` is the error message that explains why it raised and, if
 possible, what is needed to do to fix it.
 
-For example, calling :ref:`updatefun` against non existent document could produce
-next error message::
-
-  ["error", "not_found", "Update function requires existent document"]
+For example, calling :ref:`updatefun` against non existent document could
+produce next error message::
 
+    ["error", "not_found", "Update function requires existent document"]
 
 .. _qs/error/forbidden:
 
@@ -933,8 +916,7 @@ with error information object.
 
 To raise this error, the Query Server have to answer::
 
-  {"forbidden": "reason why"}
-
+    {"forbidden": "reason why"}
 
 .. _qs/error/unauthorized:
 
@@ -949,7 +931,7 @@ information object.
 
 To raise this error, the Query Server have to answer::
 
-  {"unauthorized": "reason why"}
+    {"unauthorized": "reason why"}
 
 .. _qs/log:
 
@@ -960,10 +942,10 @@ At any time, the Query Server may send some information that will be saved in
 CouchDB's log file. This is done by sending a special object with just one
 field, log, on a separate line::
 
-  ["log", "some message"]
+    ["log", "some message"]
 
 CouchDB responds nothing, but writes received message into log file::
 
-  [Sun, 13 Feb 2009 23:31:30 GMT] [info] [<0.72.0>] Query Server Log Message: some message
+    [Sun, 13 Feb 2009 23:31:30 GMT] [info] [<0.72.0>] Query Server Log Message: some message
 
 These messages are only logged at :config:option:`info level <log/level>`.


Mime
View raw message