if not get_option('build-docs')
subdir_done()
endif
sphinx_check = py_module.find_installation(required: false, modules: ['sphinx'])
if not sphinx_check.found()
warning(
'Python package "sphinx" is not installed. Documentation build not enabled.',
)
subdir_done()
endif
doc_src = []
subdir('en/reference/repl')
# TODO: Migrate this completely to meson
doc_src += custom_target(
'doc-src',
output: ['autogen'],
command: [files('bootstrap')],
env: {'SAGE_ROOT': root},
)
references = run_command(
py,
[
src / 'build-docs.py',
'--all-documents',
'reference',
'--source',
meson.current_source_dir(),
],
check: true,
).stdout().strip()
reference_inventory = []
reference_html = []
reference_pdf = []
bibliography = []
foreach type : ['inventory', 'html', 'pdf']
foreach ref : references.splitlines()
if '/' in ref
short_ref = ref.split('/')[1]
else
short_ref = ref
endif
deps = []
deps += doc_src
if type == 'html' or type == 'pdf'
deps += reference_inventory
endif
if short_ref != 'references'
deps += bibliography
endif
if short_ref == 'reference_top'
deps += reference_inventory
if type == 'html'
deps += reference_html
elif type == 'pdf'
deps += reference_pdf
endif
endif
target = custom_target(
'doc-' + type + '-reference-' + short_ref,
output: [type + short_ref],
command: [
py,
src / 'build-docs.py',
'--no-pdf-links',
ref,
type,
'-o',
'@OUTDIR@',
'--source',
meson.current_source_dir(),
],
depends: deps,
)
if short_ref == 'references'
bibliography += target
endif
if type == 'inventory'
reference_inventory += target
elif type == 'html'
reference_html += target
elif type == 'pdf'
reference_pdf += target
endif
endforeach
endforeach
other_documents = run_command(
py,
[
src / 'build-docs.py',
'--all-documents',
'all',
'--source',
meson.current_source_dir(),
],
check: true,
).stdout().strip()
other_documents_html = []
other_documents_pdf = []
foreach type : ['html', 'pdf']
foreach doc : other_documents.splitlines()
short_doc = doc.replace('/', '-')
target = custom_target(
'doc-' + type + '-other-' + short_doc,
output: [type + short_doc],
command: [
py,
src / 'build-docs.py',
'--no-pdf-links',
doc,
type,
'-o',
'@OUTDIR@',
'--source',
meson.current_source_dir(),
],
depends: reference_inventory,
)
if type == 'html'
other_documents_html += target
elif type == 'pdf'
other_documents_pdf += target
endif
endforeach
endforeach
# Custom target for building the complete documentation
alias_target('doc-html', [reference_html, other_documents_html])
alias_target('doc-pdf', [reference_pdf, other_documents_pdf])