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

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

Merged
merged 16 commits into from
Jan 4, 2025

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.

sphinx/builders/__init__.py Show resolved Hide resolved
sphinx/domains/c/__init__.py Outdated Show resolved Hide resolved
sphinx/domains/c/__init__.py Outdated Show resolved Hide resolved
sphinx/domains/changeset.py Show resolved Hide resolved
sphinx/domains/cpp/__init__.py Outdated Show resolved Hide resolved
sphinx/environment/__init__.py Outdated Show resolved Hide resolved
sphinx/environment/__init__.py Show resolved Hide resolved
sphinx/environment/__init__.py Outdated Show resolved Hide resolved
sphinx/environment/__init__.py Outdated Show resolved Hide resolved
@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.

sphinx/environment/__init__.py Outdated Show resolved Hide resolved
sphinx/environment/__init__.py Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants