2021-11-05 22:19:04 +00:00
|
|
|
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
|
2017-10-04 20:10:05 -07:00
|
|
|
include ../../../scripts/Makefile.include
|
|
|
|
|
|
|
|
INSTALL ?= install
|
|
|
|
RM ?= rm -f
|
2017-12-07 15:00:18 -08:00
|
|
|
RMDIR ?= rmdir --ignore-fail-on-non-empty
|
2017-10-04 20:10:05 -07:00
|
|
|
|
2017-12-07 15:00:17 -08:00
|
|
|
ifeq ($(V),1)
|
|
|
|
Q =
|
|
|
|
else
|
|
|
|
Q = @
|
2017-10-04 20:10:05 -07:00
|
|
|
endif
|
2017-12-07 15:00:17 -08:00
|
|
|
|
|
|
|
prefix ?= /usr/local
|
|
|
|
mandir ?= $(prefix)/man
|
2017-10-04 20:10:05 -07:00
|
|
|
man8dir = $(mandir)/man8
|
|
|
|
|
2020-09-09 17:24:59 +01:00
|
|
|
MAN8_RST = $(wildcard bpftool*.rst)
|
2017-10-04 20:10:05 -07:00
|
|
|
|
|
|
|
_DOC_MAN8 = $(patsubst %.rst,%.8,$(MAN8_RST))
|
|
|
|
DOC_MAN8 = $(addprefix $(OUTPUT),$(_DOC_MAN8))
|
|
|
|
|
2021-03-02 09:19:43 -08:00
|
|
|
man: man8
|
2017-10-04 20:10:05 -07:00
|
|
|
man8: $(DOC_MAN8)
|
|
|
|
|
2018-02-07 20:27:14 -08:00
|
|
|
RST2MAN_DEP := $(shell command -v rst2man 2>/dev/null)
|
2021-11-15 22:58:42 +00:00
|
|
|
RST2MAN_OPTS += --verbose --strip-comments
|
2018-02-07 20:27:14 -08:00
|
|
|
|
2020-09-10 21:39:35 +01:00
|
|
|
list_pages = $(sort $(basename $(filter-out $(1),$(MAN8_RST))))
|
|
|
|
see_also = $(subst " ",, \
|
|
|
|
"\n" \
|
|
|
|
"SEE ALSO\n" \
|
|
|
|
"========\n" \
|
bpftool: Use simpler indentation in source rST for documentation
The rST manual pages for bpftool would use a mix of tabs and spaces for
indentation. While this is the norm in C code, this is rather unusual
for rST documents, and over time we've seen many contributors use a
wrong level of indentation for documentation update.
Let's fix bpftool's indentation in docs once and for all:
- Let's use spaces, that are more common in rST files.
- Remove one level of indentation for the synopsis, the command
description, and the "see also" section. As a result, all sections
start with the same indentation level in the generated man page.
- Rewrap the paragraphs after the changes.
There is no content change in this patch, only indentation and
rewrapping changes. The wrapping in the generated source files for the
manual pages is changed, but the pages displayed with "man" remain the
same, apart from the adjusted indentation level on relevant sections.
[ Quentin: rebased on bpf-next, removed indent level for command
description and options, updated synopsis, command summary, and "see
also" sections. ]
Signed-off-by: Rameez Rehman <rameezrehman408@hotmail.com>
Signed-off-by: Quentin Monnet <qmo@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20240331200346.29118-2-qmo@kernel.org
2024-03-31 21:03:44 +01:00
|
|
|
"**bpf**\ (2),\n" \
|
|
|
|
"**bpf-helpers**\\ (7)" \
|
|
|
|
$(foreach page,$(call list_pages,$(1)),",\n**$(page)**\\ (8)") \
|
2020-09-10 21:39:35 +01:00
|
|
|
"\n")
|
|
|
|
|
2017-10-04 20:10:05 -07:00
|
|
|
$(OUTPUT)%.8: %.rst
|
2018-02-07 20:27:14 -08:00
|
|
|
ifndef RST2MAN_DEP
|
|
|
|
$(error "rst2man not found, but required to generate man pages")
|
|
|
|
endif
|
bpftool: Fix build failure
When building bpf selftests like
make -C tools/testing/selftests/bpf -j20
I hit the following errors:
...
GEN /net-next/tools/testing/selftests/bpf/tools/build/bpftool/Documentation/bpftool-gen.8
<stdin>:75: (WARNING/2) Block quote ends without a blank line; unexpected unindent.
<stdin>:71: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
<stdin>:85: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
<stdin>:57: (WARNING/2) Block quote ends without a blank line; unexpected unindent.
<stdin>:66: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
<stdin>:109: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
<stdin>:175: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
<stdin>:273: (WARNING/2) Literal block ends without a blank line; unexpected unindent.
make[1]: *** [/net-next/tools/testing/selftests/bpf/tools/build/bpftool/Documentation/bpftool-perf.8] Error 12
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/net-next/tools/testing/selftests/bpf/tools/build/bpftool/Documentation/bpftool-iter.8] Error 12
make[1]: *** [/net-next/tools/testing/selftests/bpf/tools/build/bpftool/Documentation/bpftool-struct_ops.8] Error 12
...
I am using:
-bash-4.4$ rst2man --version
rst2man (Docutils 0.11 [repository], Python 2.7.5, on linux2)
-bash-4.4$
The Makefile generated final .rst file (e.g., bpftool-cgroup.rst) looks like
...
ID AttachType AttachFlags Name
\n SEE ALSO\n========\n\t**bpf**\ (2),\n\t**bpf-helpers**\
(7),\n\t**bpftool**\ (8),\n\t**bpftool-btf**\
(8),\n\t**bpftool-feature**\ (8),\n\t**bpftool-gen**\
(8),\n\t**bpftool-iter**\ (8),\n\t**bpftool-link**\
(8),\n\t**bpftool-map**\ (8),\n\t**bpftool-net**\
(8),\n\t**bpftool-perf**\ (8),\n\t**bpftool-prog**\
(8),\n\t**bpftool-struct_ops**\ (8)\n
The rst2man generated .8 file looks like
Literal block ends without a blank line; unexpected unindent.
.sp
n SEEALSOn========nt**bpf**(2),nt**bpf\-helpers**(7),nt**bpftool**(8),nt**bpftool\-btf**(8),nt**
bpftool\-feature**(8),nt**bpftool\-gen**(8),nt**bpftool\-iter**(8),nt**bpftool\-link**(8),nt**
bpftool\-map**(8),nt**bpftool\-net**(8),nt**bpftool\-perf**(8),nt**bpftool\-prog**(8),nt**
bpftool\-struct_ops**(8)n
Looks like that particular version of rst2man prefers to have actual new line
instead of \n.
Since `echo -e` may not be available in some environment, let us use `printf`.
Format string "%b" is used for `printf` to ensure all escape characters are
interpretted properly.
Fixes: 18841da98100 ("tools: bpftool: Automate generation for "SEE ALSO" sections in man pages")
Suggested-by: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Cc: Quentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20200914183110.999906-1-yhs@fb.com
2020-09-14 11:31:10 -07:00
|
|
|
$(QUIET_GEN)( cat $< ; printf "%b" $(call see_also,$<) ) | rst2man $(RST2MAN_OPTS) > $@
|
2017-10-04 20:10:05 -07:00
|
|
|
|
2021-03-02 09:19:43 -08:00
|
|
|
clean:
|
2017-12-07 15:00:17 -08:00
|
|
|
$(call QUIET_CLEAN, Documentation)
|
|
|
|
$(Q)$(RM) $(DOC_MAN8)
|
2017-10-04 20:10:05 -07:00
|
|
|
|
2021-03-02 09:19:43 -08:00
|
|
|
install: man
|
2017-12-07 15:00:17 -08:00
|
|
|
$(call QUIET_INSTALL, Documentation-man)
|
|
|
|
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
|
|
|
|
$(Q)$(INSTALL) -m 644 $(DOC_MAN8) $(DESTDIR)$(man8dir)
|
2017-10-04 20:10:05 -07:00
|
|
|
|
2021-03-02 09:19:43 -08:00
|
|
|
uninstall:
|
2017-12-07 15:00:18 -08:00
|
|
|
$(call QUIET_UNINST, Documentation-man)
|
|
|
|
$(Q)$(RM) $(addprefix $(DESTDIR)$(man8dir)/,$(_DOC_MAN8))
|
|
|
|
$(Q)$(RMDIR) $(DESTDIR)$(man8dir)
|
|
|
|
|
|
|
|
.PHONY: man man8 clean install uninstall
|
2017-10-04 20:10:05 -07:00
|
|
|
.DEFAULT_GOAL := man
|