From f1d674402eda7405a9bca1ab9f189a50d1d058cb Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Mon, 20 May 2019 11:13:18 -0400 Subject: [PATCH] docs: fix link-checking Including a fun problem that the server for GitBook.io returns more than 100 HTTP headers, which Python doesn't like. --- docs/conf.py | 19 +++++++++++++++++++ docs/installation.rst | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5e69012d..4cae71e0 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -201,3 +201,22 @@ default_role = 'obj' html_logo = 'images/logo.png' + + +# When checking links, the webserver for GitBook.io can currently return more +# than 100 HTTP headers sometimes ("Link:" headers giving hints about +# fragmented JavaScript files to load), which Python's HTTP libraries reject +# by default. Here's a hack to make the problem go away. Credit: +# https://stackoverflow.com/a/38815673/3760486 . + +try: + import http.client # Python 3 + http.client._MAXHEADERS = 1000 +except ImportError: + pass + +try: + import httplib # Python 2 + httplib._MAXHEADERS = 1000 +except ImportError: + pass diff --git a/docs/installation.rst b/docs/installation.rst index 45819fcc..7a870c08 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -62,8 +62,8 @@ if using pip). For the record, these dependencies are as follows: * `Python `_ 2.7, or 3.5 or later * `NumPy `_ 1.9 or later * `Matplotlib `_ 1.5 or later -* `Astropy `_ 1.0 or later -* `Requests `_ +* `Astropy `_ 1.0 or later +* `Requests `_ * `Beautiful Soup 4 `_ * `Dateutil `_ * `lxml `_