Annotation of mandoc/catman.8, Revision 1.14
1.14 ! schwarze 1: .\" $Id: catman.8,v 1.13 2025/06/30 11:24:30 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.13 schwarze 17: .Dd $Mdocdate: June 30 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
1.13 schwarze 75: Verbose mode, printing additional information to standard error output.
76: Specifying this once prints a summary about the number of files
77: and directories processed at the end of the iteration.
78: Specifying it twice additionally prints debugging information
79: about the backchannel from
80: .Xr mandocd 8
81: to
82: .Nm
83: that is used to limit the number of files in flight at any given time.
84: For details, see
1.11 schwarze 85: .Sx DIAGNOSTICS .
1.7 schwarze 86: .El
87: .Sh IMPLEMENTATION NOTES
88: Since this version avoids
89: .Xr fork 2
90: and
91: .Xr exec 3
92: overhead and uses the much faster
93: .Sy mandoc
94: parsers and formatters rather than
95: .Sy groff ,
96: it may be about one order of magnitude faster than other
1.5 kristaps 97: .Nm
1.7 schwarze 98: implementations.
99: .Sh EXIT STATUS
100: .Ex -std
1.5 kristaps 101: .Pp
1.9 schwarze 102: Failures while trying to open individual manual pages for reading,
103: to save individual formatted files to the file system,
104: or even to read or create subdirectories do not cause
105: .Nm
106: to return an error exit status.
107: In such cases,
108: .Nm
109: simply continues with the next file or subdirectory.
110: .Sh DIAGNOSTICS
111: Some fatal errors cause
112: .Nm
113: to exit before the iteration over input files is even started:
114: .Bl -tag -width Ds -offset indent
115: .It unknown option \-\- Ar option
116: An invalid option was passed on the command line.
1.10 schwarze 117: .It missing arguments: srcdir and dstdir
118: No argument was provided.
119: Both
120: .Ar srcdir
121: and
122: .Ar dstdir
123: are mandatory.
124: .It missing argument: dstdir
125: Only one argument was provided.
126: The second argument,
127: .Ar dstdir ,
128: is mandatory, too.
129: .It too many arguments: Ar third argument
130: Three or more arguments were provided, but only two are supported.
1.9 schwarze 131: .It Sy socketpair : Ar reason
132: The sockets needed for communication with
133: .Xr mandocd 8
134: could not be created, for example due to file descriptor or memory exhaustion.
135: .It Sy fork : Ar reason
136: The new process needed to run
137: .Xr mandocd 8
138: could not be created, for example due to process table exhaustion
139: or system resource limits.
140: .It Sy exec Ns Po Sy mandocd Pc : Ar reason
141: The
142: .Xr mandocd 8
143: child program could not be started, for example because it is not in the
144: .Ev PATH
145: or has no execute permission.
146: .It Sy open No destination Ar dstdir : reason
147: The
148: .Ar dstdir
149: could not be opened for reading, for example because it does not exist,
150: it is not a directory, or permission is denied.
151: .It Sy chdir No to source Ar srcdir : reason
152: The current working directory could not be changed to
153: .Ar srcdir ,
154: for example because it does not exist, it is not a directory,
155: or permission is denied.
156: .It Sy fts_open : Ar reason
1.14 ! schwarze 157: Starting the iteration was attempted but failed,
! 158: for example due to memory exhaustion.
1.9 schwarze 159: .El
160: .Pp
161: Some fatal errors cause the iteration over input files to be aborted
162: prematurely:
163: .Bl -tag -width Ds -offset indent
164: .It FATAL: Sy fts_read : Ar reason
165: A call to
166: .Xr fts_read 3
167: returned
168: .Dv NULL ,
169: meaning that the iteration failed before being complete.
1.12 schwarze 170: .It FATAL: mandocd child died: got Ar SIGNAME
171: This message appears if
172: .Nm
173: gets the
174: .Dv SIGCHLD
175: or
176: .Dv SIGPIPE
177: signal, most likely due to a fatal bug in
178: .Xr mandocd 8 .
1.9 schwarze 179: .It FATAL: Sy sendmsg : Ar reason
180: The file descriptors needed to process one of the manual pages
181: could not be sent to
182: .Xr mandocd 8 ,
183: for example because
184: .Xr mandocd 8
185: could not be started or died unexpectedly.
1.14 ! schwarze 186: .It FATAL: Sy recv : Ar reason
! 187: Trying to read a reply message from
! 188: .Xr mandocd 8
! 189: failed, most likely because
! 190: .Xr mandocd 8
! 191: unexpectedly died or closed the socket.
1.12 schwarze 192: .It FATAL: signal Ar SIGNAME
193: This message appears if
194: .Nm
195: gets a
196: .Dv SIGHUP ,
197: .Dv SIGINT ,
198: or
199: .Dv SIGTERM
200: signal, for example because the user deliberately killed it.
1.9 schwarze 201: .El
202: .Pp
203: Some non-fatal errors cause a single subdirectory to be skipped.
204: The iteration is not aborted but continues with the next subdirectory,
205: and the exit status is unaffected:
206: .Bl -tag -width Ds -offset indent
207: .It directory Ar subdirectory No unreadable : Ar reason
208: A directory below
209: .Ar srcdir
210: could not be read and is skipped.
211: .It directory Ar subdirectory No causes cycle
212: A directory below
213: .Ar srcdir
214: is skipped because it would cause cyclic processing.
215: .It Sy mkdirat Ar subdirectory : reason
216: A required directory below
217: .Ar dstdir
218: does not exist and could not be created.
219: The corresponding subdirectory below
220: .Ar srcdir
221: is skipped.
222: .El
223: .Pp
224: Some non-fatal errors cause a single source file to be skipped.
225: The iteration is not aborted but continues with the next file,
226: and the exit status is unaffected:
227: .Bl -tag -width Ds -offset indent
228: .It file Ar filename : reason
229: The function
230: .Xr fts_read 3
231: reported a non-fatal error with respect to
232: .Ar filename .
1.10 schwarze 233: .It file Ar filename : No not a regular file
1.9 schwarze 234: For example, it might be a symbolic link or a device file.
235: .It Sy open Ar filename No for reading : Ar reason
236: A file below
1.7 schwarze 237: .Ar srcdir
1.9 schwarze 238: could not be read, for example due to permission problems.
239: .It Sy openat Ar filename No for writing : Ar reason
240: A file below
1.7 schwarze 241: .Ar dstdir
1.9 schwarze 242: could not be created or truncated, for example due to permission problems.
1.1 kristaps 243: .El
244: .Pp
1.9 schwarze 245: If errors occur, the applicable summary messages appear
246: after the end of the iteration:
247: .Pp
248: .Bl -tag -width Ds -offset indent -compact
249: .It skipped Ar number No directories due to errors
250: .It skipped Ar number No files due to errors
251: .It processing aborted due to fatal error
1.11 schwarze 252: .El
253: .Pp
254: If the
255: .Fl v
256: flag is specified, the following summary message also appears:
1.13 schwarze 257: .Bl -tag -width Ds -offset indent
1.11 schwarze 258: .It processed Ar nfiles No files in Ar ndirs No directories
259: A file is counted if it could be opened for reading and the
260: corresponding output file could be opened for writing;
261: this does not necessarily mean that it is a useful manual page.
262: A directory is counted if it could be opened for reading and the
263: corresponding output directory existed or could be created;
264: this does not necessarily mean that any files could be
265: processed inside.
1.13 schwarze 266: .El
267: .Pp
268: If the
269: .Fl v
270: flag is specified twice, the following messages also appear:
271: .Bl -tag -width Ds -offset indent
272: .It allowing up to Ar number No files in flight
273: This is printed at the beginning of the iteration,
274: showing the maximum number of files that
275: .Nm
276: allows to be in flight at any given time.
277: .It files in flight: Ar old No \- Ar decrement No = Ar new
278: This message is printed when
279: .Nm
280: learns about
281: .Xr mandocd 8
282: accepting more than one file at the same time.
283: The three numbers printed are the old number of files in flight,
284: the amount this number is being reduced, and the resulting
285: new number of files in flight.
286: .It waiting for Ar number No files in flight
287: This message is printed at the end of the iteration, after
288: .Nm
289: has submitted all files to
290: .Xr mandocd 8
291: that it intends to.
292: THe message informs about the number of files still in flight
293: at this point.
294: The
295: .Nm
296: program then waits until
297: .Xr mandocd 8
298: has accepted them all or until an error occurs.
1.9 schwarze 299: .El
1.1 kristaps 300: .Sh SEE ALSO
301: .Xr mandoc 1 ,
1.7 schwarze 302: .Xr mandocd 8
303: .Sh HISTORY
304: A
305: .Nm
306: utility first appeared in
307: .Fx 1.0 .
308: Other, incompatible implementations appeared in
309: .Nx 1.0
310: and in
311: .Sy man-db No 2.2 .
312: .Pp
313: This version appeared in version 1.14.1 of the
314: .Sy mandoc
315: toolkit.
1.1 kristaps 316: .Sh AUTHORS
1.7 schwarze 317: .An -nosplit
318: The first
319: .Nm
320: implementation was a short shell script by
321: .An Christoph Robitschko
322: in July 1993.
323: .Pp
1.1 kristaps 324: The
1.7 schwarze 325: .Nx
326: implementations were written by
327: .An J. T. Conklin Aq Mt jtc@netbsd.org
328: in 1993,
329: .An Christian E. Hopps Aq Mt chopps@netbsd.org
330: in 1994,
331: and
332: .An Dante Profeta Aq Mt dante@netbsd.org
333: in 1999; the
334: .Sy man-db
335: implementation by
336: .An Graeme W. Wilford
337: in 1994; and the
338: .Fx
339: implementations by
340: .An Wolfram Schneider Aq Mt wosch@freebsd.org
341: in 1995 and
342: .An John Rochester Aq Mt john@jrochester.org
343: in 2002.
344: .Pp
345: The concept of the present version was designed and implemented by
346: .An Michael Stapelberg Aq Mt stapelberg@debian.org
347: in 2017.
348: Option and argument handling and directory iteration was added by
349: .An Ingo Schwarze Aq Mt schwarze@openbsd.org .
350: .Sh CAVEATS
351: All versions of
352: .Nm
353: are incompatible with each other because each caters to the needs
354: of a specific operating system, for example regarding directory
355: structures and file naming conventions.
356: .Pp
357: This version is more flexible than the others in so far as it does
358: not assume any particular directory structure or naming convention.
359: That flexibility comes at the price of not being able to change the
360: names and relative paths of the source files when reusing them to
361: store the formatted files, of not supporting any configuration file
362: formats or environment variables, and of being unable to scan for
363: and remove junk files in
364: .Ar dstdir .
365: .Pp
366: Currently,
1.1 kristaps 367: .Nm
1.7 schwarze 368: always reformats each page, even if the formatted version is newer
369: than the source version.
CVSweb