#521: Added :confval:linkcheck_ignore config value.

This commit is contained in:
Georg Brandl 2010-10-22 11:40:38 +02:00
parent 092a7173a1
commit b72621c447
4 changed files with 24 additions and 0 deletions

View File

@ -21,6 +21,8 @@ Release 1.1 (in development)
* Added ``inline`` option to graphviz directives, and fixed the * Added ``inline`` option to graphviz directives, and fixed the
default (block-style) in LaTeX output. default (block-style) in LaTeX output.
* #521: Added :confval:`linkcheck_ignore` config value.
Release 1.0.4 (Sep 17, 2010) Release 1.0.4 (Sep 17, 2010)
============================ ============================

View File

@ -1113,6 +1113,19 @@ These options influence Texinfo output.
.. versionadded:: 1.1 .. 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 .. rubric:: Footnotes
.. [1] A note on available globbing syntax: you can use the standard shell .. [1] A note on available globbing syntax: you can use the standard shell

View File

@ -9,6 +9,7 @@
:license: BSD, see LICENSE for details. :license: BSD, see LICENSE for details.
""" """
import re
import socket import socket
from os import path from os import path
from urllib2 import build_opener, HTTPError from urllib2 import build_opener, HTTPError
@ -30,6 +31,7 @@ class CheckExternalLinksBuilder(Builder):
name = 'linkcheck' name = 'linkcheck'
def init(self): def init(self):
self.to_ignore = map(re.compile, self.app.config.linkcheck_ignore)
self.good = set() self.good = set()
self.broken = {} self.broken = {}
self.redirected = {} self.redirected = {}
@ -76,6 +78,10 @@ class CheckExternalLinksBuilder(Builder):
if lineno: if lineno:
self.info('(line %3d) ' % lineno, nonl=1) 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:': if uri[0:5] == 'http:' or uri[0:6] == 'https:':
self.info(uri, nonl=1) self.info(uri, nonl=1)

View File

@ -165,6 +165,9 @@ class Config(object):
texinfo_appendices = ([], None), texinfo_appendices = ([], None),
texinfo_elements = ({}, None), texinfo_elements = ({}, None),
texinfo_domain_indices = (True, None), texinfo_domain_indices = (True, None),
# linkcheck options
linkcheck_ignore = ([], None),
) )
def __init__(self, dirname, filename, overrides, tags): def __init__(self, dirname, filename, overrides, tags):