Skip to content

Commit

Permalink
Merge branch 'master' into feature/11483-force-include-mathjax
Browse files Browse the repository at this point in the history
  • Loading branch information
picnixz authored Sep 21, 2023
2 parents d65720a + abf42e9 commit 6888b1b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Bugs fixed
* #11617: ANSI control sequences are stripped from the output when writing to
a warnings file with :option:`-w <sphinx-build -w>`.
Patch by Bénédikt Tran.
* #11666: Skip all hidden directories in ``CatalogRepository.pofiles``.
Patch by Aryaz Eghbali.
* #9686: html builder: Fix MathJax lazy loading when equations appear in titles.
Patch by Bénédikt Tran.
* #11483: singlehtml builder: Fix MathJax lazy loading when the index does not
Expand Down
11 changes: 9 additions & 2 deletions sphinx/util/http_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@

import time
import warnings
from email.utils import formatdate, parsedate_tz
from email.utils import parsedate_tz

from sphinx.deprecation import RemovedInSphinx90Warning

_WEEKDAY_NAME = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
_MONTH_NAME = ('', # Placeholder for indexing purposes
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
_GMT_OFFSET = float(time.localtime().tm_gmtoff)


def epoch_to_rfc1123(epoch: float) -> str:
"""Return HTTP-date string from epoch offset."""
return formatdate(epoch, usegmt=True)
yr, mn, dd, hh, mm, ss, wd, _yd, _tz = time.gmtime(epoch)
weekday_name = _WEEKDAY_NAME[wd]
month = _MONTH_NAME[mn]
return f'{weekday_name}, {dd:02} {month} {yr:04} {hh:02}:{mm:02}:{ss:02} GMT'


def rfc1123_to_epoch(rfc1123: str) -> float:
Expand Down
5 changes: 2 additions & 3 deletions sphinx/util/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ def pofiles(self) -> Generator[tuple[str, str], None, None]:
basedir = path.join(locale_dir, self.language, 'LC_MESSAGES')
for root, dirnames, filenames in os.walk(basedir):
# skip dot-directories
for dirname in dirnames:
if dirname.startswith('.'):
dirnames.remove(dirname)
for dirname in [d for d in dirnames if d.startswith('.')]:
dirnames.remove(dirname)

for filename in filenames:
if filename.endswith('.po'):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_util_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def test_CatalogRepository(tmp_path):
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES').mkdir(parents=True, exist_ok=True)
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test1.po').write_text('#', encoding='utf8')
(tmp_path / 'loc2' / 'xx' / 'LC_MESSAGES' / 'test7.po').write_text('#', encoding='utf8')
(tmp_path / 'loc1' / 'xx' / 'LC_MESSAGES' / '.dotdir2').mkdir(parents=True, exist_ok=True)
(tmp_path / 'loc1' / 'xx' / 'LC_MESSAGES' / '.dotdir2' / 'test8.po').write_text('#', encoding='utf8')

# for language xx
repo = i18n.CatalogRepository(tmp_path, ['loc1', 'loc2'], 'xx', 'utf-8')
Expand Down

0 comments on commit 6888b1b

Please sign in to comment.