Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx extension: log build errors next to emitting error markup #187

Merged
merged 4 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/187-role-errors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "When parsing errors happen in the Sphinx extension, the extension now emits error messages during the build process next to emitting error markup (https://github.com/ansible-community/antsibull-docs/pull/187)."
7 changes: 6 additions & 1 deletion src/sphinx_antsibull_ext/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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}"
Expand Down Expand Up @@ -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], []


Expand Down