tools: bpftool: Automate generation for "SEE ALSO" sections in man pages
authorQuentin Monnet <quentin@isovalent.com>
Thu, 10 Sep 2020 20:39:35 +0000 (21:39 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 11 Sep 2020 03:10:45 +0000 (20:10 -0700)
The "SEE ALSO" sections of bpftool's manual pages refer to bpf(2),
bpf-helpers(7), then all existing bpftool man pages (save the current
one).

This leads to nearly-identical lists being duplicated in all manual
pages. Ideally, when a new page is created, all lists should be updated
accordingly, but this has led to omissions and inconsistencies multiple
times in the past.

Let's take it out of the RST files and generate the "SEE ALSO" sections
automatically in the Makefile when generating the man pages. The lists
are not really useful in the RST anyway because all other pages are
available in the same directory.

v3:
- Fix conflict with a previous patchset that introduced RST2MAN_OPTS
  variable passed to rst2man.

v2:
- Use "echo -n" instead of "printf" in Makefile, to avoid any risk of
  passing a format string directly to the command.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200910203935.25304-1-quentin@isovalent.com
13 files changed:
tools/bpf/bpftool/Documentation/Makefile
tools/bpf/bpftool/Documentation/bpftool-btf.rst
tools/bpf/bpftool/Documentation/bpftool-cgroup.rst
tools/bpf/bpftool/Documentation/bpftool-feature.rst
tools/bpf/bpftool/Documentation/bpftool-gen.rst
tools/bpf/bpftool/Documentation/bpftool-iter.rst
tools/bpf/bpftool/Documentation/bpftool-link.rst
tools/bpf/bpftool/Documentation/bpftool-map.rst
tools/bpf/bpftool/Documentation/bpftool-net.rst
tools/bpf/bpftool/Documentation/bpftool-perf.rst
tools/bpf/bpftool/Documentation/bpftool-prog.rst
tools/bpf/bpftool/Documentation/bpftool-struct_ops.rst
tools/bpf/bpftool/Documentation/bpftool.rst

index 5e3815320dab593c7e878a430a1fe553d02b9147..4c9dd1e4524437d92cc17578ebfd88515bb01648 100644 (file)
@@ -30,11 +30,21 @@ man8: $(DOC_MAN8)
 RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
 RST2MAN_OPTS += --verbose
 
+list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
+see_also = $(subst " ",, \
+       "\n" \
+       "SEE ALSO\n" \
+       "========\n" \
+       "\t**bpf**\ (2),\n" \
+       "\t**bpf-helpers**\\ (7)" \
+       $(foreach page,$(call list_pages,$(1)),",\n\t**$(page)**\\ (8)") \
+       "\n")
+
 $(OUTPUT)%.8: %.rst
 ifndef RST2MAN_DEP
        $(error "rst2man not found, but required to generate man pages")
 endif
-       $(QUIET_GEN)rst2man $(RST2MAN_OPTS) $< > $@
+       $(QUIET_GEN)( cat $< ; echo -n $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
 
 clean: helpers-clean
        $(call QUIET_CLEAN, Documentation)
index 52a7b2f6c9cb47e85205486a00d1bc42b454b4b6..ff4d327a582e6e7c39131f3eacc9f73f975cc150 100644 (file)
@@ -217,20 +217,3 @@ All the standard ways to specify map or program are supported:
 **# bpftool btf dump prog tag b88e0a09b1d9759d**
 
 **# bpftool btf dump prog pinned /sys/fs/bpf/prog_name**
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 3dba89db000ea35ca8c5d2bc60443a38d175de9e..790944c356025f31df49787f3e60407a025cabda 100644 (file)
@@ -143,19 +143,3 @@ EXAMPLES
 ::
 
     ID       AttachType      AttachFlags     Name
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index f1aae5690e3c88c7d410c2e4d322c92db3000cc9..dd3771bdbc5760b60ae1b13b3681a107ecac4648 100644 (file)
@@ -72,19 +72,3 @@ DESCRIPTION
 OPTIONS
 =======
        .. include:: common_options.rst
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 29d4cf4c3422c33eb619183657724659fdc2322c..84cf0639696f588016e642c145f5482c95733ca5 100644 (file)
@@ -279,19 +279,3 @@ and global variables.
   my_static_var: 7
 
 This is a stripped-out version of skeleton generated for above example code.
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index b688cf11805c3d335da61c3ca8445dd2ef8cb22b..51f49bead619ac37b256f39bb7cea7e9c3738926 100644 (file)
@@ -68,19 +68,3 @@ EXAMPLES
 
    Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
    id 20, and pin it to /sys/fs/bpf/my_hashmap
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index ce122be58baeef753c82a3b52052f6dfe75067b0..5f7db2a837cc87dd16afc9c384b6822c71d242e0 100644 (file)
@@ -106,20 +106,3 @@ EXAMPLES
 ::
 
     -rw------- 1 root root 0 Apr 23 21:39 link
-
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 8eac254ade48abea4c0953f2aa683107407fa926..dade10cdf295b12b7ef98ddc3a19005b34a46411 100644 (file)
@@ -270,19 +270,3 @@ would be lost as soon as bpftool exits).
 
   key: 00 00 00 00  value: 22 02 00 00
   Found 1 element
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 56439c32934d7f04d8752cc85de9f39213cb83fc..d8165d530937444b2ddc73419aceaff257c54f4e 100644 (file)
@@ -172,20 +172,3 @@ EXAMPLES
 ::
 
       xdp:
-
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 36d257a36e9b30861dfe38ebb76a6f20caf3558e..e958ce91de72d7d018ac3b7d15b71791635660e7 100644 (file)
@@ -63,20 +63,3 @@ EXAMPLES
      {"pid":21765,"fd":5,"prog_id":7,"fd_type":"kretprobe","func":"__x64_sys_nanosleep","offset":0}, \
      {"pid":21767,"fd":5,"prog_id":8,"fd_type":"tracepoint","tracepoint":"sys_enter_nanosleep"}, \
      {"pid":21800,"fd":5,"prog_id":9,"fd_type":"uprobe","filename":"/home/yhs/a.out","offset":1159}]
