[{"id":17322,"web_url":"https://patchwork.libcamera.org/comment/17322/","msgid":"<YK9fwYfJyT5HZUm2@pendragon.ideasonboard.com>","date":"2021-05-27T09:00:49","subject":"Re: [libcamera-devel] [PATCH v3 1/5] utils: ipc: Add script to\n\textract doxygen docs from mojom files","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Thu, May 27, 2021 at 04:28:01PM +0900, Paul Elder wrote:\n> Add a script to extract doxygen documentation comments from mojom files.\n> It matches based on ^\\/\\*\\*$ for start of block and ^ \\*\\/$ for end of\n> block, and simply copies the comments to the output file along with a\n> header and the libcamera namespace.\n> \n> Also add it to the meson file so it is usable by other meson files.\n> \n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> Acked-by: Umang Jain <umang.jain@ideasonboard.com>\n> Reviewed-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\n> \n> diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py\n> new file mode 100755\n> index 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\nThis could be done on top, but would it make sense to copy the SPDX\nheader from the mojom file ?\n\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))\n> diff --git a/utils/ipc/meson.build b/utils/ipc/meson.build\n> index 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',","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 30364BDB80\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 09:00:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EA16868924;\n\tThu, 27 May 2021 11:00:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2E3D68920\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 11:00:55 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6ADAFB2C;\n\tThu, 27 May 2021 11:00:55 +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=\"I1Xj96iQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622106055;\n\tbh=1k+TT7LMaJmSSNoiobTFWa1bM/URO8FM6adymhfMiDU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=I1Xj96iQGk6LhO9bkhnMeaQIQxufvDhNAW4cLDtAa7EXTy3eZ55jpnK1IG1L6mkjx\n\tYB0g2BfoNZ0oCm27wTKqfuxeJTnDGhtDrcvwW1IAztHzD6qpHpjHnRscPxUrtuWR3Y\n\tEF03hOphfOmxcwqgvbEgCCAN+lavzf9OP88jbeeg=","Date":"Thu, 27 May 2021 12:00:49 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YK9fwYfJyT5HZUm2@pendragon.ideasonboard.com>","References":"<20210527072805.1333870-1-paul.elder@ideasonboard.com>\n\t<20210527072805.1333870-2-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210527072805.1333870-2-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/5] utils: ipc: Add script to\n\textract doxygen 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17325,"web_url":"https://patchwork.libcamera.org/comment/17325/","msgid":"<20210527091948.GH1274010@pyrite.rasen.tech>","date":"2021-05-27T09:19:48","subject":"Re: [libcamera-devel] [PATCH v3 1/5] utils: ipc: Add script to\n\textract doxygen docs from mojom files","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Thu, May 27, 2021 at 12:00:49PM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Thu, May 27, 2021 at 04:28:01PM +0900, Paul Elder wrote:\n> > Add a script to extract doxygen documentation comments from mojom files.\n> > It matches based on ^\\/\\*\\*$ for start of block and ^ \\*\\/$ for end of\n> > block, and simply copies the comments to the output file along with a\n> > header and the libcamera namespace.\n> > \n> > Also add it to the meson file so it is usable by other meson files.\n> > \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > Acked-by: Umang Jain <umang.jain@ideasonboard.com>\n> > Reviewed-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\n> > \n> > diff --git a/utils/ipc/extract-docs.py b/utils/ipc/extract-docs.py\n> > new file mode 100755\n> > index 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> This could be done on top, but would it make sense to copy the SPDX\n> header from the mojom file ?\n\nOops, yeah, that would be good.\n\nI'll do it on top.\n\n\nPaul\n\n> \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))\n> > diff --git a/utils/ipc/meson.build b/utils/ipc/meson.build\n> > index 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> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 87670BDB80\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 09:19:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C284D68923;\n\tThu, 27 May 2021 11:19:56 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD77C602AA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 11:19:55 +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 F072DB2C;\n\tThu, 27 May 2021 11:19:53 +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=\"KFbbz1U9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1622107195;\n\tbh=1Ew9lPy6U1fkiisO90pfEy/Pf3W75WnQfEH6BOF9wfI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=KFbbz1U9z6Oou1ytlJ5hxYR4z4jgs/E8KqnA7tBOErFBuyAaFOqqTVDm1WJPbrCu4\n\t13dSi4UcoaRSMcct9HzQE6uYvHMasMgwZFxJEZMGcJHvmdvgTajqigsat1hApop7zJ\n\twPG/QW85jyRXLIBHtdCROVbjxR+iCZU7Ek8a30kk=","Date":"Thu, 27 May 2021 18:19:48 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210527091948.GH1274010@pyrite.rasen.tech>","References":"<20210527072805.1333870-1-paul.elder@ideasonboard.com>\n\t<20210527072805.1333870-2-paul.elder@ideasonboard.com>\n\t<YK9fwYfJyT5HZUm2@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<YK9fwYfJyT5HZUm2@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 1/5] utils: ipc: Add script to\n\textract doxygen 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]