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

allow registering entities for non-translating builders #936

Merged
Merged
Changes from all 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
26 changes: 24 additions & 2 deletions sphinxcontrib/confluencebuilder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ def setup(app):
cm.add_conf_bool('confluence_adv_bulk_archiving')
# Disable workaround for: https://jira.atlassian.com/browse/CONFCLOUD-74698
cm.add_conf_bool('confluence_adv_disable_confcloud_74698')
# Disable any attempts to initialize this extension's custom entities.
cm.add_conf_bool('confluence_adv_disable_init')
# Flag to permit the use of embedded certificates from requests.
cm.add_conf_bool('confluence_adv_embedded_certs')
# List of node types to ignore if no translator support exists.
Expand Down Expand Up @@ -302,10 +304,26 @@ def confluence_builder_inited(app):
Handling a `builder-inited` event generated from Sphinx.
"""

# ignore non-confluence builder types
if not isinstance(app.builder, ConfluenceBuilder):
# always skip initialization if configured to do so
if app.config.confluence_adv_disable_init:
return

# ignore non-confluence builder types if they have a translator
# (i.e. a builder that needs to support processing nodes generated
# from custom directives/roles); this allows other builders such
# as Sphinx's external link check to not generate warnings about
# unknown directives/roles, while being flexible for builder that
# expect to translate but would generate an exception for an unknown
# node
if not isinstance(app.builder, ConfluenceBuilder):
try:
translator = app.builder.get_translator_class()
except AttributeError:
pass
else:
if translator:
return

# register nodes required by confluence-specific directives
if not docutils.is_node_registered(confluence_metadata):
app.add_node(confluence_metadata)
Expand Down Expand Up @@ -338,6 +356,10 @@ def confluence_builder_inited(app):
app.add_role('confluence_strike', ConfluenceStrikeRole)
app.add_role('jira', JiraRole)

# always ignore non-confluence builder types for overrides below
if not isinstance(app.builder, ConfluenceBuilder):
return

# other
confluence_autosummary_support(app)
confluence_imgmath_support(app)
Expand Down