From d9cf6d2063f1f01aa5cf676e0a2fb0b7b7d8122d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 24 Mar 2019 21:55:59 +0100 Subject: Add post-build phase to check for broken links in documentation --- wscript | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/wscript b/wscript index 719c026..cb97c54 100644 --- a/wscript +++ b/wscript @@ -44,10 +44,11 @@ def options(ctx): ctx.load('lv2') ctx.add_flags( ctx.configuration_options(), - {'no-coverage': 'Do not use gcov for code coverage', - 'online-docs': 'Build documentation for web hosting', - 'no-plugins': 'Do not build example plugins', - 'copy-headers': 'Copy headers instead of linking to bundle'}) + {'no-coverage': 'Do not use gcov for code coverage', + 'online-docs': 'Build documentation for web hosting', + 'no-check-links': 'Do not check documentation for broken links', + 'no-plugins': 'Do not build example plugins', + 'copy-headers': 'Copy headers instead of linking to bundle'}) def configure(conf): try: @@ -82,6 +83,11 @@ def configure(conf): except: Logs.warn('Asciidoc not found, book will not be built') + if not Options.options.no_check_links: + if not conf.find_program('linkchecker', + var='LINKCHECKER', mandatory=False): + Logs.warn('Documentation will not be checked for broken links') + # Check for gcov library (for test coverage) if (conf.env.BUILD_TESTS and not Options.options.no_coverage @@ -378,6 +384,14 @@ def build(bld): bld.install_files('${DOCDIR}/lv2/aux/', 'aux/style.css') bld.install_files('${DOCDIR}/lv2/ns/', 'ns/index.html') + def check_links(ctx): + import subprocess + if ctx.env.LINKCHECKER: + if subprocess.call([ctx.env.LINKCHECKER[0], '--no-status', out]): + ctx.fatal('Documentation contains broken links') + + bld.add_post_fun(check_links) + if bld.env.BUILD_TESTS: # Generate a compile test .c file that includes all headers def gen_build_test(task): -- cgit v1.2.1