Problem/Motivation

Part of meta-issue #1310084: [meta] API documentation cleanup sprint

Proposed resolution

Correct the following in the core image module:

  • Ensure that all @return lines are preceded by a blank line.
  • Ensure that @see and @ingroup lines are always at the end of docblocks.
  • Ensure that all lines in doxygen blocks are 80 characters or fewer (excluding the terminal newline).
  • Ensure that all functions, classes, interfaces, and methods have one-line summaries that are clear, use the correct verb tense, and follow specific standards in http://drupal.org/node/1354.
  • Make incidental style and grammar corrections only to those docblocks already being updated.

Remaining tasks

Patch needs to be rolled.

User interface changes

None.

API changes

None.

Comments

lars toomre’s picture

Status: Active » Needs review
StatusFileSize
new79.97 KB

Attached is a first pass at bringing the image module up to Drupal 8 documentation standards. I relaize this patch will need to be re-rolled once the files are moved to /core. However, comments in the meantime are welcome.

While creating this patch, I encountered a number of questions which also may necessitate re-rolling this patch. My questions include:

  1. One of the path references for image_effect_form() results in a line greater than 80 characters. Any suggestions on how this should be adjusted to conform to a 80 character limit? The issue is also present in path for image_effect_delete_form().
  2. I have taken the approach in this patch that all page callback functions require a @return directive. I am not sure if this is correct. However, the approach does make clear how the page HTML-formatted text string is created.
  3. There are several functions in this module that return portions of an ultimate $form array. What is the appropriate way of documenting such form functions? The text 'Form constructor for the xyz form.' seems highly inappropriate.
  4. I am unfamiliar with the use of variable_get('x') (e.g. without the second parameter). Is this use case correct in image_style_url()?
  5. In the file image.effects.inc, there were a number of watchdog calls that were more than 300 characters in length. For clarity and better display, I reworked these lines of code into parts so that the maximum length of such lines is now approximately half of what it was.

Known issues requiring follow-up

  1. The function image_style_delete() always returns TRUE indicating a successful deletion operation. Surely there are conditions where this is not the case. This function needs to check the return values from db_delete() and return the appropriate boolean value.
  2. Same goes for image_default_style_revert(). It always returns TRUE.
  3. The variables type for $current_pixels and $new_pixels are not currently defined in image_filter_keyword(). While clearly intended to be numeric, there is a lack of definition on whether float or integer values may be passed in. Hence, there also is no clarity on whether fractional pixels may be returned for a a centering operation.
  4. There is an existing @todo item about missing tests for eleven functions in the image module. An issue needs to be created so that the appropriate test casess can be added.
  5. For clarity, should the text returned in ImageFieldTestCase::uploadNodeImage() be cast to an integer since it represents a node identifier (which is an integer value)? It currently is returned as a text string.
  6. The logic about using the '#allow_negative' property in image_effect_integer_validate() appears to result in an form_error message that is the reverse of what is documented. Could a fresh set of eyes take a look at this function? This function does not have a unit test (which needs to be created).
jhodgdon’s picture

Status: Needs review » Needs work

I took a quick glance through this patch, and noticed a few things:

a) We don't actually want @return docs on page callbacks or form generating functions. They are implied, unless something really odd is going on.

Something that is documented as both a page callback and form generating function therefore doesn't really need:

+ * @return array
+ *   A form array which will be rendered into a page via drupal_get_form().

b)
Things like this:

- * This form is used universally for editing all image effects. Each effect adds
- * its own custom section to the form by calling the form function specified in
- * hook_image_effects().
+ * This form is used universally for specifying all image effects. Each image
+ * effect adds its own custom section to the form by calling a form function
+ * specified in hook_image_effects().

("effect" -> "image effect") are not really necessary/welcome in this cleanup. We're just trying to do the things in the list on the meta-issue, not make all the docs perfect. Feel free to file new issues for other problems you find.

c) See http://drupal.org/node/1354#themeable for standards on how to document functions like theme_image_style_list(). In particular, the first line isn't right, and it's not necessary to say it's "the default method of theming" something -- that's implied by the name, and if we added this to all theme functions and templates, that would get very tedious. (also that second sentence about it being overridable)

d) Please do not add data types to param/return values. That's a separate effort, which has yet to be organized.

e) Since you filed a separate issue to clean up list formatting, let's not do that here either (and it's not in the list of things to clean up in the meta-issue). Or file a separate issue for that.

f) Hook definitions do not have the same verb requirements as regular functions:
http://drupal.org/node/1354#hooks

g) Refer to modules as "the Sentence case human-redable name" or "machine_name.module", not:

/**
  * @file
- * Functions needed to execute image effects provided by Image module.
+ * Functions needed to execute image effects provided by image module.
  */

h) No code changes here, only docs:

   if (!image_resize($image, $data['width'], $data['height'])) {
-    watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR);
+    $variables = array(
+      '%toolkit' => $image->toolkit,
+      '%path' => $image->source,
+      '%mimetype' => $image->info['mime_type'],
+      '%dimensions' => $image->info['width'] . 'x' . $image->info['height']
+    );
+    watchdog('image', 'Image resize failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', $variables, WATCHDOG_ERROR);
     return FALSE;

Once these are cleaned up, I'll give it a more thorough review. Thanks!

lars toomre’s picture

Assigned: lars toomre » Unassigned

This is a start at cleaning up the docs for the image module. If someone else want to take it further, please free to do so.

I am turning my focus to getting the malformed list formatting patch done since it will touch so many issues like this one. For the present, I am also not going to work on the locale module docs.

xenophyle’s picture

Assigned: Unassigned » xenophyle
xenophyle’s picture

