Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of meta-issue #1310084: [meta] API documentation cleanup sprint and continuation of #1347890: Clean up API docs for file module.
This issue is focused on further changes to bring File module closer to D8/D7 documentation standards. This issue, for instance, will ensure that the various Test files are in accord with http://drupal.org/node/1354.
Comment | File | Size | Author |
---|---|---|---|
#21 | 1811674-21-file-docs.patch | 43.69 KB | Albert Volkman |
#21 | interdiff.txt | 12.69 KB | Albert Volkman |
#19 | 1811674-19-file-docs.patch | 42.81 KB | Albert Volkman |
#19 | interdiff.txt | 17.57 KB | Albert Volkman |
#16 | interdiff.txt | 5.14 KB | pwieck |
Comments
Comment #1
Lars Toomre CreditAttribution: Lars Toomre commentedThis is a work-in-progress patch that focuses on the Tests in the File module. It includes a number of places where in @param / @return directives the added type hint or description was uncertain. At those places, '???' was used in this first patch.
Comment #2
Lars Toomre CreditAttribution: Lars Toomre commentedThe ??? text strings still need to be addressed.
Comment #3
Lars Toomre CreditAttribution: Lars Toomre commentedThis is a locally untested patch that builds upon #1 and includes other changes from a review of the rest of the files in the File module. This patch still includes some '???' strings around uncertainty.
Comment #4
jhodgdonThanks! Most of the updates here are good. A few things to fix:
a) This change is not necessary (or even a good idea):
b)
Default => Defaults
c)
Please take all out-of-scope pieces out of this patch. This is a documentation clean-up issue, and I am not even sure if we have a coding standard for this blank line you've added, in any case.
d) CopyTest.php:
Take out "the", for consistency with the other tests in this file.
e) Same file:
Needs to be shortened to one line.
f)
Take out "for" to turn "Tests" into a verb.
g) There are still several ??? in this file. I stopped reviewing when I got to the first one.
Comment #5
Lars Toomre CreditAttribution: Lars Toomre commentedI am unclear about what part of the following statement in #3 lacks clarity: "This patch still includes some '???' strings around uncertainty."
Thanks for the start of a review @jhodgdon. However, it was unexpected. I was hoping that other reviewers might fill in the '???' strings I was uncertain about.
Comment #6
jhodgdonWhat are you asking in #5? There are ??? in the patch, so it is not done, and I marked it "needs work" after reviewing quite a bit of it. Is that a problem? It is not the job of the reviewer to write the patch, sorry.
Comment #7
Albert Volkman CreditAttribution: Albert Volkman commentedRe-roll with fixes suggested in #4.
Comment #8
oresh CreditAttribution: oresh commentedIt took me insane amount of time to look through all the changes! :)
Everything seems looking good, no grammatical mistakes found, variables in comments are correct, comment standards are used.
Marking as RTBC. Probably someone more competent in File module can take a more close look on it.
Thanks!
Comment #9
alexpottComment #10
jhodgdonThis patch unfortunately touches some of the same files as an "avoid commit conflicts" issue, so I'm going to wait on committing it until
#1888424: Make Drupal's URL generation logic available to HttpKernel, and minimize code repetition/divergence
is taken care of. At which point it might need a reroll.
Comment #11
alexpottDefinitely needs a reroll
Comment #12
pwieck CreditAttribution: pwieck commented@jhodgdon, Should this be marked 'postponed' as you mentioned in #10 or should I reroll to get a working copy.
The reroll monkey
Comment #13
Albert Volkman CreditAttribution: Albert Volkman commented@pwieck that issue appears to have been completed/committed, so you can move forward with a re-roll.
Comment #14
pwieck CreditAttribution: pwieck commentedWorking on reroll
Comment #15
pwieck CreditAttribution: pwieck commentedReroll complete.
Comment #16
pwieck CreditAttribution: pwieck commentedReroll passed and ready for review.
Forgot interdiff.txt
Comment #17
jhodgdonThis patch is mostly pretty good, but I have several concerns... and I wonder whether it is even a good idea to try to get such large patches reviewed/committed, sigh. Maybe we should just abandon this type of effort?
a) [file.api.php] Why is changing "doesn't" to "does not" even being done? That is not cleanup. That is someone's personal preference who apparently doesn't like contractions. Contractions are not forbidden in any style guide that I'm aware of.
b) In several places in file.module:
- The list syntax should be improved (should have : instead of - after the items).
- We have a standard way to indicate the default item in the list:
c) file.module:
This change is incorrect. First of all, our policy is to use interfaces not classes for data types wherever possible. Second, if you use a namespace, it must start with a \. The |false part is fine.
d)
In D7, we shouldn't use @var object for a user object. It should be referencing a specific User interface class.
e) FileFieldTestBase.php
Saying "Defaults to NULL" here is kind of useless without telling me what that means as far as the size of the returned file. I would either leave that out or figure out what it means.
f) FileFieldTestBase.php
It looks like this doc block was copied from an insert/create function. It isn't quite right for the update function. Also the third param description doesn't end in ".".
g) Same file
Doesn't end in "."
h) Same file
This would be a lot more useful if it said something like "The default message is ..." rather than "Defaults to NULL", which tells me really nothing. Either that or just leave out the "Defaults to NULL". Same applies to several other methods here and in other classes.
i)
@var is missing data types
j) FileManagedTestBase
needs to be one line.
k)
Should start with a verb ending in s and "move-related" should be hyphenated.
l) same file
Needs to be one line.
m) SaveUploadTest
This is probably an integer not a string? Also you could capitalize ID in the previous line.
n)
Why was "File" capitalized?
o)
2nd parameter - boolean vs. Boolean
p)
Um.... Why is all this code being added to the module here???
q) same file
Needs to be one line.
r) same file
Two spaces after . should be 1.
s)
For extra credit, saying "Overrides [same method name that is being documented]" is not really useful or correct. It should say something like "Overrides ClassName::methodName()". or "Overrides \Fully\Namespaced\ClassName::methodName()".
Comment #18
jhodgdonComment #19
Albert Volkman CreditAttribution: Albert Volkman commentedHere's a pass to clean up the outstanding issues.
s) I don't believe these methods are overriding anything.
Comment #20
jhodgdonThanks! Looking better. There are still a few problems:
a) file.field.inc -- file_field_widget_uri()
This change is incorrect. The code is actually calling ]Drupal::token()->replace(). I don't think token_replace() still exists in D8.
b) file.module file_icon_url()
This is incorrect. This parameter is passed to file_icon_path(), which does config('file.settings')->get('icon.directory')
so I don't see how that is the value of the "file_icon_directory" variable?
c)
- When using namespaces in documentation, you must start them with a \
- When specifying @var/@param/@return types, we want to see interfaces rather than classes. In fact, there's another issue that is fixing up uses of the User class in favor of I think it is UserInterface or AccountInterface or something.
d) Same file, method updateFileField
This isn't a new field. It's an existing field. Also, I don't think the field_ prefix is really excluded. The function calls field_info_instance() passing in $name exactly as it is passed in, and that function doesn't add "field_" to field names as far as I can tell?
e) Same file, method uploadNodeFile
Don't use object here. Either just leave it out or figure out what class (or preferably interface) it actually needs to be. It's not a generic object.
==> Applies to a lot of other methods in this file
f) same method
Not really accurate. You set it to TRUE if you want the node to get a new revision when this new file is uploaded, and FALSE if you don't want a new revision to be created.
==> This also applies to the removeNodeFile and replaceNodeFile methods below in the patch.
g) same method
Not really accurate. This is actually a terrible name for the parameter. Can we change it to $node_properties (and yes, changing a parameter name is considered documentation so it's OK to do) and document it as the properties to use to create the node if $nid_or_type is a node type? We should also probably mention in $nid_or_type that if it's a node type string, a new node is created inside this function.
h) removeNodeFile method (and also applies to other methods in this file)
Can this please say "The node ID of the node to remove the file from" or at least "The node ID of the node" rather than a non-specific "A node ID"?
i) Can we add to removeNodeFile and replaceNodeFile a note that it assumes that there is exactly one file attached to the node, because it works by submitting with the "Remove" button on the edit screen?
j) same file
There are a bunch of these methods with optional $message parameters. On some, (optional) is included, and not on others. Let's put it on all of them. It would also be nice to describe the default message or at least say something like "if omitted a default message is provided"?
==> This also applies to other files in this patch.
k) FileFieldValidateTest
If these properties are unused (and I think that is correct), let's just remove them rather than documenting what they are and what type they are? Or at least let's leave out the @var since if they are unused they certainly don't have a type. I realize all member properties are supposed to have @var but if they are unused they don't have a type.
I also checked and there is nothing extending this class anywhere... Actually let's leave them undocumented and file a separate issue to remove them?
l) FileManagedTestBase
Why lose the @return type and documentation here? Was it incorrect?
m) SaveUploadTest
This should either be int|string, int, or string, but not "int string". Probably it's an int?
n) file_module_test.module file_module_test_form()
The $default_fids parameter is documented here as $default_fid instead.
o) Comment (s) from my previous review still applies to the DummyStreamWrapper methods. If those methods are not overriding anything, then don't document them as overriding something. If they are overriding something (probably from an interface somewhere?) then put that interface name into the method name.
Comment #21
Albert Volkman CreditAttribution: Albert Volkman commentedCleaned up some more. In reference to the overridden methods, it turns out that getExternalUrl() was an override, but getInternalUri() doesn't override anything, nor does it appear to be used. Perhaps we could remove that in a follow-up.
Comment #22
jhodgdonThese 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!