Arguments: <doc_id>

    Show document information (but not its content, see 'dump').
    See 'search' for the document id.

    Possible JSON replies:
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }
        --
        {
            "status": "ok",
            "type": "ImgDoc",
            "nb_pages": 3,
            "pages": [
                {"n": 1, "lines": 10, "words": 22},
                {"n": 2, "lines": 20, "words": 22},
                {"n": 3, "lines": 30, "words": 34},
            ],
            "labels": ["aaa", "bbb"],
            "first_line": "vwklsd wldkwq",
        }

def cmd_show(docid):
    """
    Arguments: <doc_id>

    Show document information (but not its content, see 'dump').
    See 'search' for the document id.

    Possible JSON replies:
        --
        {
            "status": "error", "exception": "yyy",
            "reason": "xxxx", "args": "(xxxx, )"
        }
        --
        {
            "status": "ok",
            "type": "ImgDoc",
            "nb_pages": 3,
            "pages": [
                {"n": 1, "lines": 10, "words": 22},
                {"n": 2, "lines": 20, "words": 22},
                {"n": 3, "lines": 30, "words": 34},
            ],
            "labels": ["aaa", "bbb"],
            "first_line": "vwklsd wldkwq",
        }
    """
    dsearch = get_docsearch()
    doc = dsearch.get(docid)
    r = {
        'type': str(type(doc)),
        'nb_pages': doc.nb_pages,
        'labels': [l.name for l in doc.labels],
        'first_line': _get_first_line(doc),
        'pages': []
    }
    for page in doc.pages:
        nb_lines = 0
        nb_words = 0
        for line in page.boxes:
            nb_lines += 1
            nb_words += len(line.word_boxes)
        r['pages'].append({
            "n": page.page_nb + 1,
            "lines": nb_lines,
            "words": nb_words,
        })
    reply(r)