Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
documentation
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
26 Jun 2015 at 08:51 UTC
Updated:
28 Oct 2015 at 21:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jhodgdonAgreed, should document that $variables['options'] needs to contain at least 'attributes' and 'html' keys.
I cannot figure out where this is in D8 to see if we need to document it there, but I guess not.
Comment #2
dorficus commentedComment #3
dorficus commentedI added more description and changed 'options' key to 'options' array and what it contains.
Comment #4
dorficus commentedComment #5
rukayya commentedalso should add 'language' in $variables
Comment #6
dorficus commentedI was going off of the results from a
dpm($variables). Is 'language' a key or an array of its own?Comment #7
jhodgdonHm.
So... I think we should only document here the parts of $variables that this function actually uses and needs. I also think that we shouldn't reproduce documentation elsewhere.
Looking at the code for this function, the parts of $variables that it uses directly are:
- path
- text
- options
-- options['attributes']
-- options['html']
And then it also passes options into the url() function, so let's say that in the docs rather than trying to list everything that url() might use in options. And let's not document other things that might be present in $variables that this function doesn't actually use -- there is a lot of stuff that gets passed to theme functions from the standard preprocessing, but we don't want to document it unless the function actually needs it (plus, it's not stuff that the user of this theme hook would normally need to provide).
Thanks!
Comment #8
dorficus commentedWould you recommend mentioning
@see url()along with the@see l()instead of duplicating the documentation for those functions?Comment #9
jhodgdonyes, sounds like a good idea.
Comment #10
dorficus commentedI added a little bit about the
url()functionComment #11
jhodgdonThanks! Looking better. A few thoughts:
I found this a bit awkward to read... How about something like this:
An associative array with elements 'text', 'path', and 'options', corresponding to the parameters to the l() function. The 'path' and 'options' elements are passed into the url() function to build the link, and in the 'options' array, elements 'attributes' and 'html' are used in this function like they are in l().
Remove blank line here. We normally bump all the @see lines together into one block.
Comment #12
dorficus commentedNow you're almost doing my job for me!
Comment #13
jhodgdonLooks good, thanks!
Comment #14
joachim commentedI'd really prefer it if that stated explicitly that these keys are required -- and the sub-keys in 'options', which is really something that's unexpected.
Would a nested list layout be clearer here too?
Comment #15
jhodgdonFair enough. Yes, a sub-list may be clearer, and saying explicitly that things are required is probably a good idea.
Comment #16
dorficus commentedLet's try it again.
Comment #17
jhodgdonThanks for the new patch -- it's pretty close! A few things to fix:
The list is indented two extra spaces. The - should line up under the text above it.
Also each entry should end in . according to https://www.drupal.org/node/1354#lists
um, "options" is not for "optional values", it's for the options for the l() and url() functions, right?
And somehow this patch lost the information saying to look at l() for documentation of what these things are?
This line is too long, but if you fix the indentation I think it will be OK.
Needs comma before "which".
Comment #18
dorficus commentedSince the options array is optional and defaults to an empty array in l() and url(), I put the optional tag at the beginning of the description. I also made the formatting and grammatical changes you requested.
Comment #19
jhodgdonI found this bit slightly jarring to read. The rest is all
- key: explanation
and this bit is
- explanation, maybe getting to the specific key at the end
So maybe the first two items in this array could be changed to be
- class: ...
- title: ...
And leave the "Others are... " item alone?
The rest of this patch looks great, thanks!
Comment #20
dorficus commentedHere you go.
Comment #21
jhodgdonMuch better, thanks!
But... I guess I didn't notice this before, sorry!
These should end in .
And technically... is path the URL of the link, really? I don't think so. Probably should check the url() function to see what this needs to be, or say something like "... as in the $path parameter to url()".
Comment #22
dorficus commentedI copied the description of $path from url() and changed it slightly to fit this function. "path: the internal path or external url being linked to."
Comment #23
jhodgdonThanks! I think this is very good now. Let's do it!
Comment #24
dorficus commentedOh frabjous day!
Comment #25
David_Rothstein commentedCommitted to 7.x - thanks!
Adjusted the following on commit to emphasize the security requirement a bit more (similar to how the documentation on l() does it):