-
Notifications
You must be signed in to change notification settings - Fork 98
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
linkcheck errors on unknown confluence_*
directives and roles
#927
Comments
This extension disabled the automatic registration of custom directives/roles due to the reason that a combination that some third-party builders, Sphinx and docutils could generate We did get a change into Sphinx (v4.4+) which defaulted Sphinx to generate warnings over exceptions for unknown nodes. Since it has been some time since this was merged in, we might be able to re-introduce the registration of these custom directives/roles again by default. This will of course result in generating "unknown node" warnings over unknown directive/role warnings for an active translator. Maybe this is not an issue for builders like So, if we:
Maybe the change noted in the first point would be sane to make. However, a worry is that users with existing documentation that use a mix of
(see also: #868) Will ponder this a bit. Welcome any comments. |
Thank you for the quick and again very detailed response. I think you have more context than I do, and I don't have a great understanding of the needs of users who have both That said, I wonder if either as a permanent or temporary solution, you could expand the builders with which the directives are registered. Something like: from sphinx.builders.linkcheck import CheckExternalLinksBuilder
try:
from sphinxcontrib.spelling.builder import SpellingBuilder
except ModuleNotFoundError:
acceptable_builders = (ConfluenceBuilder, CheckExternalLinksBuilder)
else:
acceptable_builders = (ConfluenceBuilder, CheckExternalLinksBuilder, SpellingBuilder)
if not isinstance(app.builder, acceptable_builders):
return or, perhaps, exposing those |
A change has been introduced in #936 which permits the registration of directives/roles when it detects a builder that does not have a translator. Hopefully this will help avoid warnings being generated in special builders (such as This change should be available in the next release (v2.5). In the rare chance that anyone using this change results in an exception, please report it here or another issue. As a workaround, using the option @adamtheturtle, thanks for mentioning this. Hopefully, this may improve the user experience for everyone. Please let me know if there is anything that has been overlooked. |
Thank you @jdknight ! Nothing is overlooked AFAIK. I really appreciate how thorough and thoughtful you are with this project. However, if you'd like to support actual link checking, you can use something like the following as the role for from docutils.nodes import Node
from docutils.parsers.rst.states import Inliner
from docutils.utils import SystemMessage
def link_role(
role: str,
rawtext: str,
text: str,
lineno: str,
inliner: Inliner,
) -> tuple[list[Node], list[SystemMessage]]:
link_text = text
link_url = text
node = nodes.reference(rawsource=rawtext, text=link_text, refuri=link_url)
return [node], [] |
Thanks for mentioning Updated the implementation to register card hrefs into a linkcheck builder with a custom transform (see #938). |
v2.5 is now available on PyPI -- marking as closed. |
confluence_*
directivepython -m sphinx -W -b linkcheck source build/linkcheck -E -a
).This also applies to the
sphinxcontrib.spelling
builder.I do not expect to see errors.
I believe that this is because the roles and directives are only added in the case that the builder is the Confluence builder:
https://github.com/sphinx-contrib/confluencebuilder/blob/bc2dbe66eb4865b017d5366e2c796db32e16fcf8/sphinxcontrib/confluencebuilder/__init__.py#L298C5-L298C30
My initial thought was to use
.. only
or.. ifconfig
, but these did not work, and I believe that this is explained at sphinx-doc/sphinx#4224 (comment):Advice welcome on how best to use these directives with the link checker / spell checker.
The text was updated successfully, but these errors were encountered: