Skip to content

refactor: Add env parameter to UnresolvedContext.resolve()#14

Merged
SilverRainZ merged 1 commit into
masterfrom
refactor/resolve-with-env
May 12, 2026
Merged

refactor: Add env parameter to UnresolvedContext.resolve()#14
SilverRainZ merged 1 commit into
masterfrom
refactor/resolve-with-env

Conversation

@SilverRainZ
Copy link
Copy Markdown
Member

Summary

  • Add env: BuildEnvironment parameter to UnresolvedContext.resolve() abstract method
  • Pass host.env from pending_node.render() to resolve()
  • Update UnparsedData.resolve() signature and tests accordingly

Motivation

PendingObject in sphinxnotes-any stores an ObjDomain reference which contains unpicklable objects (XRefRole closures in _role_cache), causing the Sphinx doctree serialization to fail. By providing env to resolve(), implementations can look up domain data at runtime rather than storing unpicklable references.

UnresolvedContext implementations may need access to the Sphinx build
environment during resolution. For example, PendingObject in
sphinxnotes-any requires env.get_domain() to look up the object domain
without storing an unpicklable domain reference.

Co-Authored-By: DeepSeek V4 Pro <service@deepseek.com>
SilverRainZ added a commit to sphinx-notes/any that referenced this pull request May 12, 2026
Storing ObjDomain directly in the PendingObject dataclass causes pickle
failures during doctree serialization because the domain contains
unpicklable local functions (XRefRole closures in _role_cache).

Store the domain name (str) instead of the domain instance, and look up
the domain at resolve time via env.get_domain().

This depends on sphinx-notes/render#14 which adds the env parameter to
UnresolvedContext.resolve().

Co-Authored-By: DeepSeek V4 Pro <service@deepseek.com>
@SilverRainZ SilverRainZ force-pushed the refactor/resolve-with-env branch from 2d53f3b to a11f4f4 Compare May 12, 2026 16:56
@SilverRainZ SilverRainZ merged commit 7117457 into master May 12, 2026
6 checks passed
SilverRainZ added a commit to sphinx-notes/any that referenced this pull request May 12, 2026
* fix: Prevent PendingObject from pickling ObjDomain reference

Storing ObjDomain directly in the PendingObject dataclass causes pickle
failures during doctree serialization because the domain contains
unpicklable local functions (XRefRole closures in _role_cache).

Store the domain name (str) instead of the domain instance, and look up
the domain at resolve time via env.get_domain().

This depends on sphinx-notes/render#14 which adds the env parameter to
UnresolvedContext.resolve().

Co-Authored-By: DeepSeek V4 Pro <service@deepseek.com>

* chore: domain_name -> domain

---------

Co-authored-by: DeepSeek V4 Pro <service@deepseek.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant