Fix false positives in docstring width warning with (fn...) constructs.
[emacs.git] / build-aux / make-info-dir
blob256c9f025cc07a3232021eb852441a41d031b77d
1 #!/bin/sh
3 ### make-info-dir - create info/dir, for systems without install-info
5 ## Copyright (C) 2013-2021 Free Software Foundation, Inc.
7 ## Author: Glenn Morris <rgm@gnu.org>
8 ## Maintainer: emacs-devel@gnu.org
10 ## This file is part of GNU Emacs.
12 ## GNU Emacs is free software: you can redistribute it and/or modify
13 ## it under the terms of the GNU General Public License as published by
14 ## the Free Software Foundation, either version 3 of the License, or
15 ## (at your option) any later version.
17 ## GNU Emacs is distributed in the hope that it will be useful,
18 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ## GNU General Public License for more details.
22 ## You should have received a copy of the GNU General Public License
23 ## along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
25 ### Commentary:
27 ## Generate info/dir, for systems without install-info.
28 ## Expects to be called from top-level Emacs source directory.
30 ## It only handles the case where info/dir is missing from the
31 ## installation directory. It does not handle info/dir being present
32 ## but missing some entries.
34 ## Header contains non-printing characters, so this is more
35 ## reliable than using awk.
36 cat <"${1?}" || exit
37 shift
39 exec "${AWK-awk}" '
40 function detexinfo() {
41 gsub(/@value{emacsname}/, "Emacs")
42 gsub(/@[^{]*\{/, "")
43 gsub(/}/, "")
45 BEGIN {
46 ntopics = 0
47 topic[ntopics++] = "Texinfo documentation system"
48 topic[ntopics++] = "Emacs"
49 topic[ntopics++] = "Emacs lisp"
50 topic[ntopics++] = "Emacs editing modes"
51 topic[ntopics++] = "Emacs network features"
52 topic[ntopics++] = "Emacs misc features"
53 topic[ntopics++] = "Emacs lisp libraries"
54 topic[ntopics] = "Unknown category"
55 texinfo = 0
58 /^@dircategory / {
59 texinfo = 1
60 sub(/^@dircategory /, "")
61 detexinfo()
62 for (dircat = 0; dircat < ntopics && topic[dircat] != $0; dircat++)
63 continue;
65 /^@direntry/, /^@end direntry/ {
66 # FIXME do not ignore w32 if OS is w32.
67 if ($0 !~ /^@/ && $0 !~ /w32/) {
68 detexinfo()
69 data[dircat] = data[dircat] $0 "\n"
73 ## Org stuff. TODO we assume the order of the texinfo items.
75 ## TODO Check FILENAME suffix instead?
76 ## TODO Is this portable awk?
77 if (FNR == 1) texinfo = 0
79 ## If applied to the generated org.texi file, this picks up the examples.
80 ## Thanks for making life more difficult...
81 if (texinfo) next
83 if (tolower($0) ~ /^#\+texinfo_dir_category/) {
84 sub(/^#[^:]*: /, "")
85 for (dircat = 0; dircat < ntopics && topic[dircat] != $0; dircat++)
86 continue;
88 if (tolower($0) ~ /^#\+texinfo_dir_title/) {
89 sub(/^#[^:]*: /, "")
90 ## Note this does not fill any long descriptions.
91 data[dircat] = data[dircat] sprintf("* %-30s", ($0 ". "))
93 if (tolower($0) ~ /^#\+texinfo_dir_desc/) {
94 sub(/^#[^:]*: /, "")
95 data[dircat] = data[dircat] $0 ".\n"
99 END {
100 for (dircat = 0; dircat <= ntopics; dircat++)
101 if (data[dircat])
102 printf "\n%s\n%s", topic[dircat], data[dircat]
104 ' "${@?}"