Skip to content

Create a new type for the current document's environment state#13151

Merged
AA-Turner merged 16 commits intosphinx-doc:masterfrom
AA-Turner:cleanup/current-document
Jan 4, 2025
Merged

Create a new type for the current document's environment state#13151
AA-Turner merged 16 commits intosphinx-doc:masterfrom
AA-Turner:cleanup/current-document

Conversation

@AA-Turner
Copy link
Member

Feature or Bugfix

  • Refactoring

Purpose

As a step towards #13072, this PR introduces a new CurrentDocument type to store and manipulate state in the environment for the document currently being read. This is currently stored in a temp_data dict.

We also rename the attribute on BuildEnvironment to current_document from temp_data, keeping the old name as an alias.

At present, none of the old names or e.g. the mapping interface to CurrentDocument are deprecated, though I expect that in the future this would be done.

For downstream extensions that make use of env.temp_data['...'], this should be a transparent refactor.

xref:

@AA-Turner AA-Turner added this to the 8.2.0 milestone Nov 22, 2024
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

This kind of interface, while being transparent for the user, may be worth documenting for extension developers
The class wouldn't be exposed but we can expose each documented attribute.

@AA-Turner AA-Turner requested a review from picnixz January 3, 2025 04:36
@AA-Turner
Copy link
Member Author

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

This interface looks cleaner and this would help us refactoring things more easily.

@AA-Turner AA-Turner merged commit e65bbb9 into sphinx-doc:master Jan 4, 2025
@AA-Turner AA-Turner deleted the cleanup/current-document branch January 4, 2025 00:28
shimizukawa added a commit that referenced this pull request Jan 16, 2025
#13151 changed the Environment class, but the `ENV_VERSION` has not been updated. This causes errors when building with existing environments.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 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.

2 participants