This meta issue is to help bring Drupal's core code into compliance with the Documentation Standards around the subject of lists (and arrays).
A list is one or more items. In the context of arrays that may be passed to or returned from functions and class methods, some of these elements of the array may be designated as 'optional', while others may be 'required'. Over time, Drupal's Documentation standards regarding lists, arrays and some associated issues have evolved. Partly as a result, numerous Drupal core files presently are inconsistent in their application of these list (array) documentation standards.
This documentation clean-up effort is ocurring in parallel to (but purposely separate from) the 2011 API documentation cleanup sprint. The intent of all is to ensure more consistently (and hopefully better) documented core code for Drupal. Please free to help out with any of the sub-issues listed below or in 2011 API documentation cleanup sprint!! There are sub-tasks for all ranges of experience from Novice to the most advanced.
Examples of malformed list documentation
These issues are listed by ease of resolution and hence those listed earlier have a higher priority (like a weight variable).
-
The documentation list item is indented one, three or four spaces instead of the standard two spaces.
-
In numerous instances, the description of keys for associated arrays use the list patterns \ -'key': \ or \ -"key": \ instead of the standard pattern \ -key: \.
-
The documentation of lists within doxygen blocks throughout core are used primarily in two contexts:
- $options associative arrays [which themselves are often '(optional)'] that are passed to functions and class methods, and
- Associative arrays returned from a function or method.
Some of these associative arrays have elements that are '(required)' and others that are '(optional)'. However, core files are inconsistent in the application of these terms. Examples here include 'Required.', 'Optional.' and 'Optional ...' instead of the documentation standard.
- No standards yet exist for how the variable type for the 'value' portion of a $key => $value pair is to be documented. As a result, the exisitng code documentation is wildly inconsistent and often missing altogether. See issue #XXXXXXX for more detailed discussion about what the 'best-practice' for this type of list documentation should be.
- Further searches through the code base for the term \optional\ reveals the other context in which that phrase is used: the specification of optional variables in calls to functions and class methods. Sometimes '(optional)' is well formed. Other examples include '(Optional)', 'Optional language ...', and so on.
- Approaching the issue of documenting 'optional' variables from the other direction (e.g., looking at the function defintion itself first and then its documentation), it appears that perhaps as many as half of all optional variables in calls to functions and class methods are not presently documented as such.
- Finally, only within the last few weeks was issue #711918: Documentation standard for @param and @return data types adopted. Already some @param and @return directives with lists within them currently include variable type hinting. The majority do not. In due course, these need to be added, reviewed and committed.
This issue arose as a side issue to #1310084: [meta] API documentation cleanup sprint in #1315886-42: Clean up API docs for includes directory, files starting with A-C. It is not per se part of the narrowly focused API documentation cleanup sprint, but closely related.
Some of these list issues are can be fixed via easy to review 'bulk' patches that require only looking at the patch file itself. Other portions of this meta 'list' documentation focus require both a reviewer and committer to focus on not only the patch itself, but also the application of the patch to the code file (so that one can confirm the accuracy of @param and @return directives). These second type of patches require far more concentration and time. As a result, these latter patches should be smaller in size to facilitate patch creators, reviewers and commiters.
Note: The last item on the above list is the lowest priority and any patches that include variable type hinting will not be backported to D7. Further, variable type hinting patches require careful review of both the documentation and the function itself. Hence, these type of changes are probably not suited for Novices.
Remaining general tasks
- Define how variable types in the values of an associated array should be documented.
- Ensure that the above documentation is addressed in Documentation standards
- Other tasks to be determined.
Sub-issues with easy patches
-
#1333534: Further cleanup for documentation in core/includes files starting with A-G
-
#1333538: Further cleanup for documentation in core/includes files starting with H-Z
-
Big patch for all of the *.api.php changes - No issue yet
-
Files for entity and field stuff ... - No issue yet
-
Files for image module. - No issue yet
- Interweaves with docs-cleanup-2011 sub-issue #1326608: Clean up API docs for image module
- Rest of module * changes - No issue yet
Sub-issues with more focused patches
-
#1331534: Lists Documentation: Insert '(optional)' and like in locale and node modules. - Interweaves with other sub-issues:
- '(optional)' phrase in bootstrap.inc - No issue yet - Interweaves with docs-cleanup-2011 sub-issue:
- '(optional)' phrase in common.inc - No issue yet - Interweaves with docs-cleanup-2011 sub-issue:
Lowest priority sub-issues (with patches for variable type hinting)
Related issues
User interface changes
None.
API changes
None.
Comments
Comment #0.0
lars toomre commentedAddition of sub-issue #1310084.
Comment #1
lars toomre commentedAdded a cross-reference to #1333470: Variable Type Hinting for common.inc file which is a work in progress patch about variable type hinting to large file common.inc.
That was created as a part of breaking out issues from my mega lists branch patch.
Comment #1.0
lars toomre commentedAdded cross-reference to #1333470 - Variable Type Hinting for common.inc file
Comment #2
lars toomre commentedAdded a cross-reference to #1333474: Variable Type Hinting for bootstrap.inc file which is a work in progress patch about variable type hinting for the key file bootstrap.inc.
That was created as a part of breaking out issues from my mega lists branch patch.
Comment #2.0
lars toomre commentedAdded cross-reference to #1333474 - Variable Type Hinting for bootstrap.inc
Comment #2.1
lars toomre commentedAdded cross-references to #1333534 and #1333538.
Comment #2.2
lars toomre commentedAdded cross-reference to #1310854.
Comment #3
lars toomre commentedAdded a cross-reference to #1330854: Update code to conform to literal array standards. That issue addresses some of the long code lines tied to 'lists of values' arrays that are in the Drupal core.
That issue has resulted in sub-issue #1333396: Re-factor a few very long code lines. to re-factor 20 long code lines in common.inc and image.effects.inc.
Comment #4
lars toomre commentedAdded cross-reference to sub-issues #1333534: Further cleanup for documentation in core/includes files starting with A-G and #1333538: Further cleanup for documentation in core/includes files starting with H-Z for that fixes the 'easy' stuff lists documentation in /includes directory.
The intention of these patches is that they should be easy to review without needing to look at the resulting patched code files. It also designed to only include changes that might be acceptable for backport to D7.
Comment #5
xjmI'd also suggest waiting on a file or group of files until the sprint patches for those files are actually committed, to reduce the need for rerolling them.
Comment #6
jhodgdonYou can't make separate issues for variable types for every file. This falls into the category of "mega-patch", and the Drupal branch maintainers have requested that mega-issues be split up into pieces like I did for #1310084: [meta] API documentation cleanup sprint. Not one issue per file.
Also, as we discussed before on the issue where those standards were adopted, I wouldn't advise starting that initiative until you've recruited some people to make and review the patches. I personally don't have time to participate and/or review them, due to other Drupal volunteer commitments. Sorry.
Comment #7
lars toomre commentedThanks for #6 @jhodgdon. I also don't believe there needs to be a separate patch for each and every core file. However, bootstrap.inc and common.inc are fairly large files on their own right, and will require time to review. (Same might also be the case for menu.inc and form.inc which both also are rather large on their own right.)
When I had the power outage last week, I went through and did the initial heavy-lifting of variable type hinting in both of those files. Rather than just throwing the work away, I thought it made sense to move those changes into their own patches so that they might get reviewed and committed at some point.
I appreciate you will not have the time due to other Drupal volunteer commitments. Thanks for all of your help in what you do!
Comment #8
lars toomre commentedI also just submitted an 'easy' list formatting patch covering /includes A-G over in #1333534: Further cleanup for documentation in core/includes files starting with A-G .
Comment #9
alan d. commentedI can programmatically fix 380 quote issues fairly easily, see #1310084: [meta] API documentation cleanup sprint for details. This covers the entire Drupal code base, which may not play nicely with the individual issues related to the code clean up. Either way, the regexp can be used by anyone to quickly find, compare and replace the list quotes.
This is a pure |- "abc":| to |- abc:| conversion only.
Comment #10
jhodgdonSo... I guess I didn't think about this idea completely yesterday.
We definitely want no quotes (single or double) for array key lists, which are most of the lists we have in Drupal core docs. However, there are cases where we would want quotes, such as when it's a list of literal string values that could be passed to a function. So running this regexp replace is probably good, but we'd still need to check over the result and make sure all the quotes are ones we want to remove.
Does it do double quotes too?
Comment #11
alan d. commentedBoth single and double. The biggest thing that I'm worried about is mucking up peoples existing patches in the queues. I do not know how active these issues are.
Comment #12
jhodgdonGood point. It may make sense to wait until most of the existing meta-issues on the "cleanup" issue are done. I think that was the idea here for more manual fix-ups too, anyway.
Comment #12.0
jhodgdonCorrected cross-reference to #1330854.
Comment #13
jhodgdonAt this point I think I'll just close this meta. 4 years means the issues it was referencing are probably either fixed or there are new issues. It's also too broad in scope.