Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sven.lauer’s picture

Status: Needs review » Active

None of the functions in color.module has any param / return value documentation. Created a separate issue for those, as specified in the instructions in #1310084: [meta] API documentation cleanup sprint:

#1332584: Add param / return value documentation to color.module

(Edited to fix reference to meta issue.)

sven.lauer’s picture

Status: Active » Needs review
FileSize
9.2 KB

Caveat about this patch: My editor killed extraneous whitespace on empty lines in two instances---is it okay to include this in the patch, or should I manually remove this?

jhodgdon’s picture

Status: Active » Needs work

Killing extraneous whitespace is always good, and doesn't make the patch harder to review, so go for it! :)

This mostly looks good. A couple of things to fix:
a)

+ * @file
+ * Attaches the behaviors for the color module.

Refer to modules either as "the Color module" (capitalized) or "color.module" (without "the"). The latter makes a link on api.drupal.org so is somewhat preferable in API docs.

b)

      * It is also symmetrical. If: shift_color(c, a, b) == d,
-     *                        then shift_color(d, b, a) == c.
+     * then shift_color(d, b, a) == c.

I think the word "then" can fit on the first line here, if you are going to rewrap it.

c)

+    /**
+     * Focuses the Farbtastic on a particular field.
+     */

I don't think "the" is good here.

d)

- * Helper for hook_form_FORM_ID_alter() implementations.
+ * Alters the system_themes form for the color module.

What is system_themes? I can't find that in a search on api.drupal.org. Please use the name of the actual form function if possible (and follow by () ). See also (a) above. Also, maybe this should have an @see to the function above that is using it as a helper?

e)

- * Callback for the theme to alter the resources used.
+ * Alters the resources used in the html template.

html -> HTML.

f) Also maybe this should have an @see to the function that is using this? If it's really a callback, follow the "callback function" guildelines in this section (scroll down):
http://drupal.org/node/1354#functions
And same for the next callback function.

f)

+ * Blends two hex colors and return the GD color.

return -> returns

g)

+ * Converts a HSL triplet into RGB.

a -> an

h)

/**
 * Test color functionality.
 */
class ColorTestCase extends DrupalWebTestCase {

This needs an update:
http://drupal.org/node/1354#classes

i)

   /**
-   * Test to see if the provided color is valid
+   * Tests if the provided color is valid.
    */

The original wording here was OK, but without "to see", the "if" in your modified line should be "whether".

sven.lauer’s picture

The attached patch fixes some of the issues, but not all. In particular:

d)

- * Helper for hook_form_FORM_ID_alter() implementations.
+ * Alters the system_themes form for the color module.

What is system_themes? I can't find that in a search on api.drupal.org. Please use the name of the actual form function if possible (and follow by () ). See also (a) above. Also, maybe this should have an @see to the function above that is using it as a helper?

Well, I just went by the name of the calling function. The function documented here is called only once, by hook_form_system_themes_alter() (just above in the same file). This is also the only thing that this function does, so really the documented function should just be that alter hook. And, as the name of the alter hook indicates, it alters the form with the form ID "system_themes" form.
Now it gets interesting: There is no such form. I THINK what this was supposed to alter was the page that is now available under "admin/appearance", which used to be a form in D6. So this tries to alter a form that does not exist anymore. Even more weird: Even in D6, there was no form with form ID "system_themes", there only was one with ID "system_themes_form". So it looks to me like this function has not done anything since at least D5.

I did not change anything about the doc header as I am at a loss about what to do.

e)

- * Callback for the theme to alter the resources used.
+ * Alters the resources used in the html template.

html -> HTML.

Are you sure? Note that this is the 'html' template, as in html.tpl.php or theme_html() so this is not a reference to HTML (the markup language), but rather a lower-case named theme/template.

f) Also maybe this should have an @see to the function that is using this? If it's really a callback, follow the "callback function" guildelines in this section (scroll down):
http://drupal.org/node/1354#functions
And same for the next callback function.

This is not QUITE a callback. Or at least, calling it that is somewhat misleading. The way I understand it, these two functions should be called by themes that want to be compatible with Color module, in the right place. Only Bartik is using these in core, they are called in bartik_process_html() and bartik_process_page(), respectively. Maybe we should @see these? And add a general comment that these ought to be called by themes? I am a bit hesitant about my interpretation, though, as it strikes me as odd that a function that should be called from outside the module would have a name starting with an underscore (though this might be simply to avoid having 'color_page_alter' to be taken to be an implementation of hook_form_alter()?)

[Edited to fix a weird typo where I wrote "settings_form" instead of "themes_form".]

sven.lauer’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

Ah.... let's see.

(d) - yeah, let's leave those functions completely alone for now and file a separate issue saying they are not being used and should be removed.

