Annotation of mandoc/catman.8, Revision 1.11
1.11 ! schwarze 1: .\" $Id: catman.8,v 1.10 2025/06/29 23:21:07 schwarze Exp $
1.1 kristaps 2: .\"
1.11 ! schwarze 3: .\" Copyright (c) 2017, 2025 Ingo Schwarze <schwarze@openbsd.org>
1.1 kristaps 4: .\"
5: .\" Permission to use, copy, modify, and distribute this software for any
6: .\" purpose with or without fee is hereby granted, provided that the above
7: .\" copyright notice and this permission notice appear in all copies.
8: .\"
9: .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: .\"
1.10 schwarze 17: .Dd $Mdocdate: June 29 2025 $
1.1 kristaps 18: .Dt CATMAN 8
19: .Os
20: .Sh NAME
21: .Nm catman
1.7 schwarze 22: .Nd format all manual pages below a directory
1.1 kristaps 23: .Sh SYNOPSIS
24: .Nm catman
1.7 schwarze 25: .Op Fl I Cm os Ns = Ns Ar name
26: .Op Fl T Ar output
27: .Ar srcdir dstdir
1.1 kristaps 28: .Sh DESCRIPTION
29: The
30: .Nm
1.7 schwarze 31: utility assumes that all files below
32: .Ar srcdir
33: are manual pages in
34: .Xr mdoc 7
35: and
36: .Xr man 7
37: format and formats all of them, storing the formatted versions in
38: the same relative paths below
39: .Ar dstdir .
40: Subdirectories of
41: .Ar dstdir
42: are created as needed.
43: Existing files are not explicitly deleted, but possibly overwritten.
1.5 kristaps 44: .Pp
1.7 schwarze 45: The options are as follows:
46: .Bl -tag -width Ds
47: .It Fl I Cm os Ns = Ns Ar name
48: Override the default operating system
49: .Ar name
50: for the
51: .Xr mdoc 7
1.8 schwarze 52: .Ic \&Os
1.7 schwarze 53: and for the
54: .Xr man 7
55: .Ic TH
56: macro.
57: .It Fl T Ar output
58: Output format.
59: The
60: .Ar output
61: argument can be
62: .Cm ascii ,
63: .Cm utf8 ,
64: or
65: .Cm html ;
66: see
67: .Xr mandoc 1 .
68: In
69: .Cm html
70: output mode, the
71: .Cm fragment
72: output option is implied.
73: Other output options are not supported.
1.11 ! schwarze 74: .It Fl v
! 75: Verbose mode; see
! 76: .Sx DIAGNOSTICS .
1.7 schwarze 77: .El
78: .Sh IMPLEMENTATION NOTES
79: Since this version avoids
80: .Xr fork 2
81: and
82: .Xr exec 3
83: overhead and uses the much faster
84: .Sy mandoc
85: parsers and formatters rather than
86: .Sy groff ,
87: it may be about one order of magnitude faster than other
1.5 kristaps 88: .Nm
1.7 schwarze 89: implementations.
90: .Sh EXIT STATUS
91: .Ex -std
1.5 kristaps 92: .Pp
1.9 schwarze 93: Failures while trying to open individual manual pages for reading,
94: to save individual formatted files to the file system,
95: or even to read or create subdirectories do not cause
96: .Nm
97: to return an error exit status.
98: In such cases,
99: .Nm
100: simply continues with the next file or subdirectory.
101: .Sh DIAGNOSTICS
102: Some fatal errors cause
103: .Nm
104: to exit before the iteration over input files is even started:
105: .Bl -tag -width Ds -offset indent
106: .It unknown option \-\- Ar option
107: An invalid option was passed on the command line.
1.10 schwarze 108: .It missing arguments: srcdir and dstdir
109: No argument was provided.
110: Both
111: .Ar srcdir
112: and
113: .Ar dstdir
114: are mandatory.
115: .It missing argument: dstdir
116: Only one argument was provided.
117: The second argument,
118: .Ar dstdir ,
119: is mandatory, too.
120: .It too many arguments: Ar third argument
121: Three or more arguments were provided, but only two are supported.
1.9 schwarze 122: .It Sy socketpair : Ar reason
123: The sockets needed for communication with
124: .Xr mandocd 8
125: could not be created, for example due to file descriptor or memory exhaustion.
126: .It Sy fork : Ar reason
127: The new process needed to run
128: .Xr mandocd 8
129: could not be created, for example due to process table exhaustion
130: or system resource limits.
131: .It Sy exec Ns Po Sy mandocd Pc : Ar reason
132: The
133: .Xr mandocd 8
134: child program could not be started, for example because it is not in the
135: .Ev PATH
136: or has no execute permission.
137: .It Sy open No destination Ar dstdir : reason
138: The
139: .Ar dstdir
140: could not be opened for reading, for example because it does not exist,
141: it is not a directory, or permission is denied.
142: .It Sy chdir No to source Ar srcdir : reason
143: The current working directory could not be changed to
144: .Ar srcdir ,
145: for example because it does not exist, it is not a directory,
146: or permission is denied.
147: .It Sy fts_open : Ar reason
148: Starting the iteration was attempted, but failed.
149: .El
150: .Pp
151: Some fatal errors cause the iteration over input files to be aborted
152: prematurely:
153: .Bl -tag -width Ds -offset indent
154: .It FATAL: Sy fts_read : Ar reason
155: A call to
156: .Xr fts_read 3
157: returned
158: .Dv NULL ,
159: meaning that the iteration failed before being complete.
160: .It FATAL: Sy sendmsg : Ar reason
161: The file descriptors needed to process one of the manual pages
162: could not be sent to
163: .Xr mandocd 8 ,
164: for example because
165: .Xr mandocd 8
166: could not be started or died unexpectedly.
167: .El
168: .Pp
169: Some non-fatal errors cause a single subdirectory to be skipped.
170: The iteration is not aborted but continues with the next subdirectory,
171: and the exit status is unaffected:
172: .Bl -tag -width Ds -offset indent
173: .It directory Ar subdirectory No unreadable : Ar reason
174: A directory below
175: .Ar srcdir
176: could not be read and is skipped.
177: .It directory Ar subdirectory No causes cycle
178: A directory below
179: .Ar srcdir
180: is skipped because it would cause cyclic processing.
181: .It Sy mkdirat Ar subdirectory : reason
182: A required directory below
183: .Ar dstdir
184: does not exist and could not be created.
185: The corresponding subdirectory below
186: .Ar srcdir
187: is skipped.
188: .El
189: .Pp
190: Some non-fatal errors cause a single source file to be skipped.
191: The iteration is not aborted but continues with the next file,
192: and the exit status is unaffected:
193: .Pp
194: .Bl -tag -width Ds -offset indent
195: .It file Ar filename : reason
196: The function
197: .Xr fts_read 3
198: reported a non-fatal error with respect to
199: .Ar filename .
1.10 schwarze 200: .It file Ar filename : No not a regular file
1.9 schwarze 201: For example, it might be a symbolic link or a device file.
202: .It Sy open Ar filename No for reading : Ar reason
203: A file below
1.7 schwarze 204: .Ar srcdir
1.9 schwarze 205: could not be read, for example due to permission problems.
206: .It Sy openat Ar filename No for writing : Ar reason
207: A file below
1.7 schwarze 208: .Ar dstdir
1.9 schwarze 209: could not be created or truncated, for example due to permission problems.
1.1 kristaps 210: .El
211: .Pp
1.9 schwarze 212: If errors occur, the applicable summary messages appear
213: after the end of the iteration:
214: .Pp
215: .Bl -tag -width Ds -offset indent -compact
216: .It skipped Ar number No directories due to errors
217: .It skipped Ar number No files due to errors
218: .It processing aborted due to fatal error
1.11 ! schwarze 219: .El
! 220: .Pp
! 221: If the
! 222: .Fl v
! 223: flag is specified, the following summary message also appears:
! 224: .Pp
! 225: .Bl -tag -width Ds -offset indent -compact
! 226: .It processed Ar nfiles No files in Ar ndirs No directories
! 227: A file is counted if it could be opened for reading and the
! 228: corresponding output file could be opened for writing;
! 229: this does not necessarily mean that it is a useful manual page.
! 230: A directory is counted if it could be opened for reading and the
! 231: corresponding output directory existed or could be created;
! 232: this does not necessarily mean that any files could be
! 233: processed inside.
1.9 schwarze 234: .El
1.1 kristaps 235: .Sh SEE ALSO
236: .Xr mandoc 1 ,
1.7 schwarze 237: .Xr mandocd 8
238: .Sh HISTORY
239: A
240: .Nm
241: utility first appeared in
242: .Fx 1.0 .
243: Other, incompatible implementations appeared in
244: .Nx 1.0
245: and in
246: .Sy man-db No 2.2 .
247: .Pp
248: This version appeared in version 1.14.1 of the
249: .Sy mandoc
250: toolkit.
1.1 kristaps 251: .Sh AUTHORS
1.7 schwarze 252: .An -nosplit
253: The first
254: .Nm
255: implementation was a short shell script by
256: .An Christoph Robitschko
257: in July 1993.
258: .Pp
1.1 kristaps 259: The
1.7 schwarze 260: .Nx
261: implementations were written by
262: .An J. T. Conklin Aq Mt jtc@netbsd.org
263: in 1993,
264: .An Christian E. Hopps Aq Mt chopps@netbsd.org
265: in 1994,
266: and
267: .An Dante Profeta Aq Mt dante@netbsd.org
268: in 1999; the
269: .Sy man-db
270: implementation by
271: .An Graeme W. Wilford
272: in 1994; and the
273: .Fx
274: implementations by
275: .An Wolfram Schneider Aq Mt wosch@freebsd.org
276: in 1995 and
277: .An John Rochester Aq Mt john@jrochester.org
278: in 2002.
279: .Pp
280: The concept of the present version was designed and implemented by
281: .An Michael Stapelberg Aq Mt stapelberg@debian.org
282: in 2017.
283: Option and argument handling and directory iteration was added by
284: .An Ingo Schwarze Aq Mt schwarze@openbsd.org .
285: .Sh CAVEATS
286: All versions of
287: .Nm
288: are incompatible with each other because each caters to the needs
289: of a specific operating system, for example regarding directory
290: structures and file naming conventions.
291: .Pp
292: This version is more flexible than the others in so far as it does
293: not assume any particular directory structure or naming convention.
294: That flexibility comes at the price of not being able to change the
295: names and relative paths of the source files when reusing them to
296: store the formatted files, of not supporting any configuration file
297: formats or environment variables, and of being unable to scan for
298: and remove junk files in
299: .Ar dstdir .
300: .Pp
301: Currently,
1.1 kristaps 302: .Nm
1.7 schwarze 303: always reformats each page, even if the formatted version is newer
304: than the source version.
CVSweb