diff --git a/swh/docs/sphinx/conf.py b/swh/docs/sphinx/conf.py --- a/swh/docs/sphinx/conf.py +++ b/swh/docs/sphinx/conf.py @@ -277,7 +277,7 @@ # ensure glossary will be available in package doc scope app.connect("source-read", add_glossary_to_index) - # suppress httpdomain warnings in non web packages + # suppress some httpdomain warnings in non web packages if "swh-web" not in app.srcdir: # filter out httpdomain unresolved reference warnings @@ -286,6 +286,21 @@ def filter(self, record: logging.LogRecord) -> bool: return not record.msg.startswith("Cannot resolve reference to") - logger = logging.getLogger("sphinx") - # insert a custom filter in the warning log handler of sphinx - logger.handlers[1].filters.insert(0, HttpDomainWarningFilter()) + # suppress some httpdomain warnings in web package + else: + + # filter out non critical warnings appeared with sphinx 4.1 release + # TODO: remove that hack when that pull request gets merged + # https://github.com/sphinx-contrib/httpdomain/pull/51 + class HttpDomainWarningFilter(logging.Filter): + def filter(self, record: logging.LogRecord) -> bool: + return not ( + record.args + and type(record.args) == tuple # to keep mypy happy + and record.args[0] == "http" + and record.msg.endswith("but that role is not in the domain.") + ) + + logger = logging.getLogger("sphinx") + # insert a custom filter in the warning log handler of sphinx + logger.handlers[1].filters.insert(0, HttpDomainWarningFilter())