Problem/Motivation
Followup from #2232275: System menu blocks need to be able to depend on their menu entities.
Plugins can now declare configuration dependencies.
This should have been documented as part of committing the issue above, but the plugin annotation documentation seems to have disappeared. So part of this issue is finding the existing documentation and then, once found, updating it.
Proposed resolution
Find the existing plugin annotation documentation.
Updated it to include changes from #2232275.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#57 | interdiff-copyedit.txt | 3.47 KB | jhodgdon |
#57 | 2235363-config-docs-56.patch | 11.69 KB | jhodgdon |
Comments
Comment #1
xjmComment #2
xjmOops.
Comment #3
jessebeach CreditAttribution: jessebeach commentedShould I be editing these pages?
system.api.php
-> https://api.drupal.org/api/drupal/core%21modules%21system%21system.api.p...I don't see a
@defgroup plugin
yet.Comment #4
jessebeach CreditAttribution: jessebeach commentedPlugin API in Drupal 8
Annotations-based plugins
Comment #5
jessebeach CreditAttribution: jessebeach commentedOy, I have no idea where to put this documentation. The use case and code is really particular. I thought that it might belong in API usage, but that's not right the more I think about it. Really, it feels like it should be a blog post. I guess I'll just continue with this page:
https://drupal.org/node/2235409
Comment #6
jessebeach CreditAttribution: jessebeach commentedAlright, this needs review. I tried to walk the line between illustrating how to declare the dependencies and where they are collected. I do not think this documentation should dive into block plugin derivatives and the inner workings of the specific implementation for system menu blocks.
https://drupal.org/node/2235409
Comment #7
xjmThis sentence doesn't provide context for what "another" configuration entity is. In general, we want the configuration entities to be decoupled from the plugin-configured data they store, and we probably need to explain that. It's a hard concept (see: months spent trying to decouple them for the Block API).
Looking promising other than that. I do think we also need to document this in the codebase, though. The problem is that the rest of the plugin API is also missing its codebase documentation. :P
I'd suggest looking for where the entity info annotation keys are documented these days; that should give us some idea of how to document plugin definition properties... or at least how it's been done so far.
Comment #8
jessebeach CreditAttribution: jessebeach commentedI'd like to avoid turning this into an issue to document plugins in general. The intent is to document configuration dependencies. If I go down a rabbit hole of documenting plugins, I won't be able to focus on other blockers.
Comment #9
jessebeach CreditAttribution: jessebeach commentedI've added a link to the configuration entity docs page.
I'm not sure I agree that we need to explain what not to do here. Declaring a dependency does not imply data mingling, so warning someone to avoid this just opens up a topic that I can't adequately address. Such detail is the stuff of blog posts and forum posts. We're just documenting capabilities here, right? Or I've completely misunderstood what you intended with the comment.
I'll expand the example of the menu configuration entity, since that's the only one we have right now.
Comment #10
jessebeach CreditAttribution: jessebeach commentedActually, I'll just change the wording to an entity, full stop, and remove the suggestive grammar of "another".
Comment #11
jessebeach CreditAttribution: jessebeach commentedChanged to: Plugins may also declare dependencies. A dependency might be a module, a theme or an entity.
Comment #12
jhodgdonHi there! I've been out for the last 10 days... jessebeach left a message for me to ask about where to put these docs but I think maybe you found a good place? Let me know if you still have questions.
Regarding api.drupal.org, there are D8 topics called "Annnotations" and ... well we don't exactly have one for Plugins per se. There are topics about specific plugin types, like Blocks, but nothing called "Plugins" in the topics list or on the api.d.o landing page: https://api.drupal.org/api/drupal/8 -- could be added, or you could add to the Annotations page?
If you file a patch for this or any other api.d.o topic, please change the component to "Documentation". Thanks!
Comment #13
xjmAgreed that this should be documentation component.
The problem is that this key needs to be documented in the codebase, like all keys in all plugin definitions. It's API, not just conceptual documentation. But unfortunately we're missing a good way of documenting these. The similar example I can think of is the entity info documentation, which I (re-)wrote for D8 back in 2012, and I can't even find it anymore. So we have a larger problem with documenting this metadata generally.
@alexpott also had some feedback on the documentation itself that's to be posted at some point.
Re: the absent plugins section, that's why I filed #2234439: Add a section for the plugin system to the API doc landing page. :)
Comment #14
jhodgdonOK -- hadn't seen the other issue yet (just got back from a long trip and I haven't looked through the new Docs component issues yet. Later today...)
So, we had an issue about documenting annotations several weeks ago, due to the EntityType problem.
We decided at that point that most annotations are (and should be) documented on their Annotation class, and all of these are listed at
https://api.drupal.org/api/drupal/core!modules!system!system.api.php/gro...
automatically by the API module (it makes all classes with @Annotation that are in /core but not /core/vendor show up in this topic). For most annotation classes, you can click through and get docs on the components of the annotation (the class members).
And for plugin/annotation types that uses get/set methods, such as EntityType, the plan was that when you click through to the annotation class, you will see something like this:
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Annotation...
which tells you where to go to find documentation of this annotation type.
So... I'm a bit confused about this particular annotation thing of this issue, and how it fits into the picture... is config dependencies annotation common to all annotations? Is it on a class somewhere? ???
Comment #15
jessebeach CreditAttribution: jessebeach commentedconfig_dependencies
is a property that some configuration entities declare (in their schema currently). So whereas the property might be expressed in annotation, it isn't necessarily always defined in annotation. Annotation is (nearly) always a subset of the properties of a Plugin.So
config_dependencies
is a logical property of a Plugin, which is why I was having trouble understanding where to put it. Maybe in the preamble to a Plugins section?Comment #16
jhodgdonThis doesn't sound like a generic Plugin thing then -- it's specifically a Config Entity thing, right? So it should probably go in documentation about config entities, not generic docs about Plugins?
Comment #17
jessebeach CreditAttribution: jessebeach commentedYes, you're right. Is this the config entity documentation? https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!Entity!Con...
Comment #18
jhodgdonProbably best to put information on the ConfigEntityInterface class, or perhaps in one of these topics (which are linked from the D8 api.d.o landing page):
https://api.drupal.org/api/drupal/core!modules!system!core.api.php/group...
https://api.drupal.org/api/drupal/core!modules!system!core.api.php/group...
Hmmm... Probably the Config & State topic will need to be expanded to make a sub-topic for config entities, and that would be a good place to put this information? Then both config_state and entity_api topics could link to this topic?
Comment #19
jessebeach CreditAttribution: jessebeach commentedOk, how about this?
Comment #20
jhodgdonHm. You've added this to the Entity API topic. Doesn't it belong in the Config and State topic instead? And... If I didn't know what this was to begin with (and I barely do)... I do not think this documentation would give me the information I need. I think it needs to start out with describing what a configuration dependency is, then how to declare it in the YML file, and then ... why even include that code block from Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies() at all? It could refer to that if necessary, but what am I supposed to learn from reading that code? My eyes glossed over.
Also, nitpicks:
a)
Too much indentation. The - should line up with the text above.
b)
Should end in : and not have a blank line afterwards?
c)
Any use of a namespace in documentation *must* start with backslash.
d) See link to https://drupal.org/documentation/administer/config -- why is this relevant? This is presumably a programming topic, and the link is about how to administer configuration?
Comment #21
jessebeach CreditAttribution: jessebeach commentedHmm, I thought I had added it there! Sorry, I don't know how to view the changes I make to the API comments, so I don't know what they look like when rendered. I'm just kind of guessing :) Is there a way one can view these changes in a browser locally?
So, I'm of the opinion that the current doc page is sufficient, that one at https://drupal.org/node/2235409
This topic is quite advanced. And one would not normally declare these dependencies in annotation, as @alexpott mentions here:
#2232275-24: System menu blocks need to be able to depend on their menu entities
Which is a response to my tentative example:
We have one example in the core codebase. As a developer, I would use this example to develop my own implementation. I don't think we can document this capability short of copy-pasting chunks of code into the doc page.
For me, I'd like to see a docs page that identifies the capability and points me to code that I can use as a starting point.
Comment #22
jhodgdonThe only way to view what your changes would look like on api.drupal.org is to build an API site with the API module. Docs at: https://drupal.org/node/1516558 (not that I'd recommend it).
I still stand by my comment in #20. This documentation doesn't tell me why I need dependencies at all, what they're for, etc. Or how to do them, if they're normally not supposed to be in the YML file. And I don't see how the calculateDependencies() bit is useful at all. What is it supposed to illustrate?
What I'm trying to say is, after reading either the d.o page you linked or the patch (which appear to be identical), I still have no idea at all what this is about, whether I need to know about this, or if I did, how I would use it.
Comment #23
jessebeach CreditAttribution: jessebeach commentedComment #24
jessebeach CreditAttribution: jessebeach commentedOk, I see this point. I've tried to address the who, what, where and why of the issue in the original doc page: https://drupal.org/node/2235409
Upon further reflection, dependencies are a feature of configuration entities in general, not just plugins in particular, so this page should be needs to be reparented under https://drupal.org/developing/api/8/configuration. I don't have permission to do this.
I hid the patch on this issue. I'd prefer to leave the documentation for this capability on the standard community docs site.
Comment #25
jhodgdonThanks!
The page is reparented (block on the sidebar showing navigation is cached so it may take a moment to be fixed; this is a known and annoying bug that I wish would get fixed).
I agree with just putting this info on the d.o pages and not in a patch.
And the docs look a lot better, thanks! At least I have some idea after reading it now what is going on. I'd be inclined to mark this issue as fixed, but leaving for more knowledgeable others to review.
Comment #26
xjmWe need @alexpott to take a look at this -- he said he had some feedback on it as of last week.
Comment #27
dawehnerI would really rather have that directly on the interface. With @code we can place some examples in there as well. This would be the expected place to look for.
Comment #28
jessebeach CreditAttribution: jessebeach commentedre:#27, dawehner, it turns out we have this documentation on
\Drupal\Core\Config\Entity\ConfigDependencyManager
. So I've added an@see
in\Drupal\Core\Config\Entity\ConfigEntityInterface
that links to it.alexpott, I updated the docs page: https://drupal.org/node/2235409
Comment #29
jhodgdonThat @see looks quite reasonable in that patch... I think the online docs are also looking pretty good? Inviting anyone who thinks there are problems in the docs, or that we need more/better/additional docs, to set issue back to needs work and explain what still needs to be done.
Comment #30
xjm@alexpott will review this for technical accuracy. He said he'd do so "this weekend".
Comment #31
alexpottThe problem we have it that there still is nowhere in the code base that tells people about the special plugin definition
config_dependencies
key. Adding the @see is a good move. I guess we can add something to the text in ConfigDependencyManager.I've also reshaped the text on the handbook page for correctness and added some @todo's
Comment #32
xjmThanks!
Comment #33
xjmDiscussed with @alexpott and we agreed to downgrade this from beta-blocking, since this particular documentation issue is not actually critical, and a non-release-blocker can't be a beta blocker by definition. The beta criteria also don't include missing documentation. However, we should still target it for beta if possible.
Comment #34
xjmActually changing the tag.
Comment #36
xjmPer discussion with @alexpott and @tim.plunkett regarding #2248151: Configurable plugins can not control instance-specific config dependencies, expanding the scope of this issue.
Comment #37
alexpottSo far the best documentation of configuration dependencies in the code base is https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Config%21...
Comment #38
xjmFrom #1808248-137: Add a separate module install/uninstall step to the config import process:
Let's add that to the scope here too.
Comment #39
Gábor HojtsyComment #40
xjmThe more I talk to people about their CMI implementations, the more I think this issue is critical.
Comment #41
jhodgdonOK, ... What do we need to do here? I've read over all the comments on this issue and I'm a bit confused as to what we need to do to finish this issue.
Comment #42
xjmWe need to document the entire config dependency system. We rescoped the issue to that in #36.
Comment #43
jhodgdonI realize that from the issue title. What I don't know is what the remaining tasks are, what has been done, and where it needs to be documented. :)
Comment #44
xjmhttps://www.drupal.org/node/2235409 is AFAIK all there is, and pretty much nothing in the codebase.
Comment #45
BerdirThe documentation should also cover #2260457: Allow config entities to remove dependent configuration keys when dependencies are deleted due to module uninstall, which just got in.
Comment #46
Gábor HojtsyHere is a substantial update. May or may not be entirely true :) Tried to build in the suggested stuff. I am not really clear on the soft-ness of the dependencies at different stages. As per @Berdir's issue it seems like the dependencies are quite hard (setting aside the new onDependencyRemoval()), but for installation, they are certainly very soft (ie. a view may depend on fields that are not even on the system as is currently for several core shipped views in the standard profile).
Interdiff vs. #28.
Please review.
Comment #47
jhodgdonHm... A couple of concerns with this documentation:
a) I found this paragraph really difficult to understand:
Either the first two sentences say it all (in which case omit the rest), or ... well I couldn't understand the rest, no idea what other information it was trying to give me.
b)
I don't understand why this is talking specifically about system menu blocks, without saying "for example" ... or are they a special case for some reason that I think isn't explained (at least not in this patch)? This patch is going into Drupal/Core/Config/Entity/ConfigDependencyManager.php, not a class that is specifically for system menu blocks...
c)
Nitpick: Please don't use "eg." or "ie.". For one thing, the proper punctuation is "e.g.,", and for another, nearly no one understands the difference between e.g. and i.e. (you wouldn't believe how many issues with this I review/commit), so it's really just better to write it out as "for example" and "i.e." as "that is". Much clearer.
d)
This paragraph comes just after the explanation of the onDependencyRemoval() method, but ... it doesn't seem relevant, or else if it is, it needs to explain more. Are the entity displays implementing this method, or the widgets/formatters? Why not just let the standard removal process do this?
Comment #48
Gábor Hojtsy@jhodgdon: thanks for the review!
a) I would at least keep the first 3 sentences. While we can assume people reading this already understand module dependencies (and leave off the submodule example), I did not make that assumption and instead put it into perspective with an example. If you think you'd rather not have that example it is fine. I think the third sentence making it clearer that the containing module needs to have dependencies should be kept.
b) Should have used "For example" with the menu block. That is the only implementation in core right now, but may not be later on :)
c) Makes sense.
d) Erm, if you believe the standard removal process would work, then this example is not good enough yet. It is meant to explain that the standard removal process would remove all dependents entirely and this solution is to do removal of partial config as appropriate. Eg. if you remove a field, the whole entity display should not be removed (even though it depends on the field), but instead the field should be removed from the entity display. That is what this capability is about. What do you suggest, how should we get that through?
Comment #49
jhodgdonI got together with Gabor and Berdir in IRC and ... well, here's a new patch that hopefully clears things up a bit. Please check for accuracy and completeness!
As one note, ConfigEntityBase::addDependency() didn't have any docs -- the inheritdoc wasn't working because it was not technically an override of the trait method (the trait method was used with an alias). That is why I substituted that doc block.
Comment #50
BerdirThe example was there before, but it is wrong.
field storages don't care about node types/bundles. There is no dependency between them.
If you wanted a nested dependency examle then say that node types are created before their fields and both before their view display configuration.
What exactly is meant with "field module" the module that provides the field type? (field is usually used for an actual field).
Maybe field type module? Or split it up and first just talk about "depends on a certain field type", and later "declare a dependency on the module that provides that field type..." ?
This doesn't really make sense to me here (the config_dependencies part).
I think plugin dependencies should be a separate paragraph, and here it would just reference to that like "from plugin bags (see below... ) and .."
In there, I would say that plugins should define their dependencies either by putting it in the config_dependencies annotation key or by implementing ConfigurablePluginInterface::calculcateDependencies() so that config entities that use them can inherit the correct dependencies. If you want an example for all that, use blocks. The dependencies of blocks depend what kind of block (plugin) is used, a views block depends on the view (static annotatio key), another block plugin might allow you to chose what to display, resulting in a dynamic dependency.
Currently, uninstalling is the only thing that triggers this process, so "such as" is not quite correct. But we want to change there, there's an issue open somewhere to detect dependant config entities when config entities are deleted and allow to deal with them.
"node type configuration" is not really correct, we don't remove that. What we would remove is the view display configuration (which formatter to use for which field for a node type/view mode combination).
same, entity view display... ah, you have that below already
But still, node type configurations do not have dependencies on configurable fields.
If you want a second example, that would be third party settings. if menu_ui adds per-node-type settings using third party settings, then uninstalling menu_ui would delete that node type.
=> Which is I think not actually implemented right now, should we? If so, then that would kill the use case in #2224581: Delete forum data on uninstall.
Comment #51
jhodgdonThanks for the review in #50!
I think I've addressed all the points... Except #4, which I decided (since there could be more cases coming, and I don't think it's too confusing to have it there even if there aren't) to leave the "such as" in there.
Here's a new patch.
Comment #52
jhodgdonI just checked and this patch still applies cleanly. It's a critical but docs-only issue -- just needs a review...
Comment #53
Gábor HojtsyLooked through the cross references and read the after-patch version. I think the improvements are great. Thanks!
Comment #54
alexpottI think we can refine to make the language a bit clearer.
EDIT: for clarity
Comment #55
alexpottPerhaps something like this.
Comment #56
Gábor HojtsyThanks. Found some grammar issues at least in my reading.
an extension vs. "modules, etc" no matching plurality
entity's no?
either "implementations of" or "an implementation of" no?
Comment #57
jhodgdonUmm... That patch has a LOT of stuff in it that is not related to this issue. Plus some minor copy editing issues (serial commas, possessives/plurals, etc.). Otherwise, very nice, thanks!
I rerolled it by going back to #51 and applying the interdiff. Then fixed the copy editing stuff. New patch attached.
[looks like I found/fixed the same things Gabor found, plus a couple more]
Comment #59
jhodgdonThis triggered a (known, critical issue) random test failure. Retesting.
Comment #61
alexpottThanks @jhodgdon for fixing up my patch :)
Comment #62
Gábor HojtsyGreat fixes :)
Comment #63
jhodgdonI guess both alexpott and I worked on this patch, so someone else should commit...
Comment #64
webchickOn it! :)
Committed and pushed to 8.0.x. Thanks!