Raw
1 manpages = {
2 # Category 1.
3 'git-add.adoc' : 1,
4 'git-am.adoc' : 1,
5 'git-annotate.adoc' : 1,
6 'git-apply.adoc' : 1,
7 'git-archimport.adoc' : 1,
8 'git-archive.adoc' : 1,
9 'git-backfill.adoc' : 1,
10 'git-bisect.adoc' : 1,
11 'git-blame.adoc' : 1,
12 'git-branch.adoc' : 1,
13 'git-bugreport.adoc' : 1,
14 'git-bundle.adoc' : 1,
15 'git-cat-file.adoc' : 1,
16 'git-check-attr.adoc' : 1,
17 'git-check-ignore.adoc' : 1,
18 'git-check-mailmap.adoc' : 1,
19 'git-checkout-index.adoc' : 1,
20 'git-checkout.adoc' : 1,
21 'git-check-ref-format.adoc' : 1,
22 'git-cherry-pick.adoc' : 1,
23 'git-cherry.adoc' : 1,
24 'git-citool.adoc' : 1,
25 'git-clean.adoc' : 1,
26 'git-clone.adoc' : 1,
27 'git-column.adoc' : 1,
28 'git-commit-graph.adoc' : 1,
29 'git-commit-tree.adoc' : 1,
30 'git-commit.adoc' : 1,
31 'git-config.adoc' : 1,
32 'git-count-objects.adoc' : 1,
33 'git-credential-cache--daemon.adoc' : 1,
34 'git-credential-cache.adoc' : 1,
35 'git-credential-store.adoc' : 1,
36 'git-credential.adoc' : 1,
37 'git-cvsexportcommit.adoc' : 1,
38 'git-cvsimport.adoc' : 1,
39 'git-cvsserver.adoc' : 1,
40 'git-daemon.adoc' : 1,
41 'git-describe.adoc' : 1,
42 'git-diagnose.adoc' : 1,
43 'git-diff-files.adoc' : 1,
44 'git-diff-index.adoc' : 1,
45 'git-diff-pairs.adoc' : 1,
46 'git-difftool.adoc' : 1,
47 'git-diff-tree.adoc' : 1,
48 'git-diff.adoc' : 1,
49 'git-fast-export.adoc' : 1,
50 'git-fast-import.adoc' : 1,
51 'git-fetch-pack.adoc' : 1,
52 'git-fetch.adoc' : 1,
53 'git-filter-branch.adoc' : 1,
54 'git-fmt-merge-msg.adoc' : 1,
55 'git-for-each-ref.adoc' : 1,
56 'git-for-each-repo.adoc' : 1,
57 'git-format-patch.adoc' : 1,
58 'git-format-rev.adoc' : 1,
59 'git-fsck-objects.adoc' : 1,
60 'git-fsck.adoc' : 1,
61 'git-fsmonitor--daemon.adoc' : 1,
62 'git-gc.adoc' : 1,
63 'git-get-tar-commit-id.adoc' : 1,
64 'git-grep.adoc' : 1,
65 'git-gui.adoc' : 1,
66 'git-hash-object.adoc' : 1,
67 'git-help.adoc' : 1,
68 'git-history.adoc' : 1,
69 'git-hook.adoc' : 1,
70 'git-http-backend.adoc' : 1,
71 'git-http-fetch.adoc' : 1,
72 'git-http-push.adoc' : 1,
73 'git-imap-send.adoc' : 1,
74 'git-index-pack.adoc' : 1,
75 'git-init-db.adoc' : 1,
76 'git-init.adoc' : 1,
77 'git-instaweb.adoc' : 1,
78 'git-interpret-trailers.adoc' : 1,
79 'git-last-modified.adoc' : 1,
80 'git-log.adoc' : 1,
81 'git-ls-files.adoc' : 1,
82 'git-ls-remote.adoc' : 1,
83 'git-ls-tree.adoc' : 1,
84 'git-mailinfo.adoc' : 1,
85 'git-mailsplit.adoc' : 1,
86 'git-maintenance.adoc' : 1,
87 'git-merge-base.adoc' : 1,
88 'git-merge-file.adoc' : 1,
89 'git-merge-index.adoc' : 1,
90 'git-merge-one-file.adoc' : 1,
91 'git-mergetool--lib.adoc' : 1,
92 'git-mergetool.adoc' : 1,
93 'git-merge-tree.adoc' : 1,
94 'git-merge.adoc' : 1,
95 'git-mktag.adoc' : 1,
96 'git-mktree.adoc' : 1,
97 'git-multi-pack-index.adoc' : 1,
98 'git-mv.adoc' : 1,
99 'git-name-rev.adoc' : 1,
100 'git-notes.adoc' : 1,
101 'git-p4.adoc' : 1,
102 'git-pack-objects.adoc' : 1,
103 'git-pack-refs.adoc' : 1,
104 'git-patch-id.adoc' : 1,
105 'git-prune-packed.adoc' : 1,
106 'git-prune.adoc' : 1,
107 'git-pull.adoc' : 1,
108 'git-push.adoc' : 1,
109 'git-quiltimport.adoc' : 1,
110 'git-range-diff.adoc' : 1,
111 'git-read-tree.adoc' : 1,
112 'git-rebase.adoc' : 1,
113 'git-receive-pack.adoc' : 1,
114 'git-reflog.adoc' : 1,
115 'git-refs.adoc' : 1,
116 'git-remote-ext.adoc' : 1,
117 'git-remote-fd.adoc' : 1,
118 'git-remote.adoc' : 1,
119 'git-repack.adoc' : 1,
120 'git-replace.adoc' : 1,
121 'git-replay.adoc' : 1,
122 'git-repo.adoc' : 1,
123 'git-request-pull.adoc' : 1,
124 'git-rerere.adoc' : 1,
125 'git-reset.adoc' : 1,
126 'git-restore.adoc' : 1,
127 'git-revert.adoc' : 1,
128 'git-rev-list.adoc' : 1,
129 'git-rev-parse.adoc' : 1,
130 'git-rm.adoc' : 1,
131 'git-send-email.adoc' : 1,
132 'git-send-pack.adoc' : 1,
133 'git-shell.adoc' : 1,
134 'git-sh-i18n--envsubst.adoc' : 1,
135 'git-sh-i18n.adoc' : 1,
136 'git-shortlog.adoc' : 1,
137 'git-show-branch.adoc' : 1,
138 'git-show-index.adoc' : 1,
139 'git-show-ref.adoc' : 1,
140 'git-show.adoc' : 1,
141 'git-sh-setup.adoc' : 1,
142 'git-sparse-checkout.adoc' : 1,
143 'git-stage.adoc' : 1,
144 'git-stash.adoc' : 1,
145 'git-status.adoc' : 1,
146 'git-stripspace.adoc' : 1,
147 'git-submodule.adoc' : 1,
148 'git-svn.adoc' : 1,
149 'git-switch.adoc' : 1,
150 'git-symbolic-ref.adoc' : 1,
151 'git-tag.adoc' : 1,
152 'git-unpack-file.adoc' : 1,
153 'git-unpack-objects.adoc' : 1,
154 'git-update-index.adoc' : 1,
155 'git-update-ref.adoc' : 1,
156 'git-update-server-info.adoc' : 1,
157 'git-upload-archive.adoc' : 1,
158 'git-upload-pack.adoc' : 1,
159 'git-url-parse.adoc' : 1,
160 'git-var.adoc' : 1,
161 'git-verify-commit.adoc' : 1,
162 'git-verify-pack.adoc' : 1,
163 'git-verify-tag.adoc' : 1,
164 'git-version.adoc' : 1,
165 'git-web--browse.adoc' : 1,
166 'git-worktree.adoc' : 1,
167 'git-write-tree.adoc' : 1,
168 'git.adoc' : 1,
169 'gitk.adoc' : 1,
170 'gitweb.adoc' : 1,
171 'scalar.adoc' : 1,
172
173 # Category 5.
174 'gitattributes.adoc' : 5,
175 'gitformat-bundle.adoc' : 5,
176 'gitformat-chunk.adoc' : 5,
177 'gitformat-commit-graph.adoc' : 5,
178 'gitformat-index.adoc' : 5,
179 'gitformat-loose.adoc' : 5,
180 'gitformat-pack.adoc' : 5,
181 'gitformat-signature.adoc' : 5,
182 'githooks.adoc' : 5,
183 'gitignore.adoc' : 5,
184 'gitmailmap.adoc' : 5,
185 'gitmodules.adoc' : 5,
186 'gitprotocol-capabilities.adoc' : 5,
187 'gitprotocol-common.adoc' : 5,
188 'gitprotocol-http.adoc' : 5,
189 'gitprotocol-pack.adoc' : 5,
190 'gitprotocol-v2.adoc' : 5,
191 'gitrepository-layout.adoc' : 5,
192 'gitweb.conf.adoc' : 5,
193
194 # Category 7.
195 'gitcli.adoc' : 7,
196 'gitcore-tutorial.adoc' : 7,
197 'gitcredentials.adoc' : 7,
198 'gitcvs-migration.adoc' : 7,
199 'gitdatamodel.adoc' : 7,
200 'gitdiffcore.adoc' : 7,
201 'giteveryday.adoc' : 7,
202 'gitfaq.adoc' : 7,
203 'gitglossary.adoc' : 7,
204 'gitpacking.adoc' : 7,
205 'gitnamespaces.adoc' : 7,
206 'gitremote-helpers.adoc' : 7,
207 'gitrevisions.adoc' : 7,
208 'gitsubmodules.adoc' : 7,
209 'gittutorial-2.adoc' : 7,
210 'gittutorial.adoc' : 7,
211 'gitworkflows.adoc' : 7,
212 }
213
214 manpages_breaking_changes = {
215 'git-pack-redundant.adoc' : 1,
216 'git-whatchanged.adoc' : 1,
217 }
218
219 if not get_option('breaking_changes')
220 manpages += manpages_breaking_changes
221 endif
222
223 docs_backend = get_option('docs_backend')
224 if docs_backend == 'auto'
225 if find_program('asciidoc', dirs: program_path, native: true, required: false).found()
226 docs_backend = 'asciidoc'
227 elif find_program('asciidoctor', dirs: program_path, native: true, required: false).found()
228 docs_backend = 'asciidoctor'
229 else
230 error('Neither asciidoc nor asciidoctor were found.')
231 endif
232 endif
233
234 if docs_backend == 'asciidoc'
235 asciidoc = find_program('asciidoc', dirs: program_path, native: true)
236 asciidoc_html = 'xhtml11'
237 asciidoc_docbook = 'docbook'
238 xmlto_extra = [ ]
239
240 asciidoc_conf = custom_target(
241 command: [
242 shell,
243 meson.project_source_root() / 'GIT-VERSION-GEN',
244 meson.project_source_root(),
245 '@INPUT@',
246 '@OUTPUT@',
247 ],
248 input: 'asciidoc.conf.in',
249 output: 'asciidoc.conf',
250 depends: [git_version_file],
251 env: version_gen_environment,
252 )
253
254 asciidoc_common_options = [
255 asciidoc,
256 '--conf-file=' + asciidoc_conf.full_path(),
257 '--attribute=build_dir=' + meson.current_build_dir(),
258 ]
259
260 pager_opt = get_option('default_pager')
261 if pager_opt != '' and pager_opt != 'less'
262 asciidoc_common_options += '-agit-default-pager=' + pager_opt
263 endif
264
265 editor_opt = get_option('default_editor')
266 if editor_opt != '' and editor_opt != 'vi'
267 asciidoc_common_options += '-agit-default-editor=' + editor_opt
268 endif
269
270 documentation_deps = [
271 asciidoc_conf,
272 ]
273 elif docs_backend == 'asciidoctor'
274 asciidoctor = find_program('asciidoctor', dirs: program_path, native: true)
275 asciidoc_html = 'xhtml5'
276 asciidoc_docbook = 'docbook5'
277 xmlto_extra = [
278 '--skip-validation',
279 '-x', meson.current_source_dir() / 'manpage.xsl',
280 ]
281
282 asciidoctor_extensions = custom_target(
283 command: [
284 shell,
285 meson.project_source_root() / 'GIT-VERSION-GEN',
286 meson.project_source_root(),
287 '@INPUT@',
288 '@OUTPUT@',
289 ],
290 input: 'asciidoctor-extensions.rb.in',
291 output: 'asciidoctor-extensions.rb',
292 depends: [git_version_file],
293 env: version_gen_environment,
294 )
295
296 asciidoc_common_options = [
297 asciidoctor,
298 '--attribute', 'compat-mode',
299 '--attribute', 'tabsize=8',
300 '--attribute', 'litdd=--',
301 '--attribute', 'docinfo=shared',
302 '--attribute', 'build_dir=' + meson.current_build_dir(),
303 '--load-path', meson.current_build_dir(),
304 '--require', 'asciidoctor-extensions',
305 ]
306
307 pager_opt = get_option('default_pager')
308 if pager_opt != '' and pager_opt != 'less'
309 asciidoc_common_options += '-agit-default-pager=' + pager_opt
310 endif
311
312 editor_opt = get_option('default_editor')
313 if editor_opt != '' and editor_opt != 'vi'
314 asciidoc_common_options += '-agit-default-editor=' + editor_opt
315 endif
316
317 documentation_deps = [
318 asciidoctor_extensions,
319 ]
320 endif
321
322 if get_option('breaking_changes')
323 asciidoc_common_options += ['--attribute', 'with-breaking-changes']
324 endif
325
326 xmlto = find_program('xmlto', dirs: program_path, native: true)
327
328 cmd_lists = [
329 'cmds-ancillaryinterrogators.adoc',
330 'cmds-ancillarymanipulators.adoc',
331 'cmds-mainporcelain.adoc',
332 'cmds-plumbinginterrogators.adoc',
333 'cmds-plumbingmanipulators.adoc',
334 'cmds-synchingrepositories.adoc',
335 'cmds-synchelpers.adoc',
336 'cmds-guide.adoc',
337 'cmds-developerinterfaces.adoc',
338 'cmds-userinterfaces.adoc',
339 'cmds-purehelpers.adoc',
340 'cmds-foreignscminterface.adoc',
341 ]
342
343 documentation_deps += custom_target(
344 command: [
345 shell,
346 '@INPUT@',
347 meson.project_source_root(),
348 meson.current_build_dir(),
349 ] + cmd_lists,
350 input: 'cmd-list.sh',
351 output: cmd_lists
352 )
353
354 foreach mode : [ 'diff', 'merge' ]
355 documentation_deps += custom_target(
356 command: [
357 shell,
358 '@INPUT@',
359 meson.project_source_root(),
360 mode,
361 '@OUTPUT@'
362 ],
363 input: 'generate-mergetool-list.sh',
364 output: 'mergetools-' + mode + '.adoc',
365 )
366 endforeach
367
368 foreach manpage, category : manpages
369 if get_option('docs').contains('man')
370 manpage_xml_target = custom_target(
371 command: asciidoc_common_options + [
372 '--backend=' + asciidoc_docbook,
373 '--doctype=manpage',
374 '--out-file=@OUTPUT@',
375 '@INPUT@',
376 ],
377 depends: documentation_deps,
378 input: manpage,
379 output: fs.stem(manpage) + '.xml',
380 )
381
382 doc_targets += custom_target(
383 command: [
384 xmlto,
385 '-m', '@INPUT0@',
386 '-m', '@INPUT1@',
387 '--stringparam',
388 'man.base.url.for.relative.links=' + get_option('prefix') / get_option('mandir'),
389 'man',
390 manpage_xml_target,
391 '-o',
392 meson.current_build_dir(),
393 ] + xmlto_extra,
394 input: [
395 'manpage-normal.xsl',
396 'manpage-bold-literal.xsl',
397 ],
398 output: fs.stem(manpage) + '.' + category.to_string(),
399 install: true,
400 install_dir: get_option('mandir') / 'man' + category.to_string(),
401 )
402 endif
403
404 if get_option('docs').contains('html')
405 doc_targets += custom_target(
406 command: asciidoc_common_options + [
407 '--backend=' + asciidoc_html,
408 '--doctype=manpage',
409 '--out-file=@OUTPUT@',
410 '@INPUT@',
411 ],
412 depends: documentation_deps,
413 input: manpage,
414 output: fs.stem(manpage) + '.html',
415 install: true,
416 install_dir: htmldir,
417 )
418 endif
419 endforeach
420
421 if get_option('docs').contains('html')
422 configure_file(
423 input: 'docinfo-html.in',
424 output: 'docinfo.html',
425 copy: true,
426 install: true,
427 install_dir: htmldir,
428 )
429
430 configure_file(
431 input: 'docbook-xsl.css',
432 output: 'docbook-xsl.css',
433 copy: true,
434 install: true,
435 install_dir: htmldir,
436 )
437
438 install_symlink('index.html',
439 install_dir: htmldir,
440 pointing_to: 'git.html',
441 )
442
443 xsltproc = find_program('xsltproc', dirs: program_path, native: true)
444
445 user_manual_xml = custom_target(
446 command: asciidoc_common_options + [
447 '--backend=' + asciidoc_docbook,
448 '--doctype=book',
449 '--out-file=@OUTPUT@',
450 '@INPUT@',
451 ],
452 input: 'user-manual.adoc',
453 output: 'user-manual.xml',
454 depends: documentation_deps,
455 )
456
457 doc_targets += custom_target(
458 command: [
459 xsltproc,
460 '--xinclude',
461 '--stringparam', 'html.stylesheet', 'docbook-xsl.css',
462 '--param', 'generate.consistent.ids', '1',
463 '--output', '@OUTPUT@',
464 '@INPUT@',
465 user_manual_xml,
466 ],
467 input: 'docbook.xsl',
468 output: 'user-manual.html',
469 install: true,
470 install_dir: htmldir,
471 )
472
473 articles = [
474 'BreakingChanges.adoc',
475 'DecisionMaking.adoc',
476 'MyFirstContribution.adoc',
477 'MyFirstObjectWalk.adoc',
478 'ReviewingGuidelines.adoc',
479 'SubmittingPatches',
480 'ToolsForGit.adoc',
481 'git-bisect-lk2009.adoc',
482 'git-tools.adoc',
483 ]
484
485 foreach article : articles
486 doc_targets += custom_target(
487 command: asciidoc_common_options + [
488 '--backend=' + asciidoc_html,
489 '--out-file=@OUTPUT@',
490 '@INPUT@',
491 ],
492 input: article,
493 output: fs.stem(article) + '.html',
494 depends: documentation_deps,
495 install: true,
496 install_dir: htmldir,
497 )
498 endforeach
499
500 asciidoc_html_options = asciidoc_common_options + [
501 '--backend=' + asciidoc_html,
502 '--out-file=@OUTPUT@',
503 '--attribute', 'git-relative-html-prefix=../',
504 '@INPUT@',
505 ]
506
507 subdir('howto')
508 subdir('technical')
509 endif
510
511 # Sanity check that we are not missing any tests present in 't/'. This check
512 # only runs once at configure time and is thus best-effort, only. Furthermore,
513 # it only verifies man pages for the sake of simplicity.
514 configured_manpages = manpages.keys()
515 configured_manpages += manpages_breaking_changes.keys()
516 configured_manpages += [ 'git-bisect-lk2009.adoc', 'git-tools.adoc' ]
517 actual_manpages = run_command(shell, '-c', 'ls git*.adoc scalar.adoc',
518 check: true,
519 env: script_environment,
520 ).stdout().strip().split('\n')
521
522 if configured_manpages != actual_manpages
523 missing_manpage = [ ]
524 foreach actual_manpage : actual_manpages
525 if actual_manpage not in configured_manpages
526 missing_manpage += actual_manpage
527 endif
528 endforeach
529 if missing_manpage.length() > 0
530 error('Man page found, but not configured:\n\n - ' + '\n - '.join(missing_manpage))
531 endif
532
533 superfluous_manpage = [ ]
534 foreach configured_manpage : configured_manpages
535 if configured_manpage not in actual_manpages
536 superfluous_manpage += configured_manpage
537 endif
538 endforeach
539 if superfluous_manpage.length() > 0
540 error('Man page configured, but not found:\n\n - ' + '\n - '.join(superfluous_manpage))
541 endif
542 endif