Skip to content

docutils language importer warningΒ #10179

@ultmaster

Description

@ultmaster

Describe the bug

My sphinx build complains:

xxx.rst:: WARNING: rST localisation for language "zh" not found.

There is no way to suppress this, because the type and subtype here are both none:

def is_suppressed_warning(type: str, subtype: str, suppress_warnings: List[str]) -> bool:

The warning comes from RstLanguageImporter in docutils (v0.17.1). There is a warning-suppresser in sphinx for LanguageImporter:

@contextmanager
def patched_get_language() -> Generator[None, None, None]:

but the suppresser doesn't work for RstLanguageImporter.

I believe this is a bug. A simple fix can be patching RstLanguageImporter in patched_get_language as well.

How to Reproduce

$ git clone https://github.com/microsoft/nni
$ cd nni
$ git checkout 04781745b9986076591f43b9b7a47dc8e5b6f3de
$ pip install -r dependencies/develop.txt
$ pip install -r dependencies/required.txt
$ pip install -r dependencies/required_extra.txt
$ pip install -r dependencies/recommended.txt
$ cd docs
$ make -e SPHINXOPTS="-W --keep-going -T -D language='zh'" html

Expected behavior

The build should complete with no warning.

Your project

https://github.com/microsoft/nni/tree/04781745b9986076591f43b9b7a47dc8e5b6f3de/docs

Screenshots

image

https://msrasrg.visualstudio.com/NNIOpenSource/_build/results?buildId=32185&view=logs&j=c732a39c-9d2c-544b-001e-d0b8721ee1cc&t=978da1c7-9944-5976-065b-459f57f62524

OS

Ubuntu

Python version

3.8

Sphinx version

4.4.0

Sphinx extensions

No response

Extra tools

No response

Additional context

Note that I have custom extensions to handle i18n.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions