]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
share/mk/: lint-man-poems: Diagnose (lack of) semantic newlines
authorAlejandro Colomar <alx@kernel.org>
Tue, 19 Aug 2025 11:31:41 +0000 (13:31 +0200)
committerAlejandro Colomar <alx@kernel.org>
Sun, 21 Sep 2025 14:25:36 +0000 (16:25 +0200)
Write poems, not prose.

This only catches the most obvious issues, but at least that's
something.

We need pcre2grep(3) because it allows multiple patterns, whereas
grep(1) in -P mode only accepts one.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
share/mk/lint/man/_.mk
share/mk/lint/man/poems.mk [new file with mode: 0644]
share/mk/lint/man/poems.pcre2grep [new file with mode: 0644]
share/mk/lint/man/poems.xfail [new file with mode: 0644]

index 0bf60eaa6aa52e7bebcad80ec0bd64baa2c155a3..ba25943d899cdc51763a8f1fdabd94a61125af79 100644 (file)
@@ -10,6 +10,7 @@ MAKEFILE_LINT_MAN_INCLUDED := 1
 lint-man: \
        lint-man-blank \
        lint-man-mandoc \
+       lint-man-poems \
        lint-man-quote \
        lint-man-so \
        lint-man-tbl \
diff --git a/share/mk/lint/man/poems.mk b/share/mk/lint/man/poems.mk
new file mode 100644 (file)
index 0000000..239a973
--- /dev/null
@@ -0,0 +1,46 @@
+# Copyright, the authors of the Linux man-pages project
+# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception
+
+
+ifndef MAKEFILE_LINT_MAN_POEMS_INCLUDED
+MAKEFILE_LINT_MAN_POEMS_INCLUDED := 1
+
+
+include $(MAKEFILEDIR)/build/man/nonso.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils/cat.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils/echo.mk
+include $(MAKEFILEDIR)/configure/build-depends/coreutils/touch.mk
+include $(MAKEFILEDIR)/configure/build-depends/pcre2-utils/pcre2grep.mk
+
+
+ext := .lint-man.poems.touch
+xfail := $(MAKEFILEDIR)/lint/man/poems.xfail
+regexf := $(MAKEFILEDIR)/lint/man/poems.pcre2grep
+
+tgts := $(patsubst %, %$(ext), $(_NONSO))
+ifeq ($(SKIP_XFAIL),yes)
+tgts := $(filter-out $(patsubst %, $(_MANDIR)/%$(ext), $(file < $(xfail))), $(tgts))
+endif
+
+
+$(tgts): %$(ext): % $(regexf) $(MK) | $$(@D)/
+       $(info  $(INFO_)PCRE2GREP       $@)
+       $(CAT) <$< \
+       | if $(PCRE2GREP) -f '$(filter %.pcre2grep, $^)' >/dev/null; then \
+               >&2 $(ECHO) "lint-man-poems: $<: Use semantic newlines (see man-pages(7)):"; \
+               >&2 $(PCRE2GREP) -n -f '$(filter %.pcre2grep, $^)' <$<; \
+               exit 1; \
+       fi;
+       $(TOUCH) $@
+
+
+.PHONY: lint-man-poems
+lint-man-poems: $(tgts);
+
+
+undefine ext
+undefine tgts
+undefine regexf
+
+
+endif  # include guard
diff --git a/share/mk/lint/man/poems.pcre2grep b/share/mk/lint/man/poems.pcre2grep
new file mode 100644 (file)
index 0000000..50dbd01
--- /dev/null
@@ -0,0 +1,2 @@
+^(?!.[A-Z])(?:(?!Subject: )(?!Author: )(?!for \().)*[^ ]\. [^ ]
+^(?![.[:space:]])(?:(?!\bfor \()[^\t:=0-9[])*; [^ ][^\t:=0-9[]*$
diff --git a/share/mk/lint/man/poems.xfail b/share/mk/lint/man/poems.xfail
new file mode 100644 (file)
index 0000000..7449bfd
--- /dev/null
@@ -0,0 +1,5 @@
+man5/tzfile.5
+man7/bpf-helpers.7
+man8/tzselect.8
+man8/zdump.8
+man8/zic.8