There are a couple places where parameters weren't documented and I couldn't tell what they were:
image.install: image_requirements()
image.module: image_filter_keyword()

I will make issues for these. It seems like I should wait until this issue is closed before I do that to avoid conflicts.

xjm’s picture

Status: Needs work » Needs review

Sending to the bot.

jhodgdon’s picture

Status: Needs review » Needs work
Issue tags: +docs-cleanup-2011

The last submitted patch, image-clean-up-documentation-1326608-5.patch, failed testing.

jhodgdon’s picture

Sorry this took so long to get reviewed...

In the meantime, we had a discussion on #1315992: No standard for documenting menu callbacks and we have (unfortunately) changed the standard for hook_menu() callbacks:
http://drupal.org/node/1354#menu-callback

So this patch will need an update.

jhodgdon’s picture

Issue tags: +Novice, +Needs backport to D7

Tagging.

Also @xenophyle: are you still planning to work on this? If so, please respond. If not, we'll unassign it so someone else can. Thanks!

Anonymous’s picture

Assigned: xenophyle » Unassigned

Since there hasn't been activity for 4+ weeks, I'm going to move this back to unassigned.

filijonka’s picture

i'm slowly working on this

filijonka’s picture

Status: Needs work » Needs review
StatusFileSize
new9.32 KB

sorry for this taking such a time but have been having some problems.

proper feedback is welcome of course

filijonka’s picture

hi

if anyone please can take some time to 24,25/5 tomake a review of this then i'll have time todo a new patch if needed

jhodgdon’s picture

Sorry, there are quite a few cleanup issues waiting for review right now... I am doing them about one a day. Yours will be reviewed sometime...

andypost’s picture

Status: Needs review » Needs work
+++ b/core/modules/image/image.admin.inc
@@ -26,11 +26,11 @@ function image_style_list() {
  *   An image style array.
+ * ¶
  * @ingroup forms
+ * ¶

A lot of trailing white-spaces in patch. Also there's a lot of @todo waiting for #1464554: Upgrade path for image style configuration

filijonka’s picture

@jhodgdon due to accident and operations etc etc I haven't have time with this and I know my reply to u is way late but just so you know; My request/wish was not targeting you (I do know how much you have to do) but generally to anyone reading the topic.

sincerely Peter

mallezie’s picture

Assigned: Unassigned » mallezie
mallezie’s picture

StatusFileSize
new8.89 KB

Rerolled the patch. Now going further with cleanup

mallezie’s picture

StatusFileSize
new27.31 KB

Further cleanup of whitespaces and indention.
Left is param and function return types. But this was out of scope for this issue. I'm not sure if i should fix array 80 character overflows.
I didn't do this for now.

mallezie’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Status: Needs review » Needs work

Thanks! This patch needs some additional cleanup:

a) Lines like this:

* Form builder; Edit an image style name and effects order.

The standard for form-generating functions is at http://drupal.org/node/1354#forms -- also note we don't need a blank line between the @ingroup and the @see at the end, and the @ingroup should be last.

b)

t('If this style is in use on the site, you may select another style to replace it. All images that have been generated for this style will be permanently deleted.'),
-    t('Delete'),  t('Cancel')
+    t('Delete'), t('Cancel')
   );
 }

This issue is limited to documentation changes. Do not make code line changes at all in this issue. Those are being addressed on other issues. See #1310084: [meta] API documentation cleanup sprint for the scope of this issue.

c)

+ * Element validate handler to ensure that either a height or a width is set.
  */
 function image_effect_scale_validate($element, &$form_state) {

Standards for this: http://drupal.org/node/1354#render

d)

/**
- * Pull in image effects exposed by modules implementing hook_image_effect_info().
+ * Pull image effects exposed by modules implementing hook_image_effect_info().

Verb tense -- see http://drupal.org/node/1354#functions -- check the rest of the functions in this directory for the same problem (there are others in the patch with wrong verb tense).

e)

* @return
  *   An array containing the image effect definition with the following keys:
- *   - "effect": The unique name for the effect being performed. Usually prefixed
- *     with the name of the module providing the effect.
+ *   - "effect": The unique name for the effect being performed. Usually
+ *     prefixed with the name of the module providing the effect.
  *   - "module": The module providing the effect.
  *   - "help": A description of the effect.
  *   - "function": The name of the function that will execute the effect.

Could clean up the list syntax: http://drupal.org/node/1354#lists

f)

* @param $value
+ *   The keyword for the filter
  * @param $current_pixels
+ *   The current pixel
  * @param $new_pixels
+ *   The pixel offset
+ *
+ * $return
+ *  The new pixel offset
  */

Formatting -- needs . at end of lines -- see http://drupal.org/node/1354#functions

dcam’s picture

Status: Needs work » Needs review
StatusFileSize
new20.21 KB

Rerolled #20.

andypost’s picture

Looks good to go

jhodgdon’s picture

Status: Needs review » Needs work

I don't think the comments in #22 have been addressed at all.

dcam’s picture

They haven't. I only rerolled the last patch. There was enough to do just creating the reroll. I hope to get to the changes in #22 later this evening.

claudiu.cristea’s picture

This needs full re-work because of dramatic changes of image module during this summer.

jhodgdon’s picture

Issue summary: View changes
Status: Needs work » Closed (won't fix)

These issues are a lot of work with very little tangible payoff, so I'm closing the rest of them as "won't fix". Your efforts on working on this issue were appreciated... it was just my fault for starting a task that was very difficult to get right.

Let's instead put our effort into fixing and reviewing documentation that is really unclear and/or wrong, and I hope that the people who worked on these issues are not afraid to jump into a more reasonable issue!