summaryrefslogtreecommitdiff
path: root/xsd/doc/buildfile
blob: b15831a7b32fa8d4835565b6bdcc67e6152d89e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# file      : doc/buildfile
# license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

define css: doc
css{*}: extension = css

define xsd: doc
xsd{*}: extension = xsd

define xhtml: doc
xhtml{*}: extension = xhtml

define ps: doc
ps{*}: extension = ps

define pdf: doc
pdf{*}: extension = pdf

define html2ps: file
html2ps{*}: extension = html2ps

define png: doc
png{*}: extension = png

define svg: file
svg{*}: extension = svg

import! [metadata] cli = cli%exe{cli}

# Import the html2ps and ps2pdf14 programs only if present on the system. This
# way a distribution that includes pre-generated files can be built without
# installing these programs.
#
import? html2ps  = html2ps%exe{html2ps}
import? ps2pdf14 = ps2pdf14%exe{ps2pdf14}

if $config.xsd.develop
{
  if ($html2ps == [null] || $ps2pdf14 == [null])
    warn "html2ps and/or ps2pdf14 are not available, not generating .ps and .pdf documentation"
}

./: xsd{custom-literals}

# Generate the man pages.
#
ops = $(src_root)/xsd/cxx/cli{options tree/options parser/options}

doc_version = [string] "$version.major\.$version.minor\.$version.patch"
if $version.pre_release
  doc_version += "-$version.pre_release_string"

# Let's take the last for-digit number to cover 2000-2021,2022.
#
doc_year = $regex.replace($copyright, '.+[-, ]([0-9][0-9][0-9][0-9]) .+', '\1')

man_options = -v project="XSD"          \
              -v version="$doc_version" \
              -v copyright="$copyright" \
              -I $src_root              \
              --stdout                  \
              --suppress-undocumented   \
              --exclude-base


# Note: *logue and *-header are not real man pages.
#
./: man1{xsd}: $ops                     \
               file{xsd-prologue.1      \
                    xsd-tree-header.1   \
                    xsd-parser-header.1 \
                    xsd-epilogue.1}     \
               $cli
{
  dist = true # Include into the distribution for user's convenience.
}
{{
  diag cli --man ($<[0])

  # Use the copyright year to approximate the last authoring date.
  #
  $cli --generate-man -v date="January $doc_year"  \
       $man_options                                \
       --class CXX::options                        \
       --class options                             \
       --man-prologue-file $path($<[3])            \
       $path($<[0]) >$path($>)

  $cli --generate-man -v date="January $doc_year"  \
       $man_options                                \
       --man-prologue-file $path($<[4])            \
       $path($<[1]) >>$path($>)

  $cli --generate-man -v date="January $doc_year"  \
       $man_options                                \
       --man-prologue-file $path($<[5])            \
       --man-epilogue-file $path($<[6])            \
       $path($<[2]) >>$path($>)
}}

# Note: *logue and *-header are not real xhtml files.
#
./: xhtml{xsd}: $ops                         \
                file{xsd-prologue.xhtml      \
                     xsd-tree-header.xhtml   \
                     xsd-parser-header.xhtml \
                     xsd-epilogue.xhtml}     \
                css{*}                       \
                $cli
{
  dist = true
}
{{
  diag cli --html ($<[0])

  $cli --generate-html -v date="January $doc_year"  \
       $man_options                                 \
       --class CXX::options                         \
       --class options                              \
       --html-prologue-file $path($<[3])            \
       $path($<[0]) >$path($>)

  $cli --generate-html -v date="January $doc_year"  \
       $man_options                                 \
       --html-prologue-file $path($<[4])            \
       $path($<[1]) >>$path($>)

  $cli --generate-html -v date="January $doc_year"  \
       $man_options                                 \
       --html-prologue-file $path($<[5])            \
       --html-epilogue-file $path($<[6])            \
       $path($<[2]) >>$path($>)
}}

# Generate the user guide/manual ps/pdf files if the html2ps and ps2pdf14
# programs are imported and handle (install, distribute, etc) the
# pre-generated files otherwise, if present.
#
for d: cxx/parser/guide/ cxx/tree/guide/ cxx/tree/manual/
{
  p = "([dir_path] $path.leaf($path.directory($d)))" # parser, tree
  l = "([dir_path] $path.leaf($d))"                  # guide, manual
  f = "cxx-$p-$l"                                    # cxx-parser-guide, etc

  ./: $d/{png svg}{*}

  ./: $d/xhtml{index}: $d/in{index}
  {
    in.symbol = '@'

    dist  = true
    clean = ($src_root != $out_root)
  }

  if ($html2ps != [null] && $ps2pdf14 != [null])
  {
    # Note that we include these generated files into the distribution and
    # don't remove them when cleaning in src (so that clean results in a state
    # identical to distributed).
    #
    ./: $d/ps{$f}: $d/xhtml{index} $d/html2ps{$l} $html2ps
    {
      base = $src_base/$d

      dist  = true
      clean = ($src_root != $out_root)
    }
    {{
      diag html2ps ($<[0])

      # Note: --base must include trailing directory separator.
      #
      $html2ps --base $base -f $path($<[1]) -o $path($>) $path($<[0])
    }}

    ./: $d/pdf{$f}: $d/ps{$f} $ps2pdf14
    {
      dist  = true
      clean = ($src_root != $out_root)
    }
    {{
      diag ps2pdf14 ($<[0])

      $ps2pdf14 -dOptimize=true -dEmbedAllFonts=true $path($<[0]) $path($>)
    }}

    $d/html2ps{$l}: $d/in{$l}
    {
      in.symbol = '@'
    }
  }
  else
    ./: $d/{ps pdf}{+$f} $d/file{$l.html2ps.in}
}

doc{*}: install.subdirs = true