Annotation of mandoc/catman.8, Revision 1.13
1.13 ! schwarze 1: .\" $Id: catman.8,v 1.12 2025/06/30 01:44:28 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
157: Starting the iteration was attempted, but failed.
158: .El
159: .Pp
160: Some fatal errors cause the iteration over input files to be aborted
161: prematurely:
162: .Bl -tag -width Ds -offset indent
163: .It FATAL: Sy fts_read : Ar reason
164: A call to
165: .Xr fts_read 3
166: returned
167: .Dv NULL ,
168: meaning that the iteration failed before being complete.
1.12 schwarze 169: .It FATAL: mandocd child died: got Ar SIGNAME
170: This message appears if
171: .Nm
172: gets the
173: .Dv SIGCHLD
174: or
175: .Dv SIGPIPE
176: signal, most likely due to a fatal bug in
177: .Xr mandocd 8 .
1.9 schwarze 178: .It FATAL: Sy sendmsg : Ar reason
179: The file descriptors needed to process one of the manual pages
180: could not be sent to
181: .Xr mandocd 8 ,
182: for example because
183: .Xr mandocd 8
184: could not be started or died unexpectedly.
1.12 schwarze 185: .It FATAL: signal Ar SIGNAME
186: This message appears if
187: .Nm
188: gets a
189: .Dv SIGHUP ,
190: .Dv SIGINT ,
191: or
192: .Dv SIGTERM
193: signal, for example because the user deliberately killed it.
1.9 schwarze 194: .El
195: .Pp
196: Some non-fatal errors cause a single subdirectory to be skipped.
197: The iteration is not aborted but continues with the next subdirectory,
198: and the exit status is unaffected:
199: .Bl -tag -width Ds -offset indent
200: .It directory Ar subdirectory No unreadable : Ar reason
201: A directory below
202: .Ar srcdir
203: could not be read and is skipped.
204: .It directory Ar subdirectory No causes cycle
205: A directory below
206: .Ar srcdir
207: is skipped because it would cause cyclic processing.
208: .It Sy mkdirat Ar subdirectory : reason
209: A required directory below
210: .Ar dstdir
211: does not exist and could not be created.
212: The corresponding subdirectory below
213: .Ar srcdir
214: is skipped.
215: .El
216: .Pp
217: Some non-fatal errors cause a single source file to be skipped.
218: The iteration is not aborted but continues with the next file,
219: and the exit status is unaffected:
220: .Bl -tag -width Ds -offset indent
221: .It file Ar filename : reason
222: The function
223: .Xr fts_read 3
224: reported a non-fatal error with respect to
225: .Ar filename .
1.10 schwarze 226: .It file Ar filename : No not a regular file
1.9 schwarze 227: For example, it might be a symbolic link or a device file.
228: .It Sy open Ar filename No for reading : Ar reason
229: A file below
1.7 schwarze 230: .Ar srcdir
1.9 schwarze 231: could not be read, for example due to permission problems.
232: .It Sy openat Ar filename No for writing : Ar reason
233: A file below
1.7 schwarze 234: .Ar dstdir
1.9 schwarze 235: could not be created or truncated, for example due to permission problems.
1.1 kristaps 236: .El
237: .Pp
1.9 schwarze 238: If errors occur, the applicable summary messages appear
239: after the end of the iteration:
240: .Pp
241: .Bl -tag -width Ds -offset indent -compact
242: .It skipped Ar number No directories due to errors
243: .It skipped Ar number No files due to errors
244: .It processing aborted due to fatal error
1.11 schwarze 245: .El
246: .Pp
247: If the
248: .Fl v
249: flag is specified, the following summary message also appears:
1.13 ! schwarze 250: .Bl -tag -width Ds -offset indent
1.11 schwarze 251: .It processed Ar nfiles No files in Ar ndirs No directories
252: A file is counted if it could be opened for reading and the
253: corresponding output file could be opened for writing;
254: this does not necessarily mean that it is a useful manual page.
255: A directory is counted if it could be opened for reading and the
256: corresponding output directory existed or could be created;
257: this does not necessarily mean that any files could be
258: processed inside.
1.13 ! schwarze 259: .El
! 260: .Pp
! 261: If the
! 262: .Fl v
! 263: flag is specified twice, the following messages also appear:
! 264: .Bl -tag -width Ds -offset indent
! 265: .It allowing up to Ar number No files in flight
! 266: This is printed at the beginning of the iteration,
! 267: showing the maximum number of files that
! 268: .Nm
! 269: allows to be in flight at any given time.
! 270: .It files in flight: Ar old No \- Ar decrement No = Ar new
! 271: This message is printed when
! 272: .Nm
! 273: learns about
! 274: .Xr mandocd 8
! 275: accepting more than one file at the same time.
! 276: The three numbers printed are the old number of files in flight,
! 277: the amount this number is being reduced, and the resulting
! 278: new number of files in flight.
! 279: .It waiting for Ar number No files in flight
! 280: This message is printed at the end of the iteration, after
! 281: .Nm
! 282: has submitted all files to
! 283: .Xr mandocd 8
! 284: that it intends to.
! 285: THe message informs about the number of files still in flight
! 286: at this point.
! 287: The
! 288: .Nm
! 289: program then waits until
! 290: .Xr mandocd 8
! 291: has accepted them all or until an error occurs.
1.9 schwarze 292: .El
1.1 kristaps 293: .Sh SEE ALSO
294: .Xr mandoc 1 ,
1.7 schwarze 295: .Xr mandocd 8
296: .Sh HISTORY
297: A
298: .Nm
299: utility first appeared in
300: .Fx 1.0 .
301: Other, incompatible implementations appeared in
302: .Nx 1.0
303: and in
304: .Sy man-db No 2.2 .
305: .Pp
306: This version appeared in version 1.14.1 of the
307: .Sy mandoc
308: toolkit.
1.1 kristaps 309: .Sh AUTHORS
1.7 schwarze 310: .An -nosplit
311: The first
312: .Nm
313: implementation was a short shell script by
314: .An Christoph Robitschko
315: in July 1993.
316: .Pp
1.1 kristaps 317: The
1.7 schwarze 318: .Nx
319: implementations were written by
320: .An J. T. Conklin Aq Mt jtc@netbsd.org
321: in 1993,
322: .An Christian E. Hopps Aq Mt chopps@netbsd.org
323: in 1994,
324: and
325: .An Dante Profeta Aq Mt dante@netbsd.org
326: in 1999; the
327: .Sy man-db
328: implementation by
329: .An Graeme W. Wilford
330: in 1994; and the
331: .Fx
332: implementations by
333: .An Wolfram Schneider Aq Mt wosch@freebsd.org
334: in 1995 and
335: .An John Rochester Aq Mt john@jrochester.org
336: in 2002.
337: .Pp
338: The concept of the present version was designed and implemented by
339: .An Michael Stapelberg Aq Mt stapelberg@debian.org
340: in 2017.
341: Option and argument handling and directory iteration was added by
342: .An Ingo Schwarze Aq Mt schwarze@openbsd.org .
343: .Sh CAVEATS
344: All versions of
345: .Nm
346: are incompatible with each other because each caters to the needs
347: of a specific operating system, for example regarding directory
348: structures and file naming conventions.
349: .Pp
350: This version is more flexible than the others in so far as it does
351: not assume any particular directory structure or naming convention.
352: That flexibility comes at the price of not being able to change the
353: names and relative paths of the source files when reusing them to
354: store the formatted files, of not supporting any configuration file
355: formats or environment variables, and of being unable to scan for
356: and remove junk files in
357: .Ar dstdir .
358: .Pp
359: Currently,
1.1 kristaps 360: .Nm
1.7 schwarze 361: always reformats each page, even if the formatted version is newer
362: than the source version.
CVSweb