Commit Graph

24 Commits

Author SHA1 Message Date
Adam Turner
49d8304670
Start using `pathlib.Path and deprecate sphinx.testing.path` (#11526) 2023-07-28 00:39:12 +01:00
Adam Turner
aee3c0ab75
Partially revert "Disable localisation when SOURCE_DATE_EPOCH is set (#10949)" (#11343)
This keeps some of the added tests, and avoids a full revert of ``sphinx.locale``.
2023-04-21 19:04:26 +01:00
James Addison
f82c3c9912
Disable localisation when `SOURCE_DATE_EPOCH` is set (#10949)
This commit disables Sphinx's localisation features when reproducible
builds are requested, as determined by a non-empty SOURCE_DATE_EPOCH_
environment variable.

The `Reproducible Builds`_ project aims to provide confidence to
consumers of packaged software that the artefacts they're downloading
and installing have not been altered by the environment they were
built in, and can be replicated at a later date if required.

Builds of localised documentation using Sphinx currently account for
a large category of reproducible build testing failures, because the
builders intentionally use varying environment locales at build-time.
This can affect the contents of the ``objects.inv`` file.

During investigation, it turned out that many ``gettext``-localised
values (particularly in Python modules under ``sphinx.domains``) were
being translated at module-load-time and would not subsequently be
re-localised.

This creates two unusual effects:

1. Attempting to write a test case to build the same application in
   two different languages was not initially possible, as the
   first-loaded translation catalogue (as found in the 
   ``sphinx.locale.translators`` global variable) would remain in-use
   for subsequent application builds under different locales.

2. Localisation of strings could vary depending on whether the
   relevant modules were loaded before or after the resource
   catalogues were populated.

We fix this by performing all translations lazily so that module
imports can occur in any order and localisation of inventory entries
should occur only when translations of those items are requested.

Localisation can then be disabled by configuring the ``gettext``
language to the ISO-639-3 'undetermined' code (``'und'``), as this
should not have an associated translation catalogue. We also want to
prevent ``gettext`` from  attempting to determine the host's locale
from environment variables (including ``LANGUAGE``).

.. _SOURCE_DATE_EPOCH: https://reproducible-builds.org/docs/source-date-epoch/
.. _Reproducible Builds: https://www.reproducible-builds.org/
2023-04-07 17:49:36 +01:00
Adam Turner
3d2114214b Improve static typing in `intersphinx` et al 2023-03-17 17:43:23 +00:00
Adam Turner
5775912455 Collapse single line docstrings 2022-02-20 03:13:45 +00:00
Adam Turner
6bb7b891a1 Remove copyright and licence fields 2022-02-20 03:06:23 +00:00
Adam Turner
5694e0ce60 Fix module docstring indentation 2022-02-20 00:35:13 +00:00
Adam Turner
4f5a3269a6 Fix module docstring first line 2022-02-20 00:11:08 +00:00
Adam Turner
6b8bccec59 Remove module titles in docstrings 2022-02-19 23:17:29 +00:00
Takeshi KOMIYA
b84771dcd2 A happy new year! 2022-01-01 18:45:03 +09:00
Takeshi KOMIYA
f996859420 A happy new year!
.. note::

   $ find sphinx tests LICENSE doc/conf.py -type f -exec sed -i '' -e 's/2007\-20../2007-2021/' {} \;
   $ git co sphinx/locale/**/*.js sphinx/templates/epub3/mimetype
2021-01-01 13:40:48 +09:00
Takeshi KOMIYA
c941406415 refactor with pyupgrade
Run `pyupgrade --py3-only --keep-percent-format` to refine our code.

Note:  --keep-percent-format is required to keep translations available.
2020-11-25 01:55:30 +09:00
Takeshi KOMIYA
2db006a0af Fix #7183: intersphinx: `:attr:` reference to property is broken 2020-02-22 01:28:13 +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
5bf25eb445 Avoid respecifying default encoding for .encode()/.decode() calls
In Python 3, both .encode() and .decode() default the encoding to
'utf-8'. See the docs:

https://docs.python.org/3/library/stdtypes.html#str.encode
https://docs.python.org/3/library/stdtypes.html#bytes.decode

Simplify and shorten the code by using the default instead of
respecifying it.
2018-12-15 17:19:56 -08:00
Jon Dufresne
4f4e225775 Replace all six.BytesIO with io.BytesIO 2018-09-23 18:38:06 -07:00
Takeshi KOMIYA
f7027049b1 Fix flake8 violations 2018-02-19 23:20:56 +09:00
Takeshi KOMIYA
aa47e9decc Fix #4209: intersphinx: In link title, "v" should be optional if target has no version 2018-01-30 00:14:53 +09:00
Andy Neebel
3a0c050af0 Some cleanup to avoid using the std:: namespace 2017-09-28 13:43:46 -05:00
Andy Neebel
5ebfd51672 Improve cpp intersphinx support
Now types called out in function declarations will be searched for in
the intersphinx inventory as well
2017-06-26 14:21:52 -05:00
Takeshi KOMIYA
44b6044d4b Implement get_full_qualified_name() to CPPDomain (refs: #3630) 2017-04-23 16:31:33 +09:00
Takeshi KOMIYA
96fa6d2972 Implement get_full_qualified_name() to JavascriptDomain (refs: #3630) 2017-04-23 16:31:33 +09:00
Takeshi KOMIYA
db377ceb55 Implement get_full_qualified_name() to StandardDomain (refs: #3630) 2017-04-23 16:31:33 +09:00
Takeshi KOMIYA
29254c15f1 Move InventoryFile class to sphinx.util.inventory 2017-03-02 22:51:42 +09:00