Skip to content

Conversation

@Tiger3018
Copy link
Contributor

Subject:

Bugfix and Refactoring

Purpose

Please see commit message and its TODO.

Detail

(Refactoring) From commit message

  • Remove: Since the application.py has the warning of write or read ahead of "doing serial %s", it is safe to remove the second warning.

  • Documentation: Replace "should be considered experimental" with proposal typename ext_*

  • util/logging.py: Change the regex match of warning type.

  • Test:

  • application.py:

Relates

Following sphinx-doc#3142, sphinx-doc#7460, sphinx-doc#9628, there are still some logger.warning
in toc parsing and rendering (not in extensions) not categorized.

This patch introduce DocumentError in environment adapter, reuse
subtype `excluded`, `not_readable`, and add 4 `toc` subtypes, with
the help of `grep`.
Following sphinx-doc#10107, sphinx-doc#11412(deprecated warn), add relevent type and
subtype(`i18n` only) to logger.warning.

Add warning in `util/i18n.py` to show the fallback locale.

This commit with 7f5ab05 should fix ambiguous or dysfunctional
configuration values of :confval:`suppress_warnings`.
Since the `application.py` has the warning of write or read ahead
of "doing serial %s", it is safe to remove the second warning.

Replace "should be considered experimental" with proposal typename
`ext_*`. Conclude this patch along with 7f5ab05 and bdea05e in
`versionchange::`. Correct the former bad typesetting.

TODO: change the regex match of warning type, add test file to make
`ext_*` type robust usage in `application.py`.

TODO: community advice from PR.
@Tiger3018 Tiger3018 force-pushed the master branch 3 times, most recently from d75e285 to 49eee15 Compare September 5, 2023 19:25
Make ``toc``, ``i18n`` and ``index`` warning types cover all relative
warnings.

Added ``i18n.babel``, ``i18n.not_readable``, ``i18n.not_writeable``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would those warnings mean?

Actually we should maybe have a follow-up issue which documents where and when warnings of such type/subtype are emitted because it's not always clear.

logger.warning(message, ref, location=toctreenode)
raise
logger.warning(message, ref, location=toctreenode, type='toc', subtype=subtype)
raise DocumentError(message % ref) from err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? We should probably keep the KeyError because I have no idea if it is caught somewhere else differently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in environment/init.py#L455 when there is an OSError.

title = ref and nodes.reference(..., *[nodes.Text(title)]) in following lines might be only KeyError source. I think this DocumentError could be outstanding for users to check original document status or filesystem status.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I would keep the exception type because they might catch it or assume its type. Changing the exception type could lead to incompatible changes and this requires a major version.

logger.warning(__('toctree contains ref to nonexisting file %r'),
includefile, location=docname)
includefile, location=docname,
type='toc', subtype='not_readable')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question as for excluded.

return formatter(date, format, locale=locale)
except (ValueError, babel.core.UnknownLocaleError):
# fallback to English
logger.warning(__('Invalid locale for babel. Fallback locale to `en`.'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could indicate the bad locale? because such warming is not necessarily helpful otherwise.

@cale-vdw
Copy link

Hi, is this PR still in progress to be merged soon @Tiger3018 @picnixz?

@picnixz
Copy link
Member

picnixz commented May 28, 2024

I personally am not involved in this PR and won't be taking over so it's up to the author to decide when it's ready. I'll nonetheless review the PR when it's updated.

# Conflicts:
#	doc/usage/configuration.rst
#	sphinx/environment/adapters/toctree.py
@AA-Turner AA-Turner added the awaiting:response Waiting for a response from the author of this issue label Jan 19, 2025
# Conflicts:
#	doc/usage/configuration.rst
#	sphinx/directives/other.py
#	sphinx/environment/__init__.py
#	sphinx/environment/adapters/indexentries.py
#	sphinx/environment/adapters/toctree.py
#	sphinx/util/i18n.py
#	sphinx/util/nodes.py
@AA-Turner AA-Turner changed the title suppress_warnings bugfix and refactoring towards extension Add more warning types and sub-types Jan 28, 2025
@AA-Turner AA-Turner added internals:config and removed awaiting:response Waiting for a response from the author of this issue labels Jan 28, 2025
@AA-Turner AA-Turner marked this pull request as ready for review January 29, 2025 19:22
@AA-Turner AA-Turner merged commit af3bb36 into sphinx-doc:master Jan 29, 2025
22 checks passed
@AA-Turner AA-Turner added this to the 8.2.0 milestone Jan 31, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants