Debian Codegraph @

debian/tests/generate-man

raw
1 #!/bin/sh
2
3 set -exu
4
5 # This is a test that generates a man page and compares the output to what's expected.
6 cd ${AUTOPKGTEST_TMP}
7
8 export SOURCE_DATE_EPOCH=1566164804
9 cat > example.adoc << __EOF__
10 = example(1)
11 Joseph Herlant
12 v1.0.0
13 :doctype: manpage
14 :manmanual: EXAMPLE
15 :mansource: EXAMPLE
16
17 == Name
18
19 example - an example of manpage
20
21 == Synopsis
22
23 *example* [_OPTION_]... _FILE_...
24
25 == Options
26
27 *-o, --out-file*=_OUT_FILE_::
28 Write result to file _OUT_FILE_.
29
30 == Exit status
31
32 *0*::
33 Success.
34 Foo!
35
36 *1*::
37 Failure.
38 Bar :(
39
40 == Resources
41
42 *Project web site:* http://example.org
43
44 == Copying
45
46 Copyright (C) 2019 {author}. +
47 Free use of this software is granted under the terms of the MIT License.
48 __EOF__
49
50 cat > example.ref << __EOF__
51 '\" t
52 .\" Title: example
53 .\" Author: Joseph Herlant
54 .\" Date: 2019-08-18
55 .\" Manual: EXAMPLE
56 .\" Source: EXAMPLE
57 .\" Language: English
58 .\"
59 .TH "EXAMPLE" "1" "2019-08-18" "EXAMPLE" "EXAMPLE"
60 .ie \n(.g .ds Aq \(aq
61 .el .ds Aq '
62 .ss \n[.ss] 0
63 .nh
64 .ad l
65 .de URL
66 \fI\\\\\$2\fP <\\\\\$1>\\\\\$3
67 ..
68 .als MTO URL
69 .if \n[.g] \{\\
70 . mso www.tmac
71 . am URL
72 . ad l
73 . .
74 . am MTO
75 . ad l
76 . .
77 . LINKSTYLE blue R < >
78 .\}
79 .SH "NAME"
80 example \- an example of manpage
81 .SH "SYNOPSIS"
82 .sp
83 \fBexample\fP [\fIOPTION\fP].\|.\|. \fIFILE\fP.\|.\|.
84 .SH "OPTIONS"
85 .sp
86 \fB\-o, \-\-out\-file\fP=\fIOUT_FILE\fP
87 .RS 4
88 Write result to file \fIOUT_FILE\fP.
89 .RE
90 .SH "EXIT STATUS"
91 .sp
92 \fB0\fP
93 .RS 4
94 Success.
95 Foo!
96 .RE
97 .sp
98 \fB1\fP
99 .RS 4
100 Failure.
101 Bar :(
102 .RE
103 .SH "RESOURCES"
104 .sp
105 \fBProject web site:\fP \c
106 .URL "http://example.org" "" ""
107 .SH "COPYING"
108 .sp
109 Copyright \(co 2019 Joseph Herlant.
110 .br
111 Free use of this software is granted under the terms of the MIT License.
112 .SH "AUTHOR"
113 .sp
114 Joseph Herlant
115 __EOF__
116
117 asciidoctor -b manpage example.adoc
118 # Removing the generator as it contains the version so we would have to change that all the time
119 sed '/Generator/d' -i example.1
120 # Remove the newline character at the end of the ref file
121 truncate -s -1 example.ref
122 diff example.ref example.1