From 56e2f2c82a1379cfcab0da1af9b66fe4e0066cc3 Mon Sep 17 00:00:00 2001 From: Samuel Felton Date: Fri, 1 Dec 2023 17:15:31 +0100 Subject: [PATCH] silence warnings generated by pybind overloads in doc --- modules/python/doc/CMakeLists.txt | 2 +- modules/python/doc/conf.py.in | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/python/doc/CMakeLists.txt b/modules/python/doc/CMakeLists.txt index 3854633073..ec54df5cec 100644 --- a/modules/python/doc/CMakeLists.txt +++ b/modules/python/doc/CMakeLists.txt @@ -67,7 +67,7 @@ configure_file( add_custom_target(visp_python_bindings_doc COMMAND ${PYTHON3_EXECUTABLE} -m pip install -r "${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt" COMMAND sphinx-build - -q -b html + -b html -c "${BINARY_BUILD_DIR}" -d "${SPHINX_CACHE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/modules/python/doc/conf.py.in b/modules/python/doc/conf.py.in index ef41fba344..07414349b4 100644 --- a/modules/python/doc/conf.py.in +++ b/modules/python/doc/conf.py.in @@ -16,6 +16,9 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. import sys import os +from sphinx.util.logging import * + + sys.path.insert(0, os.path.abspath('../build')) @@ -336,3 +339,29 @@ texinfo_documents = [ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = {"python": ("https://docs.python.org/", None)} + +from sphinx.util.logging import WarningLogRecordTranslator + +# Filter warning about Parameter names not matching function signature +# This is somethiing that is due to pybind overloads, so we cannot do anything about it +class FilterPybindArgWarnings(WarningLogRecordTranslator): + def filter(self, record): + if 'Parameter name' in record.msg and 'does not match any of the parameters' in record.msg: + return False + return super(FilterPybindArgWarnings, self).filter(record) + +# Filter warning about duplicate objects +class FilterNoIndexWarnings(WarningLogRecordTranslator): + def filter(self, record): + if 'use :no-index: for' in record.msg: + return False + return super(FilterNoIndexWarnings, self).filter(record) + + +def setup(app): + import logging + from sphinx.util.logging import NAMESPACE + logger = logging.getLogger(NAMESPACE) + for handler in logger.handlers: + handler.addFilter(FilterPybindArgWarnings(app)) + handler.addFilter(FilterNoIndexWarnings(app))