Problem/Motivation
The documentation in Form API's EntityAutocomplete
class, of what properties are allowed in different configuration arrays, is difficult to find. Some properties are described in method docblocks; some on the class docblock; other docblocks are incomplete.
Proposed resolution
Rewrite inline documentation for EntityAutocomplete
and DefaultSelection
to clarify what property keys are permitted in config arrays:
* Move explanation of common config properties to class-level docblocks.
* Reference these in method level docblocks, to avoid duplication.
* Expand descriptions of properties where appropriate.
* Two classes to reference each other with @see
, to avoid duplication.
Remaining tasks
Approve this issue summary change.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#21 | reroll_diff_2807231_2-21.txt | 3.86 KB | ankithashetty |
#21 | 2807231-21.patch | 3.4 KB | ankithashetty |
#19 | interdiff_18-19.txt | 501 bytes | ranjith_kumar_k_u |
#19 | 2942657-19.patch | 1.53 KB | ranjith_kumar_k_u |
#18 | 2942657-18.patch | 1.53 KB | ranjith_kumar_k_u |
Comments
Comment #2
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commented@Tronux thanks for this. I think you're right, that the properties in the settings and element arrays being passed around aren't clear. There is actually documentation of
$element
properties on this class, but it's buried down in one of the static method docblocks. Also, the sub-properties of$element['#selection_settings']
are not clearly explained anywhere.Based on this ticket and discussion here https://api.drupal.org/comment/62553#comment-62553 , I attach a patch which modifies two classes:
EntityAutocomplete
$element
might contain, up to the top of the class, and improve method docblocks on the way. Reference the below class for more information of the sub-properties ofhandler_settings
.DefaultSelection
handler_settings
configuration, so these don't have to be documented in the previous.@see ...
so each class references the other.Feedback welcome!
Comment #3
kiwimind CreditAttribution: kiwimind at Investis Digital commentedThis all makes sense.
Having the
@see
references and moving thetarget_bundles
to the main body of the comment is very helpful.Thanks, RTBC.
Comment #4
cilefen CreditAttribution: cilefen as a volunteer commentedI'd like to see an issue title that describes the documentation deficiency and an issue summary that reflects the direction of the patch in #2.
Comment #5
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commentedLooking at this now.
Comment #6
jp.stacey CreditAttribution: jp.stacey at Magnetic Phield commented@cilefen thanks: you're right that the problem @tronux kindly originally reported, pointed away from the ultimate fix (it referenced a solution in another class, that was actually a red herring, just coincidentally describing the same config property.)
Out of interest, I see a few issue summaries beginning "Enter a descriptive title (above) relating to class EntityAutocomplete, then describe the problem you have found:" and they're often in need of a tidyup. Is that coming from a particular submission channel? I don't know if that could be improved to get better summaries from reporters, or whether that would be intimidating; maybe a summary that needs tidying is better than no summary at all.
Anyway, I've used the standard issue template to reword the description now, and redrafted the title. Would appreciate a re-review.
Comment #17
baikhoComment #18
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedRe-rolled from #2
Comment #19
ranjith_kumar_k_u CreditAttribution: ranjith_kumar_k_u at Zyxware Technologies commentedComment #20
joachim CreditAttribution: joachim as a volunteer commentedThe most recent patches are losing a lot of the changes from patch #2.
Comment #21
ankithashettyHere is the rerolled patch from #2, thanks!
Comment #24
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
Documentation change looks like a good improvement.
Comment #25
quietone CreditAttribution: quietone at PreviousNext commentedAlways nice to see documentation improvements.
The first thing I noticed in this documentation was a double space. Then, I thought 'handler_settings' should be in quotes but then, as I read this, I think we can do better here. The descriptions should start with what the key is for, not the default value. And the reader should know what keys are required and which ones are optional, using the standard format. It is easier to express my ideas by example so I made a suggestion.
There is still work to do here. The text '(?)' needs to be replaced with (optional) or (required). And, maybe the description for target_bundles needs a tweak as well. It is not obvious why the two phrases are in double quotes.
See Making lists in documentation
Comment #26
joachim CreditAttribution: joachim as a volunteer commentedtarget_bundles, sort, auto_create, auto_create_bundle are optional, since they default to something in defaultConfiguration().
> * - sort: (?) An array of sort parameters. Default to ['field' => '_none'].
We should say it's an array containing 'field' - the field name to sort on and 'direction' - one of ASC/DEC.
Also, auto_create_bundle MUST be specified if auto_create is TRUE.