diff --git a/CHANGES b/CHANGES index dcd20947b..7f8197c90 100644 --- a/CHANGES +++ b/CHANGES @@ -176,6 +176,8 @@ Features added Bugs fixed ---------- +* #5605: with the documentation language set to Chinese, English words could not + be searched. Testing -------- @@ -241,10 +243,10 @@ Bugs fixed * #5419: incompatible math_block node has been generated * #5548: Fix ensuredir() in case of pre-existing file * #5549: graphviz Correctly deal with non-existing static dir -* #3002: i18n: multiple footnote_references referring same footnote causes +* #3002: i18n: multiple footnote_references referring same footnote cause duplicated node_ids -* #5563: latex: footnote_references generated by extension causes LaTeX builder - crashed +* #5563: latex: footnote_references generated by extension causes a LaTeX + builder crash * #5561: make all-pdf fails with old xindy version * #5557: quickstart: --no-batchfile isn't honored * #3080: texinfo: multiline rubrics are broken @@ -324,8 +326,8 @@ Incompatible changes :py:meth:`.Sphinx.add_transform()` * #4827: All ``substitution_definition`` nodes are removed from doctree on reading phase -* ``docutils.conf`` on ``$HOME`` and ``/etc`` directories are ignored. Only - ``docutils.conf`` on confdir is refered. +* ``docutils.conf`` in ``$HOME`` or ``/etc`` directories are ignored. Only + ``docutils.conf`` from confdir is obeyed. * #789: ``:samp:`` role supports to escape curly braces with backslash * #4811: The files under :confval:`html_static_path` are excluded from source files. @@ -346,8 +348,7 @@ Incompatible changes before new build. * #5163: html: hlist items are now aligned to top * ``highlightlang`` directive is processed on resolving phase -* #4000: latex: LaTeX template has been chaned. Following elements are moved - into the template: +* #4000: LaTeX: template changed. Following elements moved to it: - ``\begin{document}`` - ``shorthandoff`` variable @@ -538,9 +539,9 @@ Bugs fixed * C++, fixes for symbol addition and lookup. Lookup should no longer break in partial builds. See also #5337. * #5348: download reference to remote file is not displayed -* #5282: html theme: ``pygments_style`` of theme was overrided by ``conf.py`` +* #5282: html theme: ``pygments_style`` of theme was overridden by ``conf.py`` by default -* #4379: toctree shows confusible warning when document is excluded +* #4379: toctree shows confusing warning when document is excluded * #2401: autodoc: ``:members:`` causes ``:special-members:`` not to be shown * autodoc: ImportError is replaced by AttributeError for deeper module * #2720, #4034: Incorrect links with ``:download:``, duplicate names, and @@ -562,7 +563,7 @@ Bugs fixed * #344: autosummary does not understand docstring of module level attributes * #5191: C++, prevent nested declarations in functions to avoid lookup problems. * #5126: C++, add missing isPack method for certain template parameter types. -* #5187: C++, parse attributes on declerators as well. +* #5187: C++, parse attributes on declarators as well. * C++, parse delete expressions and basic new expressions as well. * #5002: graphviz: SVGs do not adapt to the column width @@ -687,7 +688,7 @@ Bugs fixed * #4924: html search: Upper characters problem in any other languages * #4932: apidoc: some subpackage is ignored if sibling subpackage contains a module starting with underscore -* #4863, #4938, #4939: i18n doesn't handle node.title correctly tat used for +* #4863, #4938, #4939: i18n doesn't handle correctly node.title as used for contents, topic, admonition, table and section. * #4913: i18n: literal blocks in bullet list are not translated * #4962: C++, raised TypeError on duplicate declaration. @@ -721,7 +722,7 @@ Bugs fixed ---------- * #4885, #4887: domains: Crashed with duplicated objects -* #4889: latex: sphinx.writers.latex causes recusrive import +* #4889: latex: sphinx.writers.latex causes recursive import Release 1.7.3 (released Apr 23, 2018) ===================================== @@ -852,7 +853,7 @@ Incompatible changes mock them, please specify the name of ancestors explicitly. * #3620: html theme: move DOCUMENTATION_OPTIONS to independent JavaScript file (refs: #4295) -* #4246: Limit width of text body for all themes. Conifigurable via theme +* #4246: Limit width of text body for all themes. Configurable via theme options ``body_min_width`` and ``body_max_width``. * #4771: apidoc: The ``exclude_patterns`` arguments are ignored if they are placed just after command line options @@ -1008,7 +1009,7 @@ Bugs fixed 1.7.0b3 -* #4019: inheritance_diagram AttributeError stoping make process +* #4019: inheritance_diagram AttributeError stopping make process * #4531: autosummary: methods are not treated as attributes * #4538: autodoc: ``sphinx.ext.autodoc.Options`` has been moved * #4539: autodoc emits warnings for partialmethods @@ -1041,7 +1042,7 @@ Bugs fixed * #4434: pure numbers as link targets produce warning * #4477: Build fails after building specific files * #4449: apidoc: include "empty" packages that contain modules -* #3917: citation labels are tranformed to ellipsis +* #3917: citation labels are transformed to ellipsis * #4501: graphviz: epub3 validation error caused if graph is not clickable * #4514: graphviz: workaround for wrong map ID which graphviz generates * #4525: autosectionlabel does not support parallel build @@ -1508,7 +1509,7 @@ Bugs fixed * #3614: Sphinx crashes with requests-2.5.0 * #3618: autodoc crashes with tupled arguments * #3664: No space after the bullet in items of a latex list produced by Sphinx -* #3657: EPUB builder crashes if document startswith genindex exists +* #3657: EPUB builder crashes if a document starting with genindex exists * #3588: No compact (p tag) html output in the i18n document build even when :confval:`html_compact_lists` is True. * #3685: AttributeError when using 3rd party domains @@ -1526,7 +1527,7 @@ Bugs fixed ---------- * #3597: python domain raises UnboundLocalError if invalid name given -* #3599: Move to new Mathjax CDN +* #3599: Move to new MathJax CDN Release 1.5.4 (released Apr 02, 2017) ===================================== @@ -1689,7 +1690,7 @@ Incompatible changes 1.5a1 -* latex, package fancybox is not longer a dependency of sphinx.sty +* latex, package fancybox is not any longer a dependency of sphinx.sty * Use ``'locales'`` as a default value of `locale_dirs` * latex, package ifthen is not any longer a dependency of sphinx.sty * latex, style file does not modify fancyvrb's Verbatim (also available as @@ -1712,7 +1713,7 @@ Incompatible changes (ref: #2510, #2753) * Internet Explorer 6-8, Opera 12.1x or Safari 5.1+ support is dropped because jQuery version is updated from 1.11.0 to 3.1.0 (ref: #2634, #2773) -* QtHelpBuilder doens't generate search page (ref: #2352) +* QtHelpBuilder doesn't generate search page (ref: #2352) * QtHelpBuilder uses ``nonav`` theme instead of default one to improve readability. * latex: To provide good default settings to Japanese documents, Sphinx uses @@ -2007,12 +2008,12 @@ Bugs fixed * #2890: Quickstart should return an error consistently on all error conditions * #2870: flatten genindex columns' heights. -* #2856: Search on generated HTML site doesnt find some symbols +* #2856: Search on generated HTML site doesn't find some symbols * #2882: Fall back to a GET request on 403 status in linkcheck * #2902: jsdump.loads fails to load search index if keywords starts with underscore * #2900: Fix epub content.opf: add auto generated orphan files to spine. -* #2899: Fix ``hasdoc()`` function in Jinja2 template. It can detect ``genindex``, ``search`` collectly. +* #2899: Fix ``hasdoc()`` function in Jinja2 template. It will detect ``genindex``, ``search`` also. * #2901: Fix epub result: skip creating links from image tags to original image files. * #2917: inline code is hyphenated on HTML * #1462: autosummary warns for namedtuple with attribute with trailing underscore @@ -2022,7 +2023,7 @@ Bugs fixed paths are used in `intersphinx_mapping` * #2931: code-block directive with same :caption: causes warning of duplicate target. Now `code-block` and `literalinclude` does not define hyperlink - target using its caption automatially. + target using its caption automatically. * #2962: latex: missing label of longtable * #2968: autodoc: show-inheritance option breaks docstrings @@ -2048,7 +2049,7 @@ Bugs fixed * #2778: Fix autodoc crashes if obj.__dict__ is a property method and raises exception * Fix duplicated toc in epub3 output. -* #2775: Fix failing linkcheck with servers not supporting identidy encoding +* #2775: Fix failing linkcheck with servers not supporting identity encoding * #2833: Fix formatting instance annotations in ext.autodoc. * #1911: ``-D`` option of ``sphinx-build`` does not override the ``extensions`` variable * #2789: `sphinx.ext.intersphinx` generates wrong hyperlinks if the inventory is given @@ -2115,7 +2116,7 @@ Release 1.4.4 (released Jun 12, 2016) Bugs fixed ---------- -* #2630: Latex sphinx.sty Notice Enviroment formatting problem +* #2630: latex: sphinx.sty notice environment formatting problem * #2632: Warning directives fail in quote environment latex build * #2633: Sphinx crashes with old styled indices * Fix a ``\begin{\minipage}`` typo in sphinx.sty from 1.4.2 (ref: 68becb1) @@ -2189,7 +2190,7 @@ Bugs fixed * #1817, #2077: suppress pep8 warnings on conf.py generated by sphinx-quickstart * #2407: building docs crash if document includes large data image URIs * #2436: Sphinx does not check version by :confval:`needs_sphinx` if loading extensions failed -* #2397: Setup shorthandoff for turkish documents +* #2397: Setup shorthandoff for Turkish documents * #2447: VerbatimBorderColor wrongly used also for captions of PDF * #2456: C++, fix crash related to document merging (e.g., singlehtml and Latex builders). * #2446: latex(pdf) sets local tables of contents (or more generally topic @@ -2226,7 +2227,7 @@ Bugs fixed * #2576: ``sphinx.ext.imgmath`` crashes if subprocess raises error * #2577: ``sphinx.ext.imgmath``: Invalid argument are passed to dvisvgm * #2556: Xapian search does not work with Python 3 -* #2581: The search doesn't work if language="es" (spanish) +* #2581: The search doesn't work if language="es" (Spanish) * #2382: Adjust spacing after abbreviations on figure numbers in LaTeX writer * #2383: The generated footnote by `latex_show_urls` overflows lines * #2497, #2552: The label of search button does not fit for the button itself @@ -2363,7 +2364,7 @@ Features added * #1921: Support figure substitutions by :confval:`language` and :confval:`figure_language_filename` * #2245: Add ``latex_elements["passoptionstopackages"]`` option to call PassOptionsToPackages in early stage of preambles. -* #2340: Math extension: support alignment of multiple equations for MathJAX. +* #2340: Math extension: support alignment of multiple equations for MathJax. * #2338: Define ``\titleref`` macro to redefine the style of ``title-reference`` roles. * Define ``\menuselection`` and ``\accelerator`` macros to redefine the style of `menuselection` roles. * Define ``\crossref`` macro to redefine the style of references @@ -2402,7 +2403,7 @@ Bugs fixed * The default highlight language is now ``default``. This means that source code is highlighted as Python 3 (which is mostly a superset of Python 2) if possible. To get the old behavior back, add ``highlight_language = "python"`` to conf.py. -* #2329: Refresh environment forcely if source directory has changed. +* #2329: Refresh environment forcedly if source directory has changed. * #2331: Fix code-blocks are filled by block in dvi; remove ``xcdraw`` option from xcolor package * Fix the confval type checker emits warnings if unicode is given to confvals which expects string value @@ -2412,11 +2413,11 @@ Bugs fixed * #2348: Move amsmath and amssymb to before fontpkg on LaTeX writer. * #2368: Ignore emacs lock files like ``.#foo.rst`` by default. * #2262: literal_block and its caption has been separated by pagebreak in LaTeX output. -* #2319: Fix table counter is overrided by code-block's in LaTeX. Thanks to jfbu. -* Fix unpack warning if combinated with 3rd party domain extensions. +* #2319: Fix table counter is overridden by code-block's in LaTeX. Thanks to jfbu. +* Fix unpack warning if combined with 3rd party domain extensions. * #1153: Fix figures in sidebar causes latex build error. * #2358: Fix user-preamble could not override the tocdepth definition. -* #2358: Redece tocdepth if ``part`` or ``chapter`` is used for top_sectionlevel. +* #2358: Reduce tocdepth if ``part`` or ``chapter`` is used for top_sectionlevel. * #2351: Fix footnote spacing * #2363: Fix ``toctree()`` in templates generates broken links in SingleHTMLBuilder. * #2366: Fix empty hyperref is generated on toctree in HTML builder. @@ -2450,7 +2451,7 @@ Bugs fixed * #2290: Fix ``sphinx.ext.mathbase`` use of amsfonts may break user choice of math fonts * #2324: Print a hint how to increase the recursion limit when it is hit. * #1565, #2229: Revert new warning; the new warning will be triggered from version 1.4 on. -* #2329: Refresh environment forcely if source directory has changed. +* #2329: Refresh environment forcedly if source directory has changed. * #2019: Fix the domain objects in search result are not escaped Release 1.3.5 (released Jan 24, 2016) @@ -2499,7 +2500,7 @@ Bugs fixed * #2071: Fix same footnote in more than two section titles => LaTeX/PDF Bug * #2040: Fix UnicodeDecodeError in sphinx-apidoc when author contains non-ascii characters * #2193: Fix shutil.SameFileError if source directory and destination directory are same -* #2178: Fix unparseable C++ cross-reference when referencing a function with :cpp:any: +* #2178: Fix unparsable C++ cross-reference when referencing a function with :cpp:any: * #2206: Fix Sphinx latex doc build failed due to a footnotes * #2201: Fix wrong table caption for tables with over 30 rows * #2213: Set
in the classic theme to fit with@@ -2516,10 +2517,11 @@ Bugs fixed * #1580: Fix paragraphs in longtable don't work in Latex output * #1366: Fix centered image not centered in latex * #1860: Fix man page using ``:samp:`` with braces - font doesn't reset -* #1610: Sphinx crashes in japanese indexing in some systems +* #1610: Sphinx crashes in Japanese indexing in some systems * Fix Sphinx crashes if mecab initialization failed * #2160: Fix broken TOC of PDFs if section includes an image -* #2172: Fix dysfunctional admonition \py@lightbox in sphinx.sty. Thanks to jfbu. +* #2172: Fix dysfunctional admonition ``\py@lightbox`` in sphinx.sty. Thanks to + jfbu. * #2198,#2205: ``make gettext`` generate broken msgid for definition lists. * #2062: Escape characters in doctests are treated incorrectly with Python 2. * #2225: Fix if the option does not begin with dash, linking is not performed @@ -2676,7 +2678,7 @@ Bugs fixed * #1753: C++, added missing support for more complex declarations. * #1700: Add ``:caption:`` option for :rst:dir:`toctree`. * #1742: ``:name:`` option is provided for :rst:dir:`toctree`, :rst:dir:`code-block` and - :rst:dir:`literalinclude` dirctives. + :rst:dir:`literalinclude` directives. * #1756: Incorrect section titles in search that was introduced from 1.3b3. * #1746: C++, fixed name lookup procedure, and added missing lookups in declarations. * #1765: C++, fix old id generation to use fully qualified names. @@ -2684,7 +2686,7 @@ Bugs fixed Documentation ------------- -* #1651: Add ``vartype`` field descritpion for python domain. +* #1651: Add ``vartype`` field description for python domain. Release 1.3b3 (released Feb 24, 2015) @@ -2884,7 +2886,7 @@ Features added the order of documents before they are read by the environment. * #1284: Program options documented with :rst:dir:`option` can now start with ``+``. -* PR#291: The caption of :rst:dir:`code-block` is recognised as a title of ref +* PR#291: The caption of :rst:dir:`code-block` is recognized as a title of ref target. Thanks to Takeshi Komiya. * PR#298: Add new API: :meth:`~sphinx.application.Sphinx.add_latex_package`. Thanks to Takeshi Komiya. diff --git a/doc/extdev/logging.rst b/doc/extdev/logging.rst index 005a2f87a..b66f11dbb 100644 --- a/doc/extdev/logging.rst +++ b/doc/extdev/logging.rst @@ -57,7 +57,7 @@ Logging API **color** The color of logs. By default, info and verbose level logs are not colored, - and deug level ones are colored as ``"darkgray"``. + and debug level ones are colored as ``"darkgray"``. .. autofunction:: pending_logging() diff --git a/doc/man/sphinx-apidoc.rst b/doc/man/sphinx-apidoc.rst index 15096d523..384374aa9 100644 --- a/doc/man/sphinx-apidoc.rst +++ b/doc/man/sphinx-apidoc.rst @@ -40,7 +40,7 @@ Options .. option:: -f, --force - Force overwritting of any existing generated files. + Force overwriting of any existing generated files. .. option:: -l, --follow-links diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 5400697eb..756e06cb9 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -117,7 +117,7 @@ General configuration .. confval:: source_suffix The file extensions of source files. Sphinx considers the files with this - suffix as sources. This value can be a dictionary mapping file extensions + suffix as sources. The value can be a dictionary mapping file extensions to file types. For example:: source_suffix = { @@ -128,13 +128,14 @@ General configuration By default, Sphinx only supports ``'restructuredtext'`` file type. You can add a new file type using source parser extensions. Please read a document - of the extension to know what file type the extension supports. + of the extension to know which file type the extension supports. - This also allows a list of file extensions. In that case, Sphinx conciders - that all they are ``'restructuredtext'``. Default is - ``{'.rst': 'restructuredtext'}``. + The value may also be a list of file extensions: then Sphinx will consider + that they all map to the ``'restructuredtext'`` file type. - .. note:: file extensions have to start with dot (like ``.rst``). + Default is ``{'.rst': 'restructuredtext'}``. + + .. note:: file extensions have to start with a dot (e.g. ``.rst``). .. versionchanged:: 1.3 Can now be a list of extensions. @@ -788,10 +789,10 @@ These options influence Math notations. .. confval:: math_eqref_format - A string that are used for format of label of references to equations. - As a special character, ``{number}`` will be replaced to equaition number. + A string used for formatting the labels of references to equations. + The ``{number}`` place-holder stands for the equation number. - Example: ``'Eq.{number}'`` is rendered as ``Eq.10`` + Example: ``'Eq.{number}'`` gets rendered as, for example, ``Eq.10``. .. confval:: math_numfig @@ -2731,7 +2732,7 @@ Options for the C++ domain A list of strings that the parser additionally should accept as attributes with one argument. That is, if ``my_align_as`` is in the list, then ``my_align_as(X)`` is parsed as an attribute for all strings ``X`` that have - balanced brances (``()``, ``[]``, and ``{}``). This can for example be used + balanced braces (``()``, ``[]``, and ``{}``). This can for example be used when attributes have been ``#define`` d for portability. .. versionadded:: 1.5 diff --git a/doc/usage/extensions/autodoc.rst b/doc/usage/extensions/autodoc.rst index 80783301e..36d497543 100644 --- a/doc/usage/extensions/autodoc.rst +++ b/doc/usage/extensions/autodoc.rst @@ -427,7 +427,7 @@ There are also new config values that you can set: This value controls the behavior of :option:`sphinx-build -W` during importing modules. - If ``False`` is given, autodoc forcely suppresses the error if the imported + If ``False`` is given, autodoc forcedly suppresses the error if the imported module emits warnings. By default, ``True``. .. confval:: autodoc_inherit_docstrings diff --git a/doc/usage/extensions/doctest.rst b/doc/usage/extensions/doctest.rst index e321e3a54..79a75536e 100644 --- a/doc/usage/extensions/doctest.rst +++ b/doc/usage/extensions/doctest.rst @@ -75,7 +75,7 @@ a comma-separated list of group names. * ``pyversion``, a string option, can be used to specify the required Python version for the example to be tested. For instance, in the following case - the example will be tested only for Python versions greather than 3.3:: + the example will be tested only for Python versions greater than 3.3:: .. doctest:: :pyversion: > 3.3 diff --git a/doc/usage/extensions/napoleon.rst b/doc/usage/extensions/napoleon.rst index dc52e6375..0460f1607 100644 --- a/doc/usage/extensions/napoleon.rst +++ b/doc/usage/extensions/napoleon.rst @@ -130,7 +130,7 @@ Google vs NumPy ~~~~~~~~~~~~~~~ Napoleon supports two styles of docstrings: `Google`_ and `NumPy`_. The -main difference between the two styles is that Google uses indention to +main difference between the two styles is that Google uses indentation to separate sections, whereas NumPy uses underlines. Google style: diff --git a/doc/usage/restructuredtext/directives.rst b/doc/usage/restructuredtext/directives.rst index 130f21031..35d4ac384 100644 --- a/doc/usage/restructuredtext/directives.rst +++ b/doc/usage/restructuredtext/directives.rst @@ -654,7 +654,7 @@ Glossary .. rst:directive:: .. glossary:: This directive must contain a reST definition-list-like markup with terms and - definitions. The definitions will then be referencable with the + definitions. The definitions will then be referenceable with the :rst:role:`term` role. Example:: .. glossary:: diff --git a/doc/usage/restructuredtext/domains.rst b/doc/usage/restructuredtext/domains.rst index 80528756c..a868fa602 100644 --- a/doc/usage/restructuredtext/domains.rst +++ b/doc/usage/restructuredtext/domains.rst @@ -762,7 +762,7 @@ Some directives support options: Anonymous Entities ~~~~~~~~~~~~~~~~~~ -C++ supposrts anonymous namespaces, classes, enums, and unions. +C++ supports anonymous namespaces, classes, enums, and unions. For the sake of documentation they must be given some name that starts with ``@``, e.g., ``@42`` or ``@data``. These names can also be used in cross-references and (type) expressions, @@ -1155,7 +1155,7 @@ There is a set of directives allowing documenting command-line programs: Run a module as a script. The directive will create cross-reference targets for the given options, - referencable by :rst:role:`option` (in the example case, you'd use something + referenceable by :rst:role:`option` (in the example case, you'd use something like ``:option:`dest_dir```, ``:option:`-m```, or ``:option:`--module```). ``cmdoption`` directive is a deprecated alias for the ``option`` directive. @@ -1163,7 +1163,7 @@ There is a set of directives allowing documenting command-line programs: .. rst:directive:: .. envvar:: name Describes an environment variable that the documented code or program uses - or defines. Referencable by :rst:role:`envvar`. + or defines. Referenceable by :rst:role:`envvar`. .. rst:directive:: .. program:: name diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py index 9ba582ab5..f77ebda5e 100644 --- a/sphinx/addnodes.py +++ b/sphinx/addnodes.py @@ -252,8 +252,8 @@ class index(nodes.Invisible, nodes.Inline, nodes.TextElement): *entrytype* is one of "single", "pair", "double", "triple". - *key* is categolziation characters (usually it is single character) for - general index page. For the detail of this, please see also: + *key* is categorization characters (usually a single character) for + general index page. For the details of this, please see also: :rst:dir:`glossary` and issue #2320. """ diff --git a/sphinx/application.py b/sphinx/application.py index 0e3bcac3e..50bb9dfda 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -936,10 +936,10 @@ class Sphinx: Example:: app.add_js_file('example.js') - # =>
+ # => app.add_js_file('example.js', async="async") - # => + # => .. versionadded:: 0.5 @@ -1145,13 +1145,14 @@ class Sphinx: # type: (str, Tuple[Callable, Callable], Tuple[Callable, Callable]) -> None """Register a math renderer for HTML. - The *name* is a name of the math renderer. Both *inline_renderers* and - *block_renderes* are used as visitor functions for HTML writer. - *inline_renderers* is used for inline math node (``nodes.math`)). The - another is used for block math node (``nodes.math_block``). About - visitor functions, see :meth:`add_node` for more details. + The *name* is a name of math renderer. Both *inline_renderers* and + *block_renderers* are used as visitor functions for the HTML writer: + the former for inline math node (``nodes.math``), the latter for + block math node (``nodes.math_block``). Regarding visitor functions, + see :meth:`add_node` for details. .. versionadded:: 1.8 + """ self.registry.add_html_math_renderer(name, inline_renderers, block_renderers) diff --git a/sphinx/builders/__init__.py b/sphinx/builders/__init__.py index 3524eb891..12dfb9277 100644 --- a/sphinx/builders/__init__.py +++ b/sphinx/builders/__init__.py @@ -65,7 +65,7 @@ class Builder: #: ``project`` epilog = '' - #: default translator class for the builder. This can be overrided by + #: default translator class for the builder. This can be overridden by #: :py:meth:`app.set_translator()`. default_translator_class = None # type: Type[nodes.NodeVisitor] # doctree versioning method diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index 79d601460..e955e34f5 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -155,7 +155,7 @@ def init(locale_dirs, language, catalog='sphinx', namespace='general'): """Look for message catalogs in `locale_dirs` and *ensure* that there is at least a NullTranslations catalog set in `translators`. If called multiple times or if several ``.mo`` files are found, their contents are merged - together (thus making ``init`` reentrable). + together (thus making ``init`` reentrant). """ global translators translator = translators.get((namespace, catalog)) @@ -314,8 +314,8 @@ admonitionlabels = { 'warning': _('Warning'), } -# Moved to sphinx.directives.other (will be overrided later) +# Moved to sphinx.directives.other (will be overriden later) versionlabels = {} # type: Dict[str, str] -# Moved to sphinx.domains.python (will be overrided later) +# Moved to sphinx.domains.python (will be overriden later) pairindextypes = {} # type: Dict[str, str] diff --git a/sphinx/parsers.py b/sphinx/parsers.py index f55e2df73..438f18257 100644 --- a/sphinx/parsers.py +++ b/sphinx/parsers.py @@ -26,7 +26,7 @@ if False: class Parser(docutils.parsers.Parser): """ - A base class of source parsers. The additonal parsers should inherits this class instead + A base class of source parsers. The additional parsers should inherit this class instead of ``docutils.parsers.Parser``. Compared with ``docutils.parsers.Parser``, this class improves accessibility to Sphinx APIs. diff --git a/sphinx/search/zh.py b/sphinx/search/zh.py index 3c918b4dc..011706750 100644 --- a/sphinx/search/zh.py +++ b/sphinx/search/zh.py @@ -232,7 +232,8 @@ class SearchChinese(SearchLanguage): language_name = 'Chinese' js_stemmer_code = js_porter_stemmer stopwords = english_stopwords - latin1_letters = re.compile('(?u)\\w+[\u0000-\u00ff]') + latin1_letters = re.compile(r'[a-zA-Z0-9_]+') + latin_terms = [] # type: List[str] def init(self, options): # type: (Dict) -> None @@ -249,7 +250,9 @@ class SearchChinese(SearchLanguage): if JIEBA: chinese = list(jieba.cut_for_search(input)) - latin1 = self.latin1_letters.findall(input) + latin1 = \ + [term.strip() for term in self.latin1_letters.findall(input)] + self.latin_terms.extend(latin1) return chinese + latin1 def word_filter(self, stemmed_word): @@ -258,4 +261,15 @@ class SearchChinese(SearchLanguage): def stem(self, word): # type: (str) -> str + + # Don't stem Latin words that are long enough to be relevant for search + # if not stemmed, but would be too short after being stemmed + # avoids some issues with acronyms + should_not_be_stemmed = ( + word in self.latin_terms and + len(word) >= 3 and + len(self.stemmer.stem(word.lower())) < 3 + ) + if should_not_be_stemmed: + return word.lower() return self.stemmer.stem(word.lower()) diff --git a/tests/roots/test-search/tocitem.rst b/tests/roots/test-search/tocitem.rst index f082abf65..5d99f0a66 100644 --- a/tests/roots/test-search/tocitem.rst +++ b/tests/roots/test-search/tocitem.rst @@ -8,3 +8,9 @@ textinheading ============= lorem ipsum + +可以查看 FAQ 模块中 Chinesetest 部分 + +模块中 CAS service部分 + +可以Chinesetesttwo查看 diff --git a/tests/test_search.py b/tests/test_search.py index 97789f687..4ae3d460f 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -237,3 +237,18 @@ def test_IndexBuilder_lookup(): # zh_CN index = IndexBuilder(env, 'zh_CN', {}, None) assert index.lang.lang == 'zh' + + +@pytest.mark.sphinx( + testroot='search', + confoverrides={'html_search_language': 'zh'}, + srcdir='search_zh' +) +def test_search_index_gen_zh(app, status, warning): + app.builder.build_all() + # jsdump fails if search language is 'zh'; hence we just get the text: + searchindex = (app.outdir / 'searchindex.js').text() + assert 'chinesetest ' not in searchindex + assert 'chinesetest' in searchindex + assert 'chinesetesttwo' in searchindex + assert 'cas' in searchindex