On 4/7/2021 11:33 PM, Thomas Monjalon wrote:
> The script check-doc-vs-code.sh may be used to add
> some automatic checks of the doc.
> 
> If run without any argument, a complete check is done.
> The optional argument is a git history reference point
> to check faster only what has changed since this commit.
> 
> In this commit, the only check is for rte_flow tables,
> achieved through the script parse-flow-support.sh.
> If run without a .ini reference, it prints rte_flow tables.
> Note: detected features are marked with the value Y,
> while the real .ini file could have special values like I.
> The script allow parsing exceptions (exclude or include),
> like for bnxt code which lists unsupported items and actions.
> 

Thanks for the scripts.

> Signed-off-by: Thomas Monjalon <tho...@monjalon.net>
> ---
>  devtools/check-doc-vs-code.sh  | 79 ++++++++++++++++++++++++++++++++++
>  devtools/parse-flow-support.sh | 76 ++++++++++++++++++++++++++++++++
>  2 files changed, 155 insertions(+)
>  create mode 100755 devtools/check-doc-vs-code.sh
>  create mode 100755 devtools/parse-flow-support.sh
> 
> diff --git a/devtools/check-doc-vs-code.sh b/devtools/check-doc-vs-code.sh
> new file mode 100755
> index 0000000000..6e53d66899
> --- /dev/null
> +++ b/devtools/check-doc-vs-code.sh
> @@ -0,0 +1,79 @@
> +#! /bin/sh -e
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2021 Mellanox Technologies, Ltd
> +
> +# Check whether doc & code are in sync.
> +# Optional argument: check only what changed since a commit.
> +trusted_commit=$1 # example: origin/main
> +
> +selfdir=$(dirname $(readlink -f $0))
> +rootdir=$(readlink -f $selfdir/..)
> +
> +result=0
> +
> +# speed up by ignoring Unicode details
> +export LC_COLLATE=C
> +
> +changed_files()
> +{
> +     [ -n "$files" ] ||
> +             files=$(git diff-tree --name-only -r $trusted_commit..)
> +     echo "$files"
> +}
> +
> +has_code_change() # <pattern>
> +{
> +     test -n "$(git log --format='%h' -S"$1" $trusted_commit..)"
> +}
> +
> +has_file_change() # <pattern>
> +{
> +     changed_files | grep -q "$1"
> +}
> +
> +changed_net_drivers()
> +{
> +     net_paths='drivers/net/|doc/guides/nics/features/'
> +     [ -n "$drivers" ] ||
> +             drivers=$(changed_files |
> +                     sed -rn "s,^($net_paths)([^./]*).*,\2,p")
> +     echo "$drivers"
> +}

I will not reviewed in details yet, but first observation,
when 'trusted_commit' argument is used, the drivers list has many duplicated
entries which makes the output redundant and makes script take too much time.
Getting only unique list may help on it.

Reply via email to