Closed (fixed)
Project:
Documentation
Component:
Documentation in CVS
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Dec 2007 at 22:42 UTC
Updated:
6 Jan 2008 at 23:24 UTC
Jump to comment: Most recent file
To complete this task, review Drupal core, find the global variables, declare them in a PHP file and add doxygen to each of them. The file will be similar to the existing core hook documentation. The comments themselves will be similar to the Doxygen of core constant defines.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | globals.php_.txt | 4.98 KB | boombatower |
| #12 | globals.php_.txt | 4.83 KB | boombatower |
| #12 | getGlobals.php_.txt | 2.5 KB | boombatower |
| #6 | global-variables.php_.txt | 32.06 KB | boombatower |
Comments
Comment #1
webchicksubscribing
Comment #2
boombatower commentedWhat I currently understand the task to be:
Do I modify doxygen to global variables that already have commenting?
A specific question: Is the following considered sufficient for variables such as the one below or should each individual define have documentation?
Comment #3
webchickNote: this is chx's task so he has final say over this, but I'll answer to the best of my knowledge to get you going...
Yep, that sounds about right! Bear in mind that we also want to document any functions referenced as globals, so searching for "global " in the source code should give you a nice list ($user is one, for example).
If they don't make sense or are inaccurate, then sure! Otherwise I think you're ok.
Nope, each one should have its own doxygen block. You'll notice this looks really odd at http://api.drupal.org/api/constants?page=3.
Nice first catch. :D
Comment #4
boombatower commentedBy that you mean global instances of objects that functions can be called on and global variables such as $batch?
Comment #5
chx commentedThe WATCHDOG defines are constants not variables and by now all constants have doxygen I think -- but anyways, this task is about the globals. What webchick meant is that you want to search on the "global " keyword in any function, that will find you the global variables.
Comment #6
boombatower commentedI have already complete the task as I understood it to be. If this is not what was intended then we can work on getting the intended issue completed.
I went ahead and grouped all the constants using doxygen grouping syntax that provides a nice look in the documentation. When grouping I cleaned up some of the redundant information by putting it once in the group description. I also comment a number of constants that I was able to find and understand their purpose clearly enough to write documentation.
Here are some of the things I found:
I hope that my work can be of some use and that we can get this misunderstanding cleared up.
I see that the term variable was used instead of constant and thus my work is probably not what was intended.
Comment #7
add1sun commentedMarking for review.
Comment #8
chx commentedConstants are not variables. What we wanted here was to find every variable that is prefixed with the
globalkeyword, defining it as a variable in the global scope. After finding them, document them like this:This is an example of what we have thought of.
Comment #9
darren ohI'd like to add that searching for the keyword global may not get you a complete list. The global keyword provides a way to set global variables from within functions, but any variable set outside of a function is global.
For example, many global variables are set in settings.php. These already have documentation blocks which aren't recognized by the API module, so the exact format of the documentation must be very important.
Besides settings.php, any .php file in the Drupal root directory, the .inc files in the includes directory, and the .module files in the modules directories should be checked for stray globals (globals set outside of functions) that someone may have stuck in there.
Comment #10
boombatower commentedI understand the difference between constants and variables since I have done quite a bit of programming and work with PHP. I misunderstood the issue. I see now that it describes documentation of the global variables and not constants.
Not sure how you wish to proceed.
Comment #11
webchickboombatower: What we need a .php file that basically looks like this: http://cvs.drupal.org/viewvc.py/drupal/contributions/docs/developer/hook... but with each global variable (not defines) documented in Doxygen, rather than functions. Basically it would look just like chx's reply in #8, but with all of them, rather than only one.
If this still isn't clear, please post back with specific questions and we'll try and get you on the right track.
Comment #12
boombatower commentedI have attached documentation of the global variables instead of constant defines. I was not a 100% sure on some of the variables so there may be a few changes that need to be done. I also was not sure if you would like documentation in other places moved into the global comment blocks instead of referencing it. An example:
I created a script to find all variables accessed with the global keyword. The script checks for duplicates and creates a blank globals.php file with stubbed out comment blocks. I realize this will not necessarily get all the global variables, but short of searching every file this is the most reasonable list I can come up with.
I hope this is what you were looking for.
Although my previous submission is not what you were looking for I did group the constants that made up enumerations so that the doxygen groups them. I also added documentation to a number of undocumented constants. Not sure if this is of any interest to you.
Comment #13
aclight commentedThis looks like it's closer to what chx proposed in the original task. I'm setting the status as needs review to get more eyes on this.
Comment #14
darren ohTo find the global variables which are not accessed with the global keyword, I would recommend the following process:
Comment #15
boombatower commentedI got the following result:
As it says at the top of the attached globals.php file my code found 44 global variables. The $GLOBALS array contains 36 which include some of the PHP system variables.
The only variable that I did not have is return. I am not sure what the function of that variable is and whether or not you wish to have it documented.
Comment #16
chx commentedNo need, while D6 accesses some without the global keywords, we instance them all via global. So far, extremely nice work, congratulations.
$update_mode:The $update_mode variable is set by update.php and disables calling hook_boot and hook_exit because we do not want any hooks to fire during update when the database is in a largely unknown state. The "Allow modules to react to the end of the page request before redirecting." refers to the hook_exit invocation, the "We do not want this while running update.php" is the comment for update_mode.
$profile"The name of the currently active profile." I would change this to "install profile" to avoid confusion.$themeI am fairly sure this is the name of the current theme and not an object.You see it's set to garland if nothing else is available. Why we have a different named variable
$theme_keythen, containing the same value? This I can not answer, I fear this is an oversight from three years ago which noone has discovered until now, so thanks :) The confusion about theme being an object surely comes from _init_theme which should use$theme_objectinstead of$themeas this$themelargely differs from the global variable. But, as you go on you document$theme_infobut please add @ to the see there.global $multibyte, you list UNICODE_ERROR, UNICODE_SINGLEBYTE, UNICODE_MULTIBYTE without a word, these are, I guess the possible values.global $itemused by many convenience functions? I can't remember the global $item used outside of the aggregator XML parser, but feel free to correct me. It'd be great if you'd change all theglobal $item, $element, $tag, $items, $channelto refer to the XML parser of aggregator.$menu_adminyou write "admintrator", please fix -- I checked and we will need to fix menu.admin.inc, congratulations for finding minor a core bug :)Once again, fantastic work, quick turnaround, I also try to give speedy replies. Also see my blog post praising it.
Comment #17
boombatower commentedI have made the requested changes. Please review them to ensure that I made the correct changes.
Notes:
$theme- I originally had it as the name, but then I became unsure after i read_init_theme()as you said.$multibyteI was unsure what words to use and thus I guess I left it for later and never fixed it. I addedPossible values:$item, $element, $tag, $items, $channel- yeah I misread some functions. sorry about that. Also not sure how you want me to link to XML parse so I just link to the starting callback function.Comment #18
chx commentedIf noone does, I will commit this to the repo in the morning and edit index.php accordingly. Thank you so much, this is just fabulous.
Comment #19
merlinofchaos commentedI think chx is right about $theme_key being a leftover from the days when $theme was expected to be an object. $theme is definitely the name of the current theme. $theme_key is the same thing.
Frankly we shouldn't be using these globals at all, but using something a little more robust; at the very least, we should be using only *one* global. When Drupal 7 comes around I'll try to work with dvessel to clean that up; it's something that didn't get changed in the last theme system overhaul because I didn't want to figure out where all the globals were used while doing everything else.
Comment #20
chx commentedI think Merlin crossposted me.
Comment #21
chx commentedhttp://drupal.org/cvs?commit=90999
Comment #22
lilou commentedThe link http://api.drupal.org/api/group/globals/6 in api front page doesn't work.
Comment #23
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.