Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
21 Nov 2011 at 03:40 UTC
Updated:
13 Oct 2012 at 18:35 UTC
Jump to comment: Most recent file
Comments
Comment #1
sven.lauer commentedThis one was rather quick.
I had to get creative with the various Form/Render API callbacks, though. Generalizing from the new callback standards, I went with "#property callback: ..." for the introductory line (e.g. "#process callback: ...").
Comment #2
jhodgdonHm. I am not sure I like that:
All of our other callback terminology uses plain English rather than coder-speak (e.g., Access callback not 'access callback' as in hook_menu()).
The rest looks pretty good. A few things to fix:
a) Typo (form->from):
b) This should have a form function name instead of description:
(should say Form submission handler for form_function_name(), or Form submission handler for upload and remove buttons on form_func_name() or something like that).
c) Typo (handler misspelled) plus form function instead of description:
d) Verb tense (saves not save):
e) Typo (retrieves):
That word is misspelled several other times in your patch.
Comment #3
sven.lauer commentedAttached patch straight-forwardly fixes (a), (d), and (e, I think I caught all of those. At least the ones that had the same misspelling).
For (b), I went with:
Seeing as it is not really a submit handler for the whole form, but rather for the file field specific stuff---which should be mentioned in the summary line. Relatedly, I was not sure what to do with (except fixing the embarrassing "hanlder" typo):
so I left it as is for now. The problem is that there is no single form constructor where these are used---rather, they are registered by the #process function for file_managed form element types.
Also, I left the #-callbacks untouched until we resolve what should be done:
I think that "Element validate callback:" is quite unclear. Even as someone who knows about the #element_validate property, it is not immediately clear to me what this means. By contrast "Access/Title/Page callback" is likely to be familiar to anyone who ever implemented hook_menu().
Two suggestions:
(i) Don't mention that this is a callback in the summary at all, but include a line later, saying "This is assigned as a #element_validate callback in foo_bar()".
(ii) Have a generic "Render API callback: ..." as the summary, and include a line as mentioned above.
I think (ii) is better. Generally, the hope is that once we figure out a way to automatically document the #-properties, things like '#element_validate' can be auto-linked.
Comment #4
jhodgdonI like your suggestion (ii) too.
Regarding the "Form submission hanlder for upload / remove buttons of managed_file elements." -- thanks for the explanation. I agree it can be left as-is except for the typo.
Comment #5
sven.lauer commentedChanged all the "#foo callback: ..." lines to "Render API callback: ..." and added a line to the docblock saying where this is assigned and to what property.
Only remaining caveat: I've changed all of those to "Render API callback: ..." though many of these would be considered Form API callbacks, if one makes such a distinction. There does seem to be a building consensus, however, that Form API really should be seen as subset of Render API (and, after all, all forms go through
drupal_render() at the end, so the form specific stuff that is done prior to that can be seen as preprocessing the elements for rendering).
However, if people disagree, I could change those to "Form API callback: ...".
Comment #6
jhodgdonLooks pretty good! I like how those element validate callbacks are documented -- seems very clear, and points people to where the items are being used/defined/added to arrays. Excellent!
So I gave this a thorough read-through, and found a few typos -- it's pretty close!
a)
parse -> parsed
b) Probably the word "multiple" is redundant here:
+ * Tests upload and remove buttons for multiple multi-valued File field.
c) Verb tense on 2nd clause (do -> does, and there should be an "and" after , too):
+ * Tests the file extension, do additional checks if mimedetect is installed.
Comment #7
sven.lauer commentedFixing these, but:
(b)
The "multiple is in fact not redundant, as the test creates two multi-value fields and tests those:
But, of course, that means that it should be "multiple multi-valued File fields" (not "field").
(c) With "and" and "does", this went over 80 characters ... but looking at the test, I actually don't see any additional, mimedetect-dependent tests. So I just changed this to "Tests file extension checking."
Comment #8
sven.lauer commentedComment #9
jhodgdonJust a thought: multiple multi-valued --> several multi-valued -- might be more readable?
Comment #10
sven.lauer commentedHm ... I agree that "multiple multi-value fields" is not the finest prose, but "several" tends to get a "specific" reading in English ("There are several multi-value fields. This functions tests those."), which is not what is meant here.
I tried variants of "multiple file fields with multiple values", but could not fit those into 80 characters.
Comment #11
sven.lauer commentedOh, and:
Should we make this a standard? Between our (newish) standards for callbacks that get directly passed to functions, menu and form callbacks, and hook implementations, this would close a gap (and this way of documenting those is most likely to be forward compatible to whatever gets decided in #100680: [meta] Make API module generate Form API documentation.
Comment #12
xjmI guess the only thing is that the patch uses "Render API callback" generically for any Render API property, whereas for menus we're naming the specific type of callback it is (access, ajax, page, etc.) I agree we should probably add it to our docs one way or another. It's not so much a separate standard as a special case of the other.
Comment #13
jhodgdonPage/access callbacks are callbacks from hook_menu(), whereas these are callbacks for things related to elements, so I don't think there is a conflict? Not sure how to word this standard...
Comment #14
xjmWell, not so much a conflict as just an inconsistency. In both cases, the callback is automatically called when it is set in a certain array key (for the
hook_menu()array or the render array, respectively.) Either is fine by me really; we''d just need to change a couple "Pre-render callback: " to "Render API callback" in other patches.Comment #15
jhodgdonSo... I'm not too concerned about this conflict or lack of standards actually. I think calling something a "pre-render callback" is pretty clear, and the docs that Sven did above calling it "render API callback" and in the next line explaining exactly what it is are also pretty clear. I am not convinced that either way is necessarily better, or that they all need to be exactly the same across Drupal.... Do you think we need to adopt a definite standard for this?
Comment #16
jhodgdonMeanwhile, the patch in #7 looks good. :)
Comment #17
sven.lauer commentedHm, I was thinking of making this a standard for the sake of consistency. If some (many) functions use the "Render API callback: ..." + separate specification format for #pre_render callbacks, this might well lead someone to think that "Pre-render callback: ..." must means something else.
I like the "Render API: ..." format a little better, as it is more explicit (and also specifies where the callback is assigned). At the same time, #pre_render (and #post_render, #theme, #theme_wrapper callbacks) are special, as they are invoked by drupal_render() itself---meaning (a) that these properties always work and (b) that there is no specialized function invoking them. So it might make sense to (optionally) document these with a more menu-callback-like pattern. In any case, I think that, ideally, these should get an @see drupal_render() (and an @see to the function assigning the callback, if it is not mentioned in the doc text).
Comment #18
xjmYeah, I agree with pretty much every point in #17.
Comment #19
jhodgdonOK. Can one of you please file a separate issue on the standard and write up a proposal for what it should say? Thanks!
Comment #20
catchLooks good. Committed/pushed to 8.x. Thanks!
Comment #22
xjmWith the render and menu callback stuff removed. The name of the CSS file had also changed.
Comment #23
jhodgdonThese changes all look fine for D7, assuming the test bot agrees. Thanks!
Comment #24
webchickLooks great, thanks!
Committed and pushed to 7.x.
Comment #25
jhodgdonFollow-up: I just noticed a typo in the patch that was committed to 8.x (and probably 7.x). This line from file.field.inc:
* Render API callback: Validates the maximum uplodad size field.
uploadad -> upload
Comment #26
jhodgdonComment #28
hansyg commentedPatch for fixing typo from #25
Comment #29
hansyg commentedComment #30
xjmThat looks good. Thanks @hansyg!
Comment #31
jhodgdonI committed the patch in #28 to Drupal 8 - thanks hansyg!
7.x does not appear to have this typo, so I'm marking this back to fixed.
Comment #33
lars toomre commentedFor reference, I created a follow-up issue #1811674: Further clean up of API docs for File module.