Commit Graph

264 Commits

Author SHA1 Message Date
Jonas Haag
df2f80c755 Add linkcheck_auth option 2019-11-25 09:53:45 +01:00
Takeshi KOMIYA
d0fa844f91 Fix #6806: linkcheck: Failure on parsing content 2019-11-17 11:12:33 +09:00
Takeshi KOMIYA
32763520a3 Close #1331: Change default User-Agent header 2019-10-27 02:05:33 +09:00
Sebastien Besson
a2bc070533 Be defensive and handle newly defined HTTP error code
This commit implements a change to the linkcheck builder to handle undefined
HTTP error code such as https://tools.ietf.org/html/rfc7538.
At the moment, Sphinx will fail with an internal error. With this change,
a non-registered HTTP error code will be treated in the same way as error
code 0 i.e. unknown code.
2019-10-08 01:49:11 +09:00
Takeshi KOMIYA
9a085794a2 Migrate to py3 style type annotation: sphinx.builders.linkcheck 2019-06-10 23:17:51 +09:00
Takeshi KOMIYA
e731d746fd Fix #5502: linkcheck: Consider HTTP 503 response as not an error 2019-06-03 22:30:11 +09:00
Takeshi KOMIYA
690a566791 Fix #6378: linkcheck: Send commonly used User-Agent 2019-05-19 01:39:05 +09:00
Takeshi KOMIYA
dbefc9865d Clean up import for annotations 2019-03-06 23:44:44 +09:00
Takeshi KOMIYA
f551915e9f Close #5196: linkcheck also checks remote images exist 2019-02-06 00:21:52 +09:00
Takeshi KOMIYA
805861066f Add a helper function; get_node_line() 2019-02-06 00:04:51 +09:00
Takeshi KOMIYA
332f98d44c Give "nonl=True" value to logging.info() instead of int 2019-01-19 21:20:14 +09:00
Takeshi KOMIYA
76e9f57c2e Merge branch '1.8' 2019-01-02 16:16:25 +09:00
Takeshi KOMIYA
1b1ebd2c75 A happy new year! 2019-01-02 16:00:30 +09:00
Jon Dufresne
bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00
Jon Dufresne
ade973f4e3 Use Python 3 super() argument-less syntax
The form is less verbose and more idiomatic for Python 3 only code.

https://docs.python.org/3/library/functions.html#super
2018-12-15 08:35:55 -08:00
Takeshi KOMIYA
6bc357140d Replace all "unicode" type by "str" 2018-12-15 23:57:43 +09:00
Takeshi KOMIYA
53917f228f Move to py3 mode for mypy (and remove many "type: ignore" comments) 2018-12-15 02:42:42 +09:00
Takeshi KOMIYA
a4749ca468 Fix annotations for builders 2018-12-02 22:28:28 +09:00
Takeshi KOMIYA
8201687c5b Fix annotations for builders 2018-11-29 23:26:27 +09:00
Takeshi KOMIYA
3c99d00605 Add sphinx.util.typing:unicode to help mypy-3 migration 2018-11-24 23:19:51 +09:00
Takeshi KOMIYA
8f9a76f476 Remove use six.move module 2018-11-12 01:02:14 +09:00
Jon Dufresne
02fea029bf Prefer builtin open() over io.open() and codecs.open()
In Python3, the functions io.open() is an alias of the builtin open()
and codecs.open() is functionally equivalent. To reduce indirection,
number of imports, and number of patterns, always prefer the builtin.

https://docs.python.org/3/library/io.html#high-level-module-interface

> io.open()
>
> This is an alias for the builtin open() function.
2018-09-11 05:45:36 -07:00
Takeshi KOMIYA
dffc841d2c Merge branch 'master' into 5140_Accept_header_for_linkcheck 2018-07-29 18:52:43 +09:00
Takeshi KOMIYA
1302d785fb linkcheck: Drop application/xml from Accept header 2018-07-29 18:50:22 +09:00
Takeshi KOMIYA
3e57ea0a52 Merge branch '1.7' 2018-07-17 00:37:40 +09:00
Takeshi KOMIYA
2bdbe3aaf4 Fix flake8 violations 2018-07-16 21:03:32 +09:00
Honza Javorek
271e1d1340
make linter happy 2018-07-03 14:13:46 +02:00
Honza Javorek
6fe8835037
add default Accept header
There are situations where requested server replies with a different content (in my particular case HTTP 404) when there is no accept header, possibly because it evaluates the content negotiation to an API request instead of a browser request. This change adds a default Accept header, which equals to what my Firefox sets out of the box to its requests.

I stumbled upon this when checking a link to https://crates.io/crates/dredd-hooks. While

