-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Incomplete documentation for env_version #12237
Comments
@chrisjsewell You introduced the typed interface for that one so perhaps you could take that one? |
Well, that's one of the reasons I introduced it; because for a long time I had no idea
I would note here, that I feel the purpose of a domain is more around handling referencing, and then the storage of data here is more of a "side-effect" of that; to store pointers to targets, etc |
This kinda says the opposite: #9003 (comment) Would you suggest adding arbitrary attributes to And it's not only about storing data, it's also about making it work with parallel builds, which is actually hard, see e.g. #12251. And to be fancy, it's about removing the appropriate data if a source file is removed (which the "todo" extension does but the "recipe" extension doesn't, AFAICT). For a concrete example, see mgeier/sphinx-last-updated-by-git#66. I'm not sure if that's better or worse, BTW! |
well that is not consistent with what the actual source says: sphinx/sphinx/domains/__init__.py Lines 159 to 180 in 6fd8b30
We deal with this in sphinx-needs with parallel builds for large documentation sets, and it works quite well: https://github.com/useblocks/sphinx-needs/blob/0f71ecde47a3f7c3245c5bcf545ef5281376768c/sphinx_needs/needs.py#L266-L270 But I agree that it would be nice to have a "consistent" workflow for storing data (outside of references) |
Well, the docstring you are quoting is nearly 15 years old, so maybe the usage recommendations of this have changed slightly in the meantime? Maybe the docstring should be updated? I have added this to the task list above. Is there anything except that docstring that makes you think that it is not appropriate to store arbitrary data in a
Thanks for this example, this is really interesting, since it seems to be a perfect fit for a The Now the merging and invalidation of data is scattered over different places, a As an added benefit, this domain could then be used to namespace the (many) roles/directives to get something like I'm of course not suggesting to do that now, because it would be too disruptive, but for a new project I would definitely consider it. Ironically, the extension is not returning |
Oh I forgot there is something more in-line with what you want:
and can be added with Line 1221 in 5562e2b
you see it just links methods to event hooks though, ao nothing you couldn't implement on your own
The whole of the In addition, all roles are expected to be references to domain objects, and all directives are expected to create targets. As I mentioned already, storing data is just a "side-effect" of reference resolution, not a primary goal of the If all you want to do is store data, then you are bringing in a whole lot of things you probably don't need;
yep by me 😄 |
Just my 2 cents:
In my own extension, I have a single dictionary which is storing every information I need. It works a bit like the registry on MS-DOS systems where you have namespaces + key/values and any other "component" can put whatever they want in that registry using their own registry key (a bit like the Stash in pytest actually). I create that dictionary as a single attribute in
Probably because we didn't want the tutorial to add some unknown logic.
There is actually a docstring about what the environment version is meant for:
|
See daade27, which redrafts some of the wording in https://www.sphinx-doc.org/en/master/extdev/#extension-metadata. I think that this should close this issue by covering @mgeier's remaining points, save regarding where best for an extension to store state/data, which I think should be split into its own issue (especially as it isn't solely a documentation point), and may link to #13072 if we can come up with a better way of storing data than simply a free-for-all creating new attributes on Matthias -- do you think there is anything further outstanding in terms of the documentation of A |
Describe the bug
https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata documents
env_version
.It says:
... but it gives no indication how/why to do that.
It could e.g. link to https://www.sphinx-doc.org/en/master/development/tutorials/todo.html
It says:
... but it doesn't say if that includes a
Domain
(https://www.sphinx-doc.org/en/master/extdev/domainapi.html) defined by the extension. I assume that the domain is somehow stored in the environment, but I guess it doesn't need to be reflected inenv_version
because it tracks its own structure with thedata_version
attribute?https://www.sphinx-doc.org/en/master/development/tutorials/todo.html shows an extension that stores data in the environment, but it does not return
env_version
in itssetup()
function!https://www.sphinx-doc.org/en/master/development/tutorials/todo.html could mention that alternatively, a
Domain
could be used to store data in the environment. It could link to https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html, which provides an example for that.https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html does not mention
data_version
, which is of course not strictly necessary, but I think it might be a good idea to recommend specifying it, to make it easier to not forget bumping it once there are changes to the data at a later time.This has nothing to do with
env_version
, but looking at the tutorials, I have seen that https://www.sphinx-doc.org/en/master/development/tutorials/autodoc_ext.html does not setparallel_read_safe
but I guess there is no reason for this extension to disable parallelization, right?The docstring of
Domain
doesn't give any information whether it is recommended to use it to store arbitrary data (see Incomplete documentation for env_version #12237 (comment))How to Reproduce
Look at https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata
The text was updated successfully, but these errors were encountered: