diff --git a/CHANGES b/CHANGES index c14c570f0..d271c1b82 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,8 @@ Release 1.1 (in development) * Added ``inline`` option to graphviz directives, and fixed the default (block-style) in LaTeX output. +* #521: Added :confval:`linkcheck_ignore` config value. + Release 1.0.4 (Sep 17, 2010) ============================ diff --git a/doc/config.rst b/doc/config.rst index 4c6735726..979aff5fa 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -1113,6 +1113,19 @@ These options influence Texinfo output. .. versionadded:: 1.1 +Options for the linkcheck builder +--------------------------------- + +.. confval:: linkcheck_ignore + + A list of regular expressions that match URIs that should not be checked + when doing a ``linkcheck`` build. Example:: + + linkcheck_ignore = [r'http://localhost:\d+/'] + + .. versionadded:: 1.1 + + .. rubric:: Footnotes .. [1] A note on available globbing syntax: you can use the standard shell diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 4a0bab633..dd87d70d8 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -9,6 +9,7 @@ :license: BSD, see LICENSE for details. """ +import re import socket from os import path from urllib2 import build_opener, HTTPError @@ -30,6 +31,7 @@ class CheckExternalLinksBuilder(Builder): name = 'linkcheck' def init(self): + self.to_ignore = map(re.compile, self.app.config.linkcheck_ignore) self.good = set() self.broken = {} self.redirected = {} @@ -76,6 +78,10 @@ class CheckExternalLinksBuilder(Builder): if lineno: self.info('(line %3d) ' % lineno, nonl=1) + for rex in self.to_ignore: + if rex.match(uri): + self.info(uri + ' - ' + darkgray('ignored')) + return if uri[0:5] == 'http:' or uri[0:6] == 'https:': self.info(uri, nonl=1) diff --git a/sphinx/config.py b/sphinx/config.py index a0ba989a9..6f957314a 100644 --- a/sphinx/config.py +++ b/sphinx/config.py @@ -165,6 +165,9 @@ class Config(object): texinfo_appendices = ([], None), texinfo_elements = ({}, None), texinfo_domain_indices = (True, None), + + # linkcheck options + linkcheck_ignore = ([], None), ) def __init__(self, dirname, filename, overrides, tags):