curl -i https://crates.io/crates/dredd-hooks

returns HTTP 404, following results in an expected HTTP 200 response with HTML body:

curl -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -i https://crates.io/crates/dredd-hooks
2018-07-03 14:00:33 +02:00
Takeshi KOMIYA
9efaf18852 Merge branch '1.7' 2018-03-18 01:21:01 +09:00
Takeshi KOMIYA
70a622b86c Revert "Use typing.TYPE_CHECKING for typehints"
This reverts commit a073e17537.
2018-03-13 23:23:15 +09:00
Takeshi KOMIYA
6faef28150 Make console and warning messages translatable 2018-03-03 23:18:38 +09:00
Takeshi KOMIYA
f8bb40ab30 Merge branch '1.7' 2018-02-18 12:39:07 +09:00
Takeshi KOMIYA
a073e17537 Use typing.TYPE_CHECKING for typehints 2018-02-14 22:57:38 +09:00
Takeshi KOMIYA
dc2b153835 Update type annotations 2018-02-04 15:14:51 +09:00
Takeshi KOMIYA
9f5c676322 Use flake8-import-order 2018-01-28 01:52:16 +09:00
Stephen Finucane
a83e8bab7d builders: Add 'Builder.epilog' option
This allows builders to emit a final epilog message containing
information such as where resulting files can be found. This is only
emitted if the build was successful.

This allows us to remove this content from the 'make_mode' tool and
the legacy 'Makefile' and 'make.bat' templates. There's room for more
dramatic simplification of the former, but this will come later.

Signed-off-by: Stephen Finucane <stephen@that.guru>
2018-01-11 20:57:03 +00:00
Takeshi KOMIYA
2426cedb8b A happy new year! 2018-01-01 01:06:58 +09:00
Takeshi KOMIYA
579a79660e Update type annotations for new mypy 2017-05-07 14:28:41 +09:00
Takeshi KOMIYA
8f9dd64992 Merge branch 'stable' 2017-03-26 11:52:15 +09:00
Takeshi KOMIYA
c57e47e042 Year++ 2017-03-26 11:49:34 +09:00
Takeshi KOMIYA
aa6dfb8b41 Merge branch 'stable' 2017-03-18 18:25:50 +09:00
Takeshi KOMIYA
2dae11aa68 Fix #3552: linkcheck raises UnboundLocalError 2017-03-18 18:17:59 +09:00
Takeshi KOMIYA
554199d30e Upgrade to mypy-0.5 2017-03-03 23:17:34 +09:00
Takeshi KOMIYA
035ba39c2d Fix mypy violations 2017-01-22 00:46:49 +09:00
Takeshi KOMIYA
9ac221b140 Merge branch 'stable' 2017-01-20 12:17:38 +09:00
Takeshi KOMIYA
a0c2029b3c Fix #3295: Could not import extension sphinx.builders.linkcheck 2017-01-20 12:16:18 +09:00
Takeshi KOMIYA
38d6c34f35 Merge branch 'stable' 2017-01-12 13:03:53 +09:00
Takeshi KOMIYA
412bb9aae8 Fix flake8 violations 2017-01-12 10:09:44 +09:00
Takeshi KOMIYA
e755a8c004 Use loggers 2017-01-02 12:59:51 +09:00
Takeshi KOMIYA
b43523fcbe Use sphinx.util.logging instead app.info(), verbose(), debug() and debug2() 2017-01-02 12:59:50 +09:00
Takeshi KOMIYA
d5288567fd Update type annotations 2016-12-15 19:22:40 +09:00
Takeshi KOMIYA
e645ea59db Merge branch 'stable' 2016-12-14 00:12:23 +09:00
Takeshi KOMIYA
d72954d498 builtin extensions return metadata to allow parallel build 2016-12-12 21:22:16 +09:00
Takeshi KOMIYA
88887bad88 Update type annotation 2016-12-03 16:51:18 +09:00
Takeshi KOMIYA
e63afbc60e Merge branch '1.5-release' 2016-11-23 13:31:02 +09:00
Takeshi KOMIYA
8006d31b32 Fix #3095: Add tls_verify and tls_cacerts to support self-signed servers 2016-11-17 23:12:39 +09:00
Takeshi KOMIYA
23b1c3d5f2 Add type-check annotations to sphinx.builders 2016-11-16 12:06:22 +09:00
Darragh Bailey
22765990f0 Allow skipping anchor checking by regex
To avoid needing to turn off anchor checking across the entire
documentation allow skipping based on matching the anchor against a
regex.

