[1/4] mk: use script to generate examples.dox

Message ID 20180831182055.30772-2-bluca@debian.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Meson: build Doxygen documentation |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Luca Boccassi Aug. 31, 2018, 6:20 p.m. UTC
  This will make it possible to generate the file in the same way from
Meson as well.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 doc/api/generate_examples.sh | 14 ++++++++++++++
 mk/rte.sdkdoc.mk             |  5 +----
 2 files changed, 15 insertions(+), 4 deletions(-)
 create mode 100755 doc/api/generate_examples.sh
  

Comments

Thomas Monjalon Sept. 3, 2018, 12:54 a.m. UTC | #1
31/08/2018 20:20, Luca Boccassi:
> +# SC2129 - avoid multiple individual redirects

What is SC2129 ?

> +{ \
> +    printf '/**\n'; \
> +    printf '@page examples DPDK Example Programs\n\n'; \
> +    find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example examples/%P\n' | LC_ALL=C sort; \
> +    printf '*/\n'; \
> +} > "${API_EXAMPLES}"

Why using backslashes (continuation lines)?
  
Luca Boccassi Sept. 3, 2018, 9:07 a.m. UTC | #2
On Mon, 2018-09-03 at 02:54 +0200, Thomas Monjalon wrote:
> 31/08/2018 20:20, Luca Boccassi:
> > +# SC2129 - avoid multiple individual redirects
> 
> What is SC2129 ?

shellcheck - will clarify in v2

> > +{ \
> > +    printf '/**\n'; \
> > +    printf '@page examples DPDK Example Programs\n\n'; \
> > +    find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example
> > examples/%P\n' | LC_ALL=C sort; \
> > +    printf '*/\n'; \
> > +} > "${API_EXAMPLES}"
> 
> Why using backslashes (continuation lines)?

Good point, will remove in v2
  
Bruce Richardson Sept. 7, 2018, 4:13 p.m. UTC | #3
On Mon, Sep 03, 2018 at 10:07:07AM +0100, Luca Boccassi wrote:
> On Mon, 2018-09-03 at 02:54 +0200, Thomas Monjalon wrote:
> > 31/08/2018 20:20, Luca Boccassi:
> > > +# SC2129 - avoid multiple individual redirects
> > 
> > What is SC2129 ?
> 
> shellcheck - will clarify in v2
> 
> > > +{ \
> > > +    printf '/**\n'; \
> > > +    printf '@page examples DPDK Example Programs\n\n'; \
> > > +    find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example
> > > examples/%P\n' | LC_ALL=C sort; \
> > > +    printf '*/\n'; \
> > > +} > "${API_EXAMPLES}"
> > 
> > Why using backslashes (continuation lines)?
> 
> Good point, will remove in v2
>
Agree, rather than using continuation lines, I suggest one of the
following:
* use exec > ${API_EXAMPLES} at the top of the script
* let the script just print to stdout and have make/meson put that in the
  output file for you.

/Bruce
  
Luca Boccassi Sept. 7, 2018, 4:56 p.m. UTC | #4
On Fri, 2018-09-07 at 17:13 +0100, Bruce Richardson wrote:
> On Mon, Sep 03, 2018 at 10:07:07AM +0100, Luca Boccassi wrote:
> > On Mon, 2018-09-03 at 02:54 +0200, Thomas Monjalon wrote:
> > > 31/08/2018 20:20, Luca Boccassi:
> > > > +# SC2129 - avoid multiple individual redirects
> > > 
> > > What is SC2129 ?
> > 
> > shellcheck - will clarify in v2
> > 
> > > > +{ \
> > > > +    printf '/**\n'; \
> > > > +    printf '@page examples DPDK Example Programs\n\n'; \
> > > > +    find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@examp
> > > > le
> > > > examples/%P\n' | LC_ALL=C sort; \
> > > > +    printf '*/\n'; \
> > > > +} > "${API_EXAMPLES}"
> > > 
> > > Why using backslashes (continuation lines)?
> > 
> > Good point, will remove in v2
> > 
> 
> Agree, rather than using continuation lines, I suggest one of the
> following:
> * use exec > ${API_EXAMPLES} at the top of the script
> * let the script just print to stdout and have make/meson put that in
> the
>   output file for you.
> 
> /Bruce

exec > works and checkbashism is also happy with it, so used that in v2
  

Patch

diff --git a/doc/api/generate_examples.sh b/doc/api/generate_examples.sh
new file mode 100755
index 0000000000..9633a64f7a
--- /dev/null
+++ b/doc/api/generate_examples.sh
@@ -0,0 +1,14 @@ 
+#! /bin/sh -e
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright 2018 Luca Boccassi <bluca@debian.org>
+
+EXAMPLES_DIR=$1
+API_EXAMPLES=$2
+
+# SC2129 - avoid multiple individual redirects
+{ \
+    printf '/**\n'; \
+    printf '@page examples DPDK Example Programs\n\n'; \
+    find "${EXAMPLES_DIR}" -type f -name '*.c' -printf '@example examples/%P\n' | LC_ALL=C sort; \
+    printf '*/\n'; \
+} > "${API_EXAMPLES}"
diff --git a/mk/rte.sdkdoc.mk b/mk/rte.sdkdoc.mk
index bd2e5763df..d023b720fe 100644
--- a/mk/rte.sdkdoc.mk
+++ b/mk/rte.sdkdoc.mk
@@ -63,10 +63,7 @@  api-html-clean:
 
 $(API_EXAMPLES): api-html-clean
 	$(Q)mkdir -p $(@D)
-	@printf '/**\n' > $(API_EXAMPLES)
-	@printf '@page examples DPDK Example Programs\n\n' >> $(API_EXAMPLES)
-	@find examples -type f -name '*.c' -printf '@example %p\n' | LC_ALL=C sort >> $(API_EXAMPLES)
-	@printf '*/\n' >> $(API_EXAMPLES)
+	$(Q)doc/api/generate_examples.sh examples $(API_EXAMPLES)
 
 guides-pdf-clean: guides-pdf-img-clean
 guides-pdf-img-clean: