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

A better way to store extension data on the environment #9003

Open
timhoffm opened this issue Mar 15, 2021 · 1 comment
Open

A better way to store extension data on the environment #9003

timhoffm opened this issue Mar 15, 2021 · 1 comment

Comments

@timhoffm
Copy link
Contributor

Problem

The approach to storing extension data is explained only vaguely.

From the env-merge-info description and
the todo extension tutorial I infer that one has to add arbitrary attributes to the env object.

This doesn't look very clean. It risks breaking the object and one has to be careful that the data is already added (lots of hasattr() checks).

Proposal

  • Add a dict env.extension_data and recommend extensions writing there.
  • Can one initialize the extension data instead of checking in various places if it exists? Would env-before-read-docs the right place? I.e.
def setup(app):
    ...
    app.connect("env-before-read-docs", setup_data)

def setup_data(app, env, docnames):
    env.extension_data['todo_all_todos'] = []
@timhoffm timhoffm added the type:enhancement enhance or introduce a new feature label Mar 15, 2021
@tk0miya
Copy link
Member

tk0miya commented Mar 15, 2021

Absolutely. Adding arbitrary attributes to the env object is ugly. Actually, the real "todo" extension uses a Domain component as a datastore. It can define methods for initialization, gathering contents, merging, and purging. To support parallel build, extension should support both merging and purging. So the Domain component is better to implement it, I think

timhoffm added a commit to timhoffm/matplotlib that referenced this issue Apr 24, 2021
This uses a domain as data store for the redirects sphinx plugin.
That is how the sphinx todo extension handles data and was suggested in
sphinx-doc/sphinx#9003 (comment)
timhoffm added a commit to timhoffm/matplotlib that referenced this issue Apr 28, 2021
This uses a domain as data store for the redirects sphinx plugin.
That is how the sphinx todo extension handles data and was suggested in
sphinx-doc/sphinx#9003 (comment)

Limit documenting special members to __call__

Closes matplotlib#20080.

Follow up to matplotlib#17151.
@AA-Turner AA-Turner added this to the some future version milestone Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants