{"id":12438,"url":"https://patchwork.libcamera.org/api/patches/12438/?format=json","web_url":"https://patchwork.libcamera.org/patch/12438/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210527072805.1333870-2-paul.elder@ideasonboard.com>","date":"2021-05-27T07:28:01","name":"[libcamera-devel,v3,1/5] utils: ipc: Add script to extract doxygen docs from mojom files","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a5ba9769c6cfd609be311eed2007152bc38678eb","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12438/mbox/","series":[{"id":2080,"url":"https://patchwork.libcamera.org/api/series/2080/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2080","date":"2021-05-27T07:28:00","name":"Generate docs from mojom files","version":3,"mbox":"https://patchwork.libcamera.org/series/2080/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12438/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12438/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 20BD7C3203\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 07:28:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D41C668926;\n\tThu, 27 May 2021 09:28:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 05B8D68922\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 09:28:20 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A17AF8DE;\n\tThu, 27 May 2021 09:28:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ugexjRnM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622100499;\n\tbh=tMfrxX9B2T9sVXPgvMxRyLpEATqYD49uGqyijlbGOjo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=ugexjRnMgrCkWhk2FneESFv9a/YHCoVzLgBTOQXjOfiJOC6nn/Ewdhje6aQUjUOAD\n\tN0tWhuXT57qpjvjlWss0E0a8GHZp/pkHZ1OJYLJ80evvAeVkB3pqLrEtGsj0FR1j0E\n\t2/xDXzOVxM5vTX9R+01O5LXBBhhrV+joBWa1k5lk=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 27 May 2021 16:28:01 +0900","Message-Id":"<20210527072805.1333870-2-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20210527072805.1333870-1-paul.elder@ideasonboard.com>","References":"<20210527072805.1333870-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/5] utils: ipc: Add script to extract\n\tdoxygen docs from mojom files","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a script to extract doxygen documentation comments from mojom files.\nIt matches based on ^\\/\\*\\*$ for start of block and ^ \\*\\/$ for end of\nblock, and simply copies the comments to the output file along with a\nheader and the libcamera namespace.\n\nAlso add it to the meson file so it is usable by other meson files.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nAcked-by: Umang Jain <umang.jain@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/ipc/extract-docs.py | 74 +++++++++++++++++++++++++++++++++++++++\n utils/ipc/meson.build     |  2 ++\n 2 files changed, 76 insertions(+)\n create mode 100755 utils/ipc/extract-docs.py","diff":"diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py\nnew file mode 100755\nindex 00000000..56566ce0\n--- /dev/null\n+++ b/utils/ipc/extract-docs.py\n@@ -0,0 +1,74 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Copyright (C) 2021, Google Inc.\n+#\n+# Author: Paul Elder <paul.elder@ideasonboard.com>\n+#\n+# extract-docs.py - Extract doxygen documentation from mojom files\n+\n+import argparse\n+import re\n+import sys\n+\n+regex_block_start = re.compile('^\\/\\*\\*$')\n+regex_block_end = re.compile('^ \\*\\/$')\n+\n+\n+def main(argv):\n+\n+    # Parse command line arguments\n+    parser = argparse.ArgumentParser()\n+    parser.add_argument('-o', dest='output', metavar='file',\n+                        type=argparse.FileType('w', encoding='utf-8'),\n+                        default=sys.stdout,\n+                        help='Output file name (default: standard output)')\n+    parser.add_argument('input', type=str,\n+                        help='Input file name.')\n+    args = parser.parse_args(argv[1:])\n+\n+    lines = open(args.input, 'r').readlines()\n+    pipeline = args.input.split('/')[-1].replace('.mojom', '')\n+    data = f'''\\\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * {pipeline}_ipa_interface.cpp - Docs file for generated {pipeline}.mojom\n+ *\n+ * This file is auto-generated. Do not edit.\n+ */\n+\n+namespace libcamera {{\n+\n+'''\n+\n+    in_block = False\n+    comment = ''\n+    for lineno, line in enumerate(lines, start=1):\n+        if regex_block_start.match(line):\n+            if in_block:\n+                raise SyntaxError('Expected end of comment',\n+                                  (args.input, lineno, 1, line))\n+            in_block = True\n+            comment = line\n+            continue\n+\n+        if regex_block_end.match(line):\n+            if in_block:\n+                comment += line\n+                data += comment + '\\n'\n+            in_block = False\n+            continue\n+\n+        if in_block:\n+            comment += line\n+\n+    data += '} /* namespace libcamera */\\n'\n+\n+    args.output.write(data)\n+\n+    return 0\n+\n+\n+if __name__ == '__main__':\n+    sys.exit(main(sys.argv))\ndiff --git a/utils/ipc/meson.build b/utils/ipc/meson.build\nindex 4a41b9c1..973a5417 100644\n--- a/utils/ipc/meson.build\n+++ b/utils/ipc/meson.build\n@@ -8,6 +8,8 @@ mojom_parser = find_program('./parser.py')\n \n mojom_generator = find_program('./generate.py')\n \n+mojom_docs_extractor = find_program('./extract-docs.py')\n+\n mojom_templates = custom_target('mojom_templates',\n                                 input : mojom_template_files,\n                                 output : 'libcamera_templates.zip',\n","prefixes":["libcamera-devel","v3","1/5"]}