Some sites/pages use JavaScript to perform anchor assignment in a
webpage, which would require rendering the page to determine whether
the anchor exists. Allow fine grain control of whether the anchor is
checked based on pattern matching, until such stage as the retrieved
URLs can be passed through an engine for deeper checking on the HTML
doctree.
2016-10-27 10:52:04 +01:00
Hiroaki Itoh
42604a1ff6 Fix #2990: linkcheck raises "Can't convert 'bytes' object to str implicitly" error if linkcheck_anchors enabled 2016-10-06 18:59:24 +09:00
Takeshi KOMIYA
4c7bec6460 Fix #3008: `linkcheck` builder ignores self-signed certificate URL 2016-10-06 12:46:23 +09:00
Takeshi KOMIYA
ce7fea9a35 Fix #2988: linkcheck: retry with GET request if denied HEAD request 2016-10-04 12:47:59 +09:00
Takeshi KOMIYA
07e30b279b Merge pull request #2884 from tk0miya/refactor_intersphinx
Refactor intersphinx: Use requests package
2016-08-27 16:43:54 +09:00
Takeshi KOMIYA
2b5c7057a7 Fix linkcheck builder does not send User-Agent header 2016-08-22 21:17:55 +09:00
Takeshi KOMIYA
fe1e5f7a7d linkcheck: Move requests package loader to sphinx.util.requests 2016-08-22 20:35:11 +09:00
Takeshi KOMIYA
54247c96fe Fix #2811: Show warning if requests < 2.4.1 2016-07-27 13:28:07 +09:00
Takeshi KOMIYA
8a45aa5e59 Now all builders and domains work as built-in extensions 2016-07-06 23:25:45 +09:00
Alex Gaynor
830e986b7a Include additional info on broken links in linkcheck 2016-05-29 10:30:33 -07:00
Darragh Bailey
2f46c7899c Some sites also return 403 on HEAD requests
Atlassian websites will return a 403 Forbidden access code when
queried, so add this to the list of codes that should trigger using a
GET request as a fallback.
2016-04-21 13:20:02 +01:00
Darragh Bailey
0b9ee8d451 Switch to using requests for better charset detection
Python requests does a better job of detecting the charsets of
webpages, performing automatic decoding when the text content is
requested, avoiding issues around needing to do detection.

This allows checking the following urls & anchors correctly:

    http://www.yaml.org/spec/1.2/spec.html#id2761803
    http://www.yaml.org/spec/1.2/spec.html#id2765878
    http://www.yaml.org/spec/1.2/spec.html#id2765878
2016-04-21 13:20:02 +01:00
Georg Brandl
fed5a34568 Merge pull request #2313 from alex/idiomatic
Make some code in linkcheck more idiomatic
2016-02-13 18:12:02 +01:00
Georg Brandl
222edf59e7 linkcheck: dont check anchors starting with "!".
Add changelog entry for #1099.
2016-02-13 16:06:55 +01:00
Alex Gaynor
3f2612ee78 Make some code in linkcheck more idiomatic 2016-02-13 09:54:51 -05:00
Alex Gaynor
e6980adaf6 oops, lost this 2016-02-13 09:02:44 -05:00
Alex Gaynor
863e2f468f moved more logic around 2016-02-13 08:55:55 -05:00
Alex Gaynor
ae5bfe500e syntax error 2016-02-13 08:55:00 -05:00
Alex Gaynor
4f00a9905c Fixed #1099 -- allow the linkcheck builder to retry on errors.
This is useful because if you run linkcheck often, you are likely to see lots of transient network errors, which usually disappear if you simply try again.
2016-02-13 08:52:38 -05:00
Georg Brandl
46d7e8558e Obligatory copyright update. 2016-01-14 22:54:04 +01:00
Takeshi KOMIYA
2bcf92dfb0 Fix #1815: linkcheck does not raise an exception if warniserror set to true and link is broken 2016-01-03 20:12:33 +09:00
Takeshi KOMIYA
8b57bc7227 Fix #2003: decode error under python2 (only) when `make linkcheck` is run 2015-12-21 22:34:04 +09:00
Takeshi KOMIYA
788c0ebffc Add testcase for encoding URIs in linkcheck builder 2015-12-19 22:49:14 +09:00
Barry Warsaw
5d30bc635b One way to work around the lack of html.parser.HTMLParserError in Python 3.5 2015-07-24 15:58:50 +02:00
Georg Brandl
ea97e6658c Linkcheck now works with non-ASCII URIs.
Fixes: #1739
2015-02-25 12:49:45 +01:00
Georg Brandl
2b6f7f4afe Closes #1687: for linkcheck purposes, HTTP 401 Unauthorized is working. 2015-01-19 19:50:31 +01:00
Georg Brandl
a23903d8d5 Merge branch 'stable' 2015-01-03 21:41:14 +01:00
Georg Brandl
567d52f199 all: update copyright 2015-01-03 21:36:32 +01:00
Takayuki Shimizukawa
74fbd611ab merge with stable 2014-06-09 22:45:05 +09:00
Takayuki Shimizukawa
82a53382d5 Fix: In python3 environment, make linkcheck cause "Can't convert 'bytes'
object to str implicitly" error when link target url has a hash part.
Thanks to Jorge_C. Closes #1457
2014-05-04 00:43:50 +09:00
Takayuki Shimizukawa
2d1549b35a wrap py3 iterators with list() for each places that expect a list object. refs #1350. 2014-04-30 23:25:44 +09:00
Takayuki Shimizukawa
f31d9113ff use six privided functions/classes to support py2/py3 in one source. refs #1350 2014-04-30 20:39:26 +09:00
Takayuki Shimizukawa
c3c879f2c6 use six privided functions/classes to support py2/py3 in one source. refs #1350. 2014-04-29 19:59:58 +09:00
Georg Brandl
ac92719ac3 Update copyright year. 2014-03-01 08:18:23 +01:00
Georg Brandl
e030031321 Update copyright year. 2014-03-01 08:18:16 +01:00
Dmitry Shachnev
ce2185ce27 Modernize the code now that Python 2.5 is no longer supported
- Use print function instead of print statement;
- Use new exception handling;
- Use in operator instead of has_key();
- Do not use tuple arguments in functions;
- Other miscellaneous improvements.

