From: Alejandro Colomar <alx@kernel.org>
To: linux-man@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>,
groff@gnu.org, cjwatson@debian.org, branden@debian.org
Subject: [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1)
Date: Sun, 3 Nov 2024 02:16:47 +0100 [thread overview]
Message-ID: <ef793bf0af1f006971c6a3aa78227719ae30222a.1730596445.git.alx@kernel.org> (raw)
In-Reply-To: <cover.1730596445.git.alx@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2232 bytes --]
Remove the man_section() function, and call the mansect(1) program
instead.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
scripts/bash_aliases | 45 ++++++--------------------------------------
1 file changed, 6 insertions(+), 39 deletions(-)
diff --git a/scripts/bash_aliases b/scripts/bash_aliases
index e461707c8..25425c389 100644
--- a/scripts/bash_aliases
+++ b/scripts/bash_aliases
@@ -38,39 +38,6 @@ sed_rm_ccomments()
########################################################################
# Linux man-pages
-# man_section() prints specific manual page sections (DESCRIPTION, SYNOPSIS,
-# ...) of all manual pages in a directory (or in a single manual page file).
-# Usage example: .../man-pages$ man_section man2 SYNOPSIS 'SEE ALSO';
-
-man_section()
-{
- if [ $# -lt 2 ]; then
- >&2 echo "Usage: ${FUNCNAME[0]} <dir> <section>...";
- return $EX_USAGE;
- fi
-
- local page="$1";
- shift;
- local sect="$*";
-
- find "$page" -type f \
- |xargs wc -l \
- |grep -v -e '\b1 ' -e '\btotal\b' \
- |awk '{ print $2 }' \
- |sort \
- |while read -r manpage; do
- (sed -n '/^\.TH/,/^\.SH/{/^\.SH/!p}' <"$manpage";
- for s in $sect; do
- <"$manpage" \
- sed -n \
- -e "/^\.SH $s/p" \
- -e "/^\.SH $s/,/^\.SH/{/^\.SH/!p}";
- done;) \
- |mandoc -Tutf8 2>/dev/null \
- |col -pbx;
- done;
-}
-
# man_lsfunc() prints the name of all C functions declared in the SYNOPSIS
# of all manual pages in a directory (or in a single manual page file).
# Each name is printed in a separate line
@@ -83,9 +50,9 @@ man_lsfunc()
return $EX_USAGE;
fi
- for arg in "$@"; do
- man_section "$arg" 'SYNOPSIS';
- done \
+ mansect 'SYNOPSIS' "$@" \
+ |mandoc -Tutf8 2>/dev/null \
+ |col -pbx \
|sed_rm_ccomments \
|pcregrep -Mn '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]*?(...)?\s*\); *$' \
|grep '^[0-9]' \
@@ -106,9 +73,9 @@ man_lsvar()
return $EX_USAGE;
fi
- for arg in "$@"; do
- man_section "$arg" 'SYNOPSIS';
- done \
+ mansect 'SYNOPSIS' "$@" \
+ |mandoc -Tutf8 2>/dev/null \
+ |col -pbx \
|sed_rm_ccomments \
|pcregrep -Mv '(?s)^ [\w ]+ \**\w+\([\w\s(,)[\]*]+?(...)?\s*\); *$' \
|pcregrep -Mn \
--
2.39.5
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next parent reply other threads:[~2024-11-03 1:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1730596445.git.alx@kernel.org>
2024-11-03 1:16 ` Alejandro Colomar [this message]
2024-11-03 1:26 ` [PATCH v2 1/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use mansect(1) Alejandro Colomar
2024-11-03 1:17 ` [PATCH v2 2/3] scripts/bash_aliases: man_lsfunc(), man_lsvar(): Use pcre2grep(1) instead of pcregrep(1) Alejandro Colomar
2024-11-03 1:17 ` [PATCH v2 3/3] src/bin/mansect: Preprocess with preconv(1) Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef793bf0af1f006971c6a3aa78227719ae30222a.1730596445.git.alx@kernel.org \
--to=alx@kernel.org \
--cc=branden@debian.org \
--cc=cjwatson@debian.org \
--cc=groff@gnu.org \
--cc=linux-man@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox