Skip to content

Commit

Permalink
silence warnings generated by pybind overloads in doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Dec 1, 2023
1 parent 81d826a commit 56e2f2c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/python/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
29 changes: 29 additions & 0 deletions modules/python/doc/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand Down Expand Up @@ -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))

0 comments on commit 56e2f2c

Please sign in to comment.