mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #7536: sphinx-autogen: crashes when template uses i18n feature
This commit is contained in:
parent
ebfa8dbf2a
commit
ab3795f176
1
CHANGES
1
CHANGES
@ -35,6 +35,7 @@ Features added
|
|||||||
* #248, #6040: autosummary: Add ``:recursive:`` option to autosummary directive
|
* #248, #6040: autosummary: Add ``:recursive:`` option to autosummary directive
|
||||||
to generate stub files recursively
|
to generate stub files recursively
|
||||||
* #7535: sphinx-autogen: crashes when custom template uses inheritance
|
* #7535: sphinx-autogen: crashes when custom template uses inheritance
|
||||||
|
* #7536: sphinx-autogen: crashes when template uses i18n feature
|
||||||
* #7481: html theme: Add right margin to footnote/citation labels
|
* #7481: html theme: Add right margin to footnote/citation labels
|
||||||
* #7482: html theme: CSS spacing for code blocks with captions and line numbers
|
* #7482: html theme: CSS spacing for code blocks with captions and line numbers
|
||||||
* #7443: html theme: Add new options :confval:`globaltoc_collapse` and
|
* #7443: html theme: Add new options :confval:`globaltoc_collapse` and
|
||||||
|
@ -25,6 +25,7 @@ import pydoc
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
from gettext import NullTranslations
|
||||||
from os import path
|
from os import path
|
||||||
from typing import Any, Callable, Dict, List, NamedTuple, Set, Tuple
|
from typing import Any, Callable, Dict, List, NamedTuple, Set, Tuple
|
||||||
|
|
||||||
@ -58,10 +59,10 @@ logger = logging.getLogger(__name__)
|
|||||||
class DummyApplication:
|
class DummyApplication:
|
||||||
"""Dummy Application class for sphinx-autogen command."""
|
"""Dummy Application class for sphinx-autogen command."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, translator: NullTranslations) -> None:
|
||||||
self.registry = SphinxComponentRegistry()
|
self.registry = SphinxComponentRegistry()
|
||||||
self.messagelog = [] # type: List[str]
|
self.messagelog = [] # type: List[str]
|
||||||
self.translator = None
|
self.translator = translator
|
||||||
self.verbosity = 0
|
self.verbosity = 0
|
||||||
self._warncount = 0
|
self._warncount = 0
|
||||||
self.warningiserror = False
|
self.warningiserror = False
|
||||||
@ -528,8 +529,9 @@ The format of the autosummary directive is documented in the
|
|||||||
def main(argv: List[str] = sys.argv[1:]) -> None:
|
def main(argv: List[str] = sys.argv[1:]) -> None:
|
||||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||||
|
translator, _ = sphinx.locale.init([], None)
|
||||||
|
|
||||||
app = DummyApplication()
|
app = DummyApplication(translator)
|
||||||
logging.setup(app, sys.stdout, sys.stderr) # type: ignore
|
logging.setup(app, sys.stdout, sys.stderr) # type: ignore
|
||||||
setup_documenters(app)
|
setup_documenters(app)
|
||||||
args = get_parser().parse_args(argv)
|
args = get_parser().parse_args(argv)
|
||||||
|
@ -19,9 +19,10 @@ from sphinx import addnodes
|
|||||||
from sphinx.ext.autosummary import (
|
from sphinx.ext.autosummary import (
|
||||||
autosummary_table, autosummary_toc, mangle_signature, import_by_name, extract_summary
|
autosummary_table, autosummary_toc, mangle_signature, import_by_name, extract_summary
|
||||||
)
|
)
|
||||||
from sphinx.ext.autosummary.generate import AutosummaryEntry, generate_autosummary_docs
|
from sphinx.ext.autosummary.generate import AutosummaryEntry, generate_autosummary_docs, main as autogen_main
|
||||||
from sphinx.testing.util import assert_node, etree_parse
|
from sphinx.testing.util import assert_node, etree_parse
|
||||||
from sphinx.util.docutils import new_document
|
from sphinx.util.docutils import new_document
|
||||||
|
from sphinx.util.osutil import cd
|
||||||
|
|
||||||
html_warnfile = StringIO()
|
html_warnfile = StringIO()
|
||||||
|
|
||||||
@ -388,3 +389,10 @@ def test_empty_autosummary_generate(app, status, warning):
|
|||||||
confoverrides={'autosummary_generate': ['unknown']})
|
confoverrides={'autosummary_generate': ['unknown']})
|
||||||
def test_invalid_autosummary_generate(app, status, warning):
|
def test_invalid_autosummary_generate(app, status, warning):
|
||||||
assert 'WARNING: autosummary_generate: file not found: unknown.rst' in warning.getvalue()
|
assert 'WARNING: autosummary_generate: file not found: unknown.rst' in warning.getvalue()
|
||||||
|
|
||||||
|
|
||||||
|
def test_autogen(rootdir, tempdir):
|
||||||
|
with cd(rootdir / 'test-templating'):
|
||||||
|
args = ['-o', tempdir, '-t', '.', 'autosummary_templating.txt']
|
||||||
|
autogen_main(args)
|
||||||
|
assert (tempdir / 'sphinx.application.TemplateBridge.rst').exists()
|
||||||
|
Loading…
Reference in New Issue
Block a user