-
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)
index 9b2b18e2a3acc676a2ef783b0481a7b5583042ce..358c7309d4191e01deb727f5e5df36da5a3703c0 100644 (file)
@@ -326,19 +326,3 @@ EXAMPLES
       40176203 cycles                                                 (83.05%)
       42518139 instructions    #   1.06 insns per cycle               (83.39%)
            123 llc_misses      #   2.89 LLC misses per million insns  (83.15%)
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-struct_ops**\ (8)
index 315f1f21f2ba2e06e8fc7f55dcdba4f81a518c1e..506e70ee78e91d47dbe53087ebbf23f7a5bb2467 100644 (file)
@@ -82,20 +82,3 @@ EXAMPLES
 ::
 
    Registered tcp_congestion_ops cubic id 110
-
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool**\ (8),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8)
index b87f8c2df49dd06e4470689ddba77e7b417df09d..e7d9493349618dbc8fc03ccda12a333d6310ca3a 100644 (file)
@@ -54,19 +54,3 @@ OPTIONS
        -n, --nomount
                  Do not automatically attempt to mount any virtual file system
                  (such as tracefs or BPF virtual file system) when necessary.
-
-SEE ALSO
-========
-       **bpf**\ (2),
-       **bpf-helpers**\ (7),
-       **bpftool-btf**\ (8),
-       **bpftool-cgroup**\ (8),
-       **bpftool-feature**\ (8),
-       **bpftool-gen**\ (8),
-       **bpftool-iter**\ (8),
-       **bpftool-link**\ (8),
-       **bpftool-map**\ (8),
-       **bpftool-net**\ (8),
-       **bpftool-perf**\ (8),
-       **bpftool-prog**\ (8),
-       **bpftool-struct_ops**\ (8)