| 1 |
project('Meson documentation', version: '1.0') |
| 2 |
|
| 3 |
yaml_modname = get_option('unsafe_yaml') ? 'yaml' : 'strictyaml' |
| 4 |
py = import('python').find_installation('python3', modules: [yaml_modname], required: false) |
| 5 |
if not py.found() |
| 6 |
error(f'Cannot build documentation without yaml support') |
| 7 |
endif |
| 8 |
|
| 9 |
cur_bdir = meson.current_build_dir() |
| 10 |
|
| 11 |
sitemap = files('sitemap.txt') |
| 12 |
|
| 13 |
yaml_loader = get_option('unsafe_yaml') ? 'fastyaml' : 'yaml' |
| 14 |
genrefman = find_program('./genrefman.py') |
| 15 |
refman_binary = custom_target( |
| 16 |
'gen_refman_bin', |
| 17 |
input: sitemap, |
| 18 |
output: 'reference_manual.bin', |
| 19 |
depfile: 'reman_dep.d', |
| 20 |
command: [ |
| 21 |
genrefman, |
| 22 |
'-l', yaml_loader, |
| 23 |
'-g', 'pickle', |
| 24 |
'-o', '@OUTPUT@', |
| 25 |
'--depfile', '@DEPFILE@', |
| 26 |
'--force-color', |
| 27 |
] |
| 28 |
) |
| 29 |
|
| 30 |
refman_json = custom_target( |
| 31 |
'gen_refman_json', |
| 32 |
build_by_default: true, |
| 33 |
input: refman_binary, |
| 34 |
output: 'reference_manual.json', |
| 35 |
command: [ |
| 36 |
genrefman, |
| 37 |
'-l', 'pickle', |
| 38 |
'-g', 'json', |
| 39 |
'-i', '@INPUT@', |
| 40 |
'-o', '@OUTPUT@', |
| 41 |
'--force-color', |
| 42 |
], |
| 43 |
) |
| 44 |
test('validate_docs', find_program('./jsonvalidator.py'), args: [refman_json]) |
| 45 |
|
| 46 |
refman_man = custom_target( |
| 47 |
'gen_refman_man', |
| 48 |
build_by_default: true, |
| 49 |
input: refman_binary, |
| 50 |
output: 'meson-reference.3', |
| 51 |
command: [ |
| 52 |
genrefman, |
| 53 |
'-l', 'pickle', |
| 54 |
'-g', 'man', |
| 55 |
'-i', '@INPUT@', |
| 56 |
'-o', '@OUTPUT@', |
| 57 |
'--force-color', |
| 58 |
'--no-modules', |
| 59 |
], |
| 60 |
install: true, |
| 61 |
install_dir: get_option('mandir') / 'man3', |
| 62 |
) |
| 63 |
|
| 64 |
# Everything past here is HTML resources. |
| 65 |
if not get_option('html') |
| 66 |
subdir_done() |
| 67 |
endif |
| 68 |
|
| 69 |
# Only the script knows which files are being generated |
| 70 |
docs_gen = custom_target( |
| 71 |
'gen_docs', |
| 72 |
input: files('markdown/index.md'), |
| 73 |
output: 'gen_docs.stamp', |
| 74 |
command: [ |
| 75 |
files('../tools/regenerate_docs.py'), |
| 76 |
'--output-dir', cur_bdir, |
| 77 |
'--dummy-output-file', '@OUTPUT@', |
| 78 |
], |
| 79 |
build_by_default: true, |
| 80 |
install: false, |
| 81 |
) |
| 82 |
|
| 83 |
refman_md = custom_target( |
| 84 |
'gen_refman_md', |
| 85 |
input: refman_binary, |
| 86 |
output: ['configured_sitemap.txt', 'refman_links.json'], |
| 87 |
command: [ |
| 88 |
genrefman, |
| 89 |
'-l', 'pickle', |
| 90 |
'-g', 'md', |
| 91 |
'-s', sitemap, |
| 92 |
'-i', '@INPUT@', |
| 93 |
'-o', '@OUTPUT0@', |
| 94 |
'--link-defs', '@OUTPUT1@', |
| 95 |
'--force-color', |
| 96 |
'--no-modules', |
| 97 |
], |
| 98 |
) |
| 99 |
sitemap = refman_md[0] |
| 100 |
|
| 101 |
genrelnotes = custom_target( |
| 102 |
output: ['sitemap-genrelnotes.txt'], |
| 103 |
build_always_stale: true, |
| 104 |
command: [find_program('genrelnotes.py'), |
| 105 |
'--input-sitemap', sitemap, |
| 106 |
'--output-sitemap', '@OUTPUT0@', |
| 107 |
'--output-dir', meson.current_build_dir(), |
| 108 |
'--source-dir', meson.current_source_dir(), |
| 109 |
] |
| 110 |
) |
| 111 |
sitemap = genrelnotes[0] |
| 112 |
|
| 113 |
hotdoc_prog = find_program('hotdoc', version: '>=0.13.7') |
| 114 |
py = import('python').find_installation('python3', modules: ['chevron'], required: false) |
| 115 |
if not py.found() |
| 116 |
error('Building the HTML docs requires the chevron module to render generated markdown pages') |
| 117 |
endif |
| 118 |
|
| 119 |
hotdoc = import('hotdoc') |
| 120 |
documentation = hotdoc.generate_doc(meson.project_name(), |
| 121 |
project_version: meson.project_version(), |
| 122 |
sitemap: sitemap, |
| 123 |
build_by_default: true, |
| 124 |
depends: docs_gen, |
| 125 |
index: 'markdown/index.md', |
| 126 |
install: false, |
| 127 |
extra_assets: ['images/'], |
| 128 |
include_paths: ['markdown', cur_bdir], |
| 129 |
default_license: 'CC-BY-SAv4.0', |
| 130 |
html_extra_theme: join_paths('theme', 'extra'), |
| 131 |
git_upload_repository: '[email protected]:mesonbuild/mesonbuild.github.io.git', |
| 132 |
edit_on_github_repository: 'https://github.com/mesonbuild/meson', |
| 133 |
syntax_highlighting_activate: true, |
| 134 |
keep_markup_in_code_blocks: true, |
| 135 |
extra_extension: meson.current_source_dir() / 'extensions' / 'refman_links.py', |
| 136 |
refman_data_file: refman_md[1], |
| 137 |
fatal_warnings: true, |
| 138 |
) |
| 139 |
|
| 140 |
run_target('upload', |
| 141 |
command: [hotdoc_prog, 'run', |
| 142 |
'--conf-file', documentation.config_path(), |
| 143 |
'--git-upload', |
| 144 |
'-vv', |
| 145 |
], |
| 146 |
depends: documentation, |
| 147 |
) |
| 148 |
|
| 149 |
test('validate_links', find_program('./validatelinks.py'), args: meson.current_source_dir() / 'markdown' / 'Users.md') |