diff --git a/changelogs/fragments/187-role-errors.yml b/changelogs/fragments/187-role-errors.yml new file mode 100644 index 00000000..ebe887a7 --- /dev/null +++ b/changelogs/fragments/187-role-errors.yml @@ -0,0 +1,2 @@ +minor_changes: + - "When parsing errors happen in the Sphinx extension, the extension now emits error messages during the build process in addition to error markup (https://github.com/ansible-community/antsibull-docs/pull/187)." diff --git a/src/sphinx_antsibull_ext/roles.py b/src/sphinx_antsibull_ext/roles.py index 54c58ea9..e0dae4a8 100644 --- a/src/sphinx_antsibull_ext/roles.py +++ b/src/sphinx_antsibull_ext/roles.py @@ -14,6 +14,7 @@ from docutils import nodes from docutils.utils import unescape # pyre-ignore[21] from sphinx import addnodes +from sphinx.util import logging from antsibull_docs.markup.semantic_helper import ( parse_option, @@ -24,6 +25,8 @@ from .sphinx_helper import extract_explicit_title +logger = logging.getLogger(__name__) + def _plugin_ref(plugin_fqcn: str, plugin_type: str) -> str: return f"ansible_collections.{plugin_fqcn}_{plugin_type}" @@ -160,9 +163,11 @@ def _create_ref_or_not( return refnode -# pylint:disable-next=unused-argument def _create_error(rawtext: str, text: str, error: str) -> tuple[list[t.Any], list[str]]: content = nodes.strong(text, error, classes=["error"]) + logger.error( + f"while processing {rawtext}: {error}", location=content, type="semantic-markup" + ) return [content], []