From 5aa6a9b654cca5666a2e5715936f1694ce8d5ee4 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 10 Jun 2018 10:47:22 -0700 Subject: [PATCH] In docs, use intersphinx to link to Python documentation The intersphinx extension can generate automatic links to the documentation of objects in other projects. It was already used for urllib3. For complete details on intersphinx, see: http://www.sphinx-doc.org/en/master/ext/intersphinx.html --- docs/conf.py | 5 ++++- docs/user/advanced.rst | 24 ++++++++++-------------- docs/user/quickstart.rst | 12 +++++------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index c952fe79..fb10abdb 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -376,4 +376,7 @@ epub_exclude_files = ['search.html'] # If false, no index is generated. #epub_use_index = True -intersphinx_mapping = {'urllib3': ('https://urllib3.readthedocs.io/en/latest', None)} +intersphinx_mapping = { + 'python': ('https://docs.python.org/3/', None), + 'urllib3': ('https://urllib3.readthedocs.io/en/latest', None), +} diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 857c296b..2076fc00 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -351,13 +351,11 @@ file-like object for your body:: with open('massive-body', 'rb') as f: requests.post('http://some.url/streamed', data=f) -.. warning:: It is strongly recommended that you open files in `binary mode`_. - This is because Requests may attempt to provide the - ``Content-Length`` header for you, and if it does this value will - be set to the number of *bytes* in the file. Errors may occur if - you open the file in *text mode*. - -.. _binary mode: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files +.. warning:: It is strongly recommended that you open files in :ref:`binary + mode `. This is because Requests may attempt to provide + the ``Content-Length`` header for you, and if it does this value + will be set to the number of *bytes* in the file. Errors may occur + if you open the file in *text mode*. .. _chunk-encoding: @@ -408,13 +406,11 @@ To do that, just set files to a list of tuples of ``(form_field_name, file_info) ... } -.. warning:: It is strongly recommended that you open files in `binary mode`_. - This is because Requests may attempt to provide the - ``Content-Length`` header for you, and if it does this value will - be set to the number of *bytes* in the file. Errors may occur if - you open the file in *text mode*. - -.. _binary mode: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files +.. warning:: It is strongly recommended that you open files in :ref:`binary + mode `. This is because Requests may attempt to provide + the ``Content-Length`` header for you, and if it does this value + will be set to the number of *bytes* in the file. Errors may occur + if you open the file in *text mode*. .. _event-hooks: diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 035b94d2..699c0ffd 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -348,13 +348,11 @@ support this, but there is a separate package which does - For sending multiple files in one request refer to the :ref:`advanced ` section. -.. warning:: It is strongly recommended that you open files in `binary mode`_. - This is because Requests may attempt to provide the - ``Content-Length`` header for you, and if it does this value will - be set to the number of *bytes* in the file. Errors may occur if - you open the file in *text mode*. - -.. _binary mode: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files +.. warning:: It is strongly recommended that you open files in :ref:`binary + mode `. This is because Requests may attempt to provide + the ``Content-Length`` header for you, and if it does this value + will be set to the number of *bytes* in the file. Errors may occur + if you open the file in *text mode*. Response Status Codes