This is based on output of `futurize --stage1`, with some
manual corrections.
2014-01-19 14:17:10 +04:00
Takayuki Shimizukawa
cc7509966c merge heads 2014-01-15 05:25:56 +00:00
Georg Brandl
5406bff1cd Closes #1292: In the linkchecker, retry HEAD requests when denied by HTTP 405.
Also make the redirect code apparent and tweak the output a bit to be
more obvious.
2014-01-12 23:52:16 +01:00
Takayuki Shimizukawa
a8fc938d1b Drop python-2.5 and remove 2.4,2.5 support codes 2013-12-15 14:16:53 +09:00
Georg Brandl
151856819c Copyright update. 2013-01-01 22:13:15 +01:00
Jonathan Waltman
55b28b0198 Fix whitespace / line length issues reported by "make test" 2012-11-03 11:04:32 -05:00
Georg Brandl
166c7e8d27 Style fixes. 2012-03-10 18:13:55 +01:00
Marti Raudsepp
e0e9d2a7fa Add #anchor checking to 'linkcheck' builder.
This requires us to download the document and parse its HTML.
2012-02-28 20:12:59 +02:00
Georg Brandl
17efae5622 merge with 1.0 2011-01-04 11:29:09 +01:00
Georg Brandl
51852c0e87 #472: linkcheck builder: Check links in parallel, use HTTP HEAD requests and allow configuring the timeout.
New config values: :confval:`linkcheck_timeout` and :confval:`linkcheck_workers`.
2011-01-04 11:27:42 +01:00
Georg Brandl
0e1db6ad90 New year update. 2011-01-04 10:00:51 +01:00
Georg Brandl
b72621c447 #521: Added :confval:linkcheck_ignore config value. 2010-10-22 11:40:38 +02:00
Georg Brandl
9f4c61b154 #391: do not report local links as "malformed" in the linkcheck builder. 2010-07-11 11:00:07 +02:00
Georg Brandl
c8c703805c merge with 0.6 2010-05-22 12:59:18 +02:00
Georg Brandl
f5d52fa4f4 #377: Fix crash in linkcheck builder if all parent nodes have no line number set. 2010-04-18 09:55:38 +02:00
Georg Brandl
436693cea6 linkcheck builder now shows the line number in console output. 2010-01-03 10:25:21 +01:00
Georg Brandl
f6a56192d1 Happy new year! 2010-01-01 14:09:13 +01:00
Georg Brandl
b244dbf9b5 Use standard `file:line: warning: message` format for warning messages. 2009-03-05 09:21:35 +01:00
Georg Brandl
b068e91803 Reformat to EOL80. 2009-01-10 21:23:39 +01:00
Georg Brandl
f16f94f2cd Merge in copyright style changes from 0.5. 2009-01-03 12:15:19 +01:00
Georg Brandl
26d7aafaae Explicitly refer to the license in :license: tags. 2008-12-27 12:19:17 +01:00
Georg Brandl
9175e665b1 Move builders and writers into new packages. 2008-11-29 19:56:58 +01:00