diff options
| author | Jean-François B <jfbu@free.fr> | 2020-10-23 15:16:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-23 15:16:11 +0200 |
| commit | 569c7b02de5fb80db033ee462ca2c2bb2b8ce2b9 (patch) | |
| tree | d1ddf1e04ab399ef3ce0fe660ffd070e47d652f6 /sphinx/builders/linkcheck.py | |
| parent | add70354f1a49a5a6d4f8c1d0dd1fdf21fcd24cc (diff) | |
| parent | 0476e1cea93b587e3c0ab295aa20b2b9f0f81a34 (diff) | |
| download | sphinx-git-569c7b02de5fb80db033ee462ca2c2bb2b8ce2b9.tar.gz | |
Merge branch '3.x' into fix-oneside-latex
Diffstat (limited to 'sphinx/builders/linkcheck.py')
| -rw-r--r-- | sphinx/builders/linkcheck.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 9b54afc7c..a9e6b05b0 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -166,6 +166,7 @@ class CheckExternalLinksBuilder(Builder): # Read the whole document and see if #anchor exists response = requests.get(req_url, stream=True, config=self.app.config, auth=auth_info, **kwargs) + response.raise_for_status() found = check_anchor(response, unquote(anchor)) if not found: @@ -210,7 +211,7 @@ class CheckExternalLinksBuilder(Builder): else: return 'redirected', new_url, 0 - def check() -> Tuple[str, str, int]: + def check(docname: str) -> Tuple[str, str, int]: # check for various conditions without bothering the network if len(uri) == 0 or uri.startswith(('#', 'mailto:')): return 'unchecked', '', 0 @@ -219,7 +220,8 @@ class CheckExternalLinksBuilder(Builder): # non supported URI schemes (ex. ftp) return 'unchecked', '', 0 else: - if path.exists(path.join(self.srcdir, uri)): + srcdir = path.dirname(self.env.doc2path(docname)) + if path.exists(path.join(srcdir, uri)): return 'working', '', 0 else: for rex in self.to_ignore: @@ -256,7 +258,7 @@ class CheckExternalLinksBuilder(Builder): uri, docname, lineno = self.wqueue.get() if uri is None: break - status, info, code = check() + status, info, code = check(docname) self.rqueue.put((uri, docname, lineno, status, info, code)) def process_result(self, result: Tuple[str, str, int, str, str, int]) -> None: |
