Problem/Motivation
New developers, learning how to code using Drupal "the Drupal way", often struggle to grasp the concept of render arrays. A large component of this is in my opinion, that render arrays often have their type documented, but there is no list of render array keys available. This leads to developers relying on posted questions and solutions on other platforms such as StackExchange, or guides solving a particular problem (if there is any guide at all), instead of consulting the documentation and trying to find the best way to solve the problem.
Steps to reproduce
Documentation of render array types (for example "File") can be found on their classes, if available. Examples:
Proposed resolution
All the possible render array keys (also the default ones like #title
and #description
) should be listed and described in the first part of the documentation.
On the File class, there are two out of seven possible render array keys listed and described. On the ManagedFile class, there are none documented. There should be at least every render array key listed in the description section (like on the File class) with a quick description on what can be achieved by defining this setting.
Additionally, a small section of code examples should also be included afterwards, so users see the logic and the syntax to define these setting.
The list of allowed keys could be based on public function getInfo()
which is implemented on these classes.
Remaining tasks
- List candidates for documentation changes (could be based on this list)
- Add said descriptions to the documentation pages
User interface changes
None.
API changes
None.
Data model changes
None.