Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sage
Path: blob/develop/src/doc/meson.build
7357 views
1
if not get_option('build-docs')
2
subdir_done()
3
endif
4
5
warning(
6
'Documentation building enabled, generating targets may be slow. To disable this, pass -Dbuild-docs=false.',
7
)
8
9
sphinx_check = py_module.find_installation(required: false, modules: ['sphinx'])
10
if not sphinx_check.found()
11
warning(
12
'Python package "sphinx" is not installed. Documentation build not enabled.',
13
)
14
subdir_done()
15
endif
16
17
doc_src = []
18
subdir('el')
19
subdir('ca')
20
subdir('zh')
21
subdir('it')
22
subdir('common')
23
subdir('hu')
24
subdir('de')
25
subdir('en')
26
subdir('pt')
27
subdir('ru')
28
subdir('tr')
29
subdir('es')
30
subdir('fr')
31
subdir('ja')
32
33
# TODO: Migrate this completely to meson
34
doc_bootstrap = custom_target(
35
'bootstrap',
36
output: ['autogen'],
37
command: [files('bootstrap'), meson.current_build_dir()],
38
env: {'SAGE_ROOT': root},
39
# doc_src is not really a dependency of the bootstrap, but we want to make sure
40
# that all the source files are present before running the actual doc build
41
# so let's collect all source-related targets here.
42
depends: doc_src,
43
)
44
45
references = run_command(
46
py,
47
[
48
src / 'build-docs.py',
49
'--no-prune-empty-dirs',
50
'--all-documents',
51
'reference',
52
'--source',
53
meson.current_source_dir(),
54
],
55
check: true,
56
).stdout().strip()
57
58
reference_inventory = []
59
reference_html = []
60
reference_pdf = []
61
bibliography = []
62
foreach type : ['inventory', 'html', 'pdf']
63
foreach ref : references.splitlines()
64
if '/' in ref
65
short_ref = ref.split('/')[1]
66
else
67
short_ref = ref
68
endif
69
deps = []
70
deps += doc_bootstrap
71
if short_ref == 'repl'
72
deps += doc_src_repl
73
endif
74
if type == 'html' or type == 'pdf'
75
deps += reference_inventory
76
endif
77
if short_ref != 'references'
78
deps += bibliography
79
endif
80
if short_ref == 'reference_top'
81
deps += reference_inventory
82
if type == 'html'
83
deps += reference_html
84
elif type == 'pdf'
85
deps += reference_pdf
86
endif
87
endif
88
target = custom_target(
89
'doc-' + type + '-reference-' + short_ref,
90
output: [type + short_ref],
91
command: [
92
py,
93
src / 'build-docs.py',
94
'--no-prune-empty-dirs',
95
'--no-pdf-links',
96
ref,
97
type,
98
'-o',
99
'@OUTDIR@',
100
'--source',
101
meson.current_build_dir(),
102
],
103
depends: deps,
104
)
105
if short_ref == 'references'
106
bibliography += target
107
endif
108
if type == 'inventory'
109
reference_inventory += target
110
elif type == 'html'
111
reference_html += target
112
elif type == 'pdf'
113
reference_pdf += target
114
endif
115
endforeach
116
endforeach
117
118
other_documents = run_command(
119
py,
120
[
121
src / 'build-docs.py',
122
'--no-prune-empty-dirs',
123
'--all-documents',
124
'all',
125
'--source',
126
meson.current_source_dir(),
127
],
128
check: true,
129
).stdout().strip()
130
other_documents_html = []
131
other_documents_pdf = []
132
foreach type : ['html', 'pdf']
133
foreach doc : other_documents.splitlines()
134
short_doc = doc.replace('/', '-')
135
target = custom_target(
136
'doc-' + type + '-other-' + short_doc,
137
output: [type + short_doc],
138
command: [
139
py,
140
src / 'build-docs.py',
141
'--no-prune-empty-dirs',
142
'--no-pdf-links',
143
doc,
144
type,
145
'-o',
146
'@OUTDIR@',
147
'--source',
148
meson.current_build_dir(),
149
],
150
depends: reference_inventory,
151
)
152
if type == 'html'
153
other_documents_html += target
154
elif type == 'pdf'
155
other_documents_pdf += target
156
endif
157
endforeach
158
endforeach
159
160
# Custom target for building the complete documentation
161
alias_target('doc-html', [reference_html, other_documents_html])
162
alias_target('doc-pdf', [reference_pdf, other_documents_pdf])
163
164