Problem/Motivation
All related plugin classes and interfaces for a plugin type need to be linked together in documentation, so that developers can discover how to make that type of plugin. Also, there should be a link to the plugin_api topic in their documentation headers, which tells how to make plugins in general. (See #2269389: [meta] Make sure plugin developer info is discoverable for discussion, if interested.)
For any plugin type, here are the classes and interfaces that need to be located and linked together:
- The interface for the plugin (if there is one -- most plugins have one)
- The base class for the plugin (if there is one -- most plugins have one)
- The plugin manager class
- The annotation class
Developers also need to know the plugin namespace that plugin classes have to be put into, in order to be recognized.
And it would be helpful for them to have a link to one working example of a plugin.
Proposed resolution
This issue is for: The Archiver plugin type.
The specific tasks to be done:
a) Locate the annotation class, interface, base class (if there is one), and plugin manager class for this plugin type. Find a working example class too. And figure out what the plugin namespace has to be. There are notes below on how to do this.
b) Make sure that all these classes and interfaces are linked together with @see links or are mentioned in each other's documentation headers. Example of a @see link:
* @see \Drupal\foo\bar\FooBarPluginInterface
c) Make sure that all of these classes and interfaces have:
* @see plugin_api
in their documentation headers.
d) Make sure that the annotation class documents the plugin namespace like this:
* Plugin Namespace: Plugin\Foo
e) In the Annotation class, also put in a line linking to the working example:
* For a working example, see \Name\Of\Plugin\Class
Remaining tasks
See Proposed Resolution.
Note:
All of the added lines should go into the class or interface documentation block, meaning the documentation immediately before the class/interface declaration:
/**
* (This is the interface documentation block/)
*/
class WhateverInterface extends Plugin {
Plain text lines like "Plugin Namespace: ..." should go before any @see or @ingroup lines, and the @Annotation line has to come last in any docs header.
Some notes on how to do this
You can find the annotation class on
https://api.drupal.org/api/drupal/core!modules!system!system.api.php/gro...
To find the a working example, look for a class in the Drupal Core code base that is annotated with the annotation class (using grep). For instance, if the annotation class is "Foo", search for a class that has "@Foo(" (without the quotes) in its documentation header.
Once you have located a working example, look at its class hierarchy (you can do this easily on api.drupal.org). It will most likely be extending a class called something like "FooBase", which would be the base class, and FooBase will most likely be implementing an interface called something like "FooInterface", which would be the plugin interface.
To find the manager class, take a look at the "Expanded class hierarchy of DefaultPluginManager" page:
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Plugin!DefaultPlu...
Look for a class there called FooPluginManager or something similar.
Once you have found the manager class, look at its __construct() method. It will call parent::construct(), passing in the annotation class and the plugin namespace. Verify that the right annotation class is shown, and take note of the plugin namespace is (typically something like "Plugin/Foo".
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#3 | drupal8-archiver-plugin-docs-2290253-3.patch | 1.68 KB | er.pushpinderrana |
Comments
Comment #1
er.pushpinderrana CreditAttribution: er.pushpinderrana commentedFor Archiver plugin class there is no individual interface but a common interface for all Archiver classes. I am not sure whether it need to be linked with plugin manager class and annotation class, in this patch not linked. Also for this plugin type, no base class found, so please review attached patch and share your thoughts.
Comment #2
jhodgdonThanks!
I agree, I do not see a base class either.
I agree that ArchiverInterface can be used for non-plugin classes, but I do not think it is bad to link it to the Archiver annotation and manager, and put the reference to plugin_api documentation in it either. Most people who would use this interface should be making plugins.
So let's go ahead and add the links to/from the interface too. Thanks!
And:
These two lines need a blank line between them.
Comment #3
er.pushpinderrana CreditAttribution: er.pushpinderrana commentedAdded. Please review.
Also given blank line.
Comment #4
jhodgdonThanks, looks good now!
Comment #5
jhodgdonThanks again! Committed to 8.x.