(e) - In that case, call it html.tpl.php directly (which will make a link to the file on api.drupal.org). If you want to use HTML in text as "the HTML template", yes it should be capitalized.

(f) - Ah, OK. So it was misdocumented as a callback in the original. I think adding an extra line to the docs saying something like "Themes can call this function to ..." would be helpful, yes. Putting an @see to the Bartik functions that call it is not necessary (on api.drupal.org, the list of calling functions is shown anyway).

I took a closer look at those functions. Maybe a better description would be:

(html function)
Replaces style sheets with color-altered style sheets.

A theme that supports the color module should call this function from its themename_process_html() function, so that the correct style sheets are included when html.tpl.php is rendered.

(page function)
Replaces the logo with a color-altered logo.

A theme that supports the color module should call this function from its themename_process_page() function, so that the correct logo is included when page.tpl.php is rendered.

sven.lauer’s picture

Status: Needs work » Needs review
FileSize
9.86 KB

Okay.

I adopted your suggestion (which makes (e) a non-issue), except that I referred to the functions as "THEME_process_page/html()" to be consistent with how we refer to these in the docblock for theme(). I added a @see theme(), as this is where the purpose of THEM_process_* is explained.

I also opened #1337198: Remove useless form_alter implementation re: (d).

xjm’s picture

A few files are still missing @file blocks. Other thank that, I think this patch is ready.

jhodgdon’s picture

Status: Needs review » Needs work

Regarding (d) from the discussion above -- let's not do *anything* to the docblocks for those function(s) that probably need to be removed. So this should not be here:

/**
- * Helper for hook_form_FORM_ID_alter() implementations.
+ * Alters the system_themes form for the color module.
  */
 function _color_theme_select_form_alter(&$form, &$form_state) {

While you're at it:

 /**
- * Form callback. Returns the configuration form.
+ * Form constructor for the configuration form for a particular theme.

This is probably just the color configuration form, right? The description here makes it sound like it's the whole config page for a theme, not specifically about colors.

And this needs a period at the end of the sentence:

+ * Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction
+ * delta then (return == target + (given - target) * delta)

And this needs an extra blank line between the @file docblock and the first function:

+/**
+ * @file
+ * Attaches preview-related behavior for the color module.
+ */
 (function ($) {
sven.lauer’s picture

Status: Needs work » Needs review
FileSize
398.4 KB

Fixing the issues mentioned in @jhodgdon's #9, and also adding the @file docblocks to the css files.

sven.lauer’s picture

Arg. Git is hating me today. Proper patch attached.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Read through the patch again and #8 and #9 have been fixed. Everything else looks correct as well.

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/color/color.admin.cssundefined
@@ -1,3 +1,7 @@
+ * @file
+ * Stylesheet for the adminstration pages of the Color module.
+ */

typo for 'administration'.

Otherwise looks great.

Discussed the comments for CSS and JS files here a bit with xjm. We strip comments for CSS during aggregation, but not JavaScript, so I bumped #352951: Make JS & CSS Preprocessing Pluggable to major.

11 days to next Drupal core point release.

sven.lauer’s picture

Status: Needs work » Needs review
FileSize
10.14 KB

Re-roll fixing the typo attached.

(I guess a point could be made for setting this directly back to RTBC, given that both xjm and catch said that the patch is good otherwise---but I am following protocol just to be sure.)

xjm’s picture

Sorry, missed this before:

+++ b/core/modules/color/color.moduleundefined
@@ -112,7 +128,7 @@ function _color_page_alter(&$vars) {
+ * Retrieves the color.module info for a particular theme.

+++ b/core/modules/color/color.testundefined
@@ -6,7 +6,7 @@
+ * Tests color functionality.

@@ -52,7 +52,7 @@ class ColorTestCase extends DrupalWebTestCase {
+   * Tests color module functionality.

Should this be "the Color module information"? (Functionality, etc.)

sven.lauer’s picture

Right, sorry for missing this before.

Attached patch fixes those.

xjm’s picture

Status: Needs review » Reviewed & tested by the community

Alrighty, re-RTBC. :)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xjm’s picture

Version: 8.x-dev » 7.x-dev
Assigned: sven.lauer » Unassigned
Status: Closed (fixed) » Needs review
Issue tags: +Needs backport to D7
FileSize
10.29 KB

Pretty much a straight reroll; just the names of the CSS files have changed in D8. No commit credit please. :P

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good for d7, thanks!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, d7-color.patch, failed testing.

xjm’s picture

Status: Needs work » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, thanks!

Committed and pushed to 7.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Lars Toomre’s picture

I opened up #1808178: Further clean up of API docs for Color module to address additional issues about bringing Color module closer to D8 documentation standards. Reviews there are welcome.