From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AF373A04FF; Thu, 31 Mar 2022 23:29:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C15C4291B; Thu, 31 Mar 2022 23:28:59 +0200 (CEST) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mails.dpdk.org (Postfix) with ESMTP id 05A0442906 for ; Thu, 31 Mar 2022 23:28:56 +0200 (CEST) Received: by mail-lf1-f53.google.com with SMTP id m3so1398586lfj.11 for ; Thu, 31 Mar 2022 14:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FVAukTJH18Iz4PBvgHAgcL0tigKWWbbX4DDbFW4cEn4=; b=efqI/zeSNSxu+14yiy8Amxt3zKij6F/GJ/kD/eKeeCm/t9Vrw6pExQ+WwmOO1eee2X gOdDDEe6x+1dq0N24ZNKAEyqzrcPyNJ0VeVRf55u6QKRRP76HxehdPTsYKGhhkTRYkv4 7RfOYvNrCKnEV2wHfIVEekxhaedvCFLRvHT0/cbuYZBvTI42F2JHhcF0o9q42zrrXnpp t7M0gEmG1f9JIYRK0UAHoD7QR3BWYq72OkQV+YIwLnmfPaP8ZYvCkeZnEc8rcNh5G5uq vktzhoRiXkNR9ZdC/e4eFyTwr5eMeUuuoAXPbEAXpdzAIzzXl0WIvAfXb+4eQoB+klsa ANjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FVAukTJH18Iz4PBvgHAgcL0tigKWWbbX4DDbFW4cEn4=; b=RgJI3xofs5b3fWAtsMPxKVfWS0pawe7S6OCzuWCHgF+3FbmbFNVIeJjRnHyYY0tr5G ymTr/MTaCMGD7b+D6mUCxz03gEpa2IO9aGImjBZs06TKp9iyS6tSzn00p3uAdXr5sS/Z y05E0UV5UQUcK677p0Dwh50f1Cm/ui/NLTM+fv8M2Gb97GCwDun7xCMzYigkh3zTUBqw /Fb05nUURzyFP1fpwiZtEdrQbeZX1NkkMpnbT/MAdtk1jnvrFR3G9Tm2B8xp5wD0BBrC VrnKlCQERCB0CQSbFkSfzRBX78HcfRwfV/4+KfK/LrZgLLarPA3/C3sBJjRY3IZ4LYCf vD9w== X-Gm-Message-State: AOAM531ba/LCAIE1BbcnDGjmCXHJzZ1Z0sDx9XxYjUSd8I9Fh5zWFHcC 2Abt1In2SGaNsnQNehkvOVa1t7oGiuQ= X-Google-Smtp-Source: ABdhPJwNRiejVpAh+DcNKXWMOnj96gEDAvybASUAYptjInXu0sYwY6VT3YeTETk808FeI1j8kFEshg== X-Received: by 2002:a05:6512:3b2c:b0:44a:35fd:994c with SMTP id f44-20020a0565123b2c00b0044a35fd994cmr11822709lfv.473.1648762135344; Thu, 31 Mar 2022 14:28:55 -0700 (PDT) Received: from sovereign.. (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id o7-20020ac24c47000000b0044a15c4e0aesm47567lfk.272.2022.03.31.14.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 14:28:54 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Vipin Varghese , Dmitry Kozlyuk Subject: [PATCH 3/3] doc: rewrite shell scripts in Python Date: Fri, 1 Apr 2022 00:28:30 +0300 Message-Id: <20220331212830.708912-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20220331212830.708912-1-dmitry.kozliuk@gmail.com> References: <20220331212830.708912-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Shell used in documentation generation could not run on Windows. Rewrite scripts in Python. New scripts use proper path separators and handle paths with spaces. Signed-off-by: Dmitry Kozlyuk --- doc/api/generate_doxygen.py | 19 +++++++++++++++++++ doc/api/generate_doxygen.sh | 12 ------------ doc/api/generate_examples.py | 31 +++++++++++++++++++++++++++++++ doc/api/generate_examples.sh | 20 -------------------- doc/api/meson.build | 6 +++--- 5 files changed, 53 insertions(+), 35 deletions(-) create mode 100644 doc/api/generate_doxygen.py delete mode 100755 doc/api/generate_doxygen.sh create mode 100644 doc/api/generate_examples.py delete mode 100755 doc/api/generate_examples.sh diff --git a/doc/api/generate_doxygen.py b/doc/api/generate_doxygen.py new file mode 100644 index 0000000000..2ccedf844e --- /dev/null +++ b/doc/api/generate_doxygen.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# (c) 2018 Luca Boccassi +# (c) 2022 Dmitry Kozlyuk + +import os, re, subprocess, sys + +pattern = re.compile('^Preprocessing (.*)...$') +out_dir, *doxygen_command = sys.argv[1:] +out_file = os.path.join(os.path.dirname(out_dir), 'doxygen.out') +dep_file = f'{out_dir}.d' +with open(out_file, 'w') as out: + subprocess.run(doxygen_command, check=True, stdout=out) +with open(out_file) as out, open(dep_file, 'w') as dep: + print(f'{out_dir}:', end=' ', file=dep) + for line in out: + match = re.match(pattern, line) + if match: + print(match.group(1), end=' ', file=dep) diff --git a/doc/api/generate_doxygen.sh b/doc/api/generate_doxygen.sh deleted file mode 100755 index 1940ea46e2..0000000000 --- a/doc/api/generate_doxygen.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 Luca Boccassi - -DOXYCONF=$1 -OUTDIR=$2 - -OUT_FILE=$(dirname $OUTDIR)/doxygen.out - -# run doxygen, capturing all the header files it processed -doxygen "${DOXYCONF}" > $OUT_FILE -echo "$OUTDIR: $(awk '/Preprocessing/ {printf("%s ", substr($2, 1, length($2) - 3))}' $OUT_FILE)" > $OUTDIR.d diff --git a/doc/api/generate_examples.py b/doc/api/generate_examples.py new file mode 100644 index 0000000000..66933f9472 --- /dev/null +++ b/doc/api/generate_examples.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: BSD-3-Clause +# (c) 2018 Luca Boccassi +# (c) 2022 Dmitry Kozlyuk + +import os, sys + +examples_dir, api_examples = sys.argv[1:] + +sources = [] +with open(f'{api_examples}.d', 'w') as dep: + print(f'{api_examples}:', end=' ', file=dep) + for root, _, files in os.walk(examples_dir): + for name in files: + is_source = name.endswith('.c') + if is_source or name == 'meson.meson.build': + path = os.path.join(root, name) + if is_source: + sources.append(path) + print(path , end=' ', file=dep) + +sys.stdout = open(api_examples, 'w') +print('/**') +print('@page examples DPDK Example Programs') +print() +for path in sources: + # Produce consistent output with forward slashes on all systems. + # Every \ in paths within examples directory is a separator, not escape. + relpath = os.path.relpath(path, examples_dir).replace('\\', '/') + print(f'@example examples/{relpath}') +print('*/') diff --git a/doc/api/generate_examples.sh b/doc/api/generate_examples.sh deleted file mode 100755 index 48574563ca..0000000000 --- a/doc/api/generate_examples.sh +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh -e -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2018 Luca Boccassi - -EXAMPLES_DIR=$1 -API_EXAMPLES=$2 - -FIND=find - -# generate a .d file including both C files and also build files, so we can -# detect both file changes and file additions/deletions -echo "$API_EXAMPLES: $($FIND ${EXAMPLES_DIR} -type f \( -name '*.c' -o -name 'meson.build' \) | tr '\n' ' ' )" > ${API_EXAMPLES}.d - -exec > "${API_EXAMPLES}" -printf '/**\n' -printf '@page examples DPDK Example Programs\n\n' -$FIND "${EXAMPLES_DIR}" -type f -name '*.c' | - sed "s|${EXAMPLES_DIR}|@example examples|" | - LC_ALL=C sort -printf '*/\n' diff --git a/doc/api/meson.build b/doc/api/meson.build index 53338a02d6..2876a78a7e 100644 --- a/doc/api/meson.build +++ b/doc/api/meson.build @@ -11,8 +11,8 @@ endif # is in a subdirectory that is created at build time and thus it cannot # be an individual custom_target, we need to wrap the doxygen call in a # script to run the CSS modification afterwards -generate_doxygen = find_program('generate_doxygen.sh') -generate_examples = find_program('generate_examples.sh') +generate_doxygen = py3 + files('generate_doxygen.py') +generate_examples = py3 + files('generate_examples.py') htmldir = join_paths(get_option('datadir'), 'doc', 'dpdk') @@ -51,7 +51,7 @@ doxy_build = custom_target('doxygen', input: doxy_conf, output: 'html', depfile: 'html.d', - command: [generate_doxygen, '@INPUT@', '@OUTPUT@'], + command: [generate_doxygen, '@OUTPUT@', doxygen, '@INPUT@'], install: get_option('enable_docs'), install_dir: htmldir, build_by_default: get_option('enable_docs')) -- 2.29.3