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