Problem/Motivation
The documentation for DateTimePlus is incomplete. And needs to be improved.
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Date...
See for instance https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Date.... The '@see __construct()' is not forming a link.
Proposed resolution
Change the documentation according to https://www.drupal.org/docs/develop/standards/api-documentation-and-comm....
Remaining tasks
Documentation to be written and updated.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | interdiff-24-36.txt | 747 bytes | nitin_lama |
| #36 | 3077520-36.patch | 5.97 KB | nitin_lama |
| #33 | DateTimePlus_doc-3077520-33.patch | 6.04 KB | kunalgautam |
| #26 | 3077520-applied-24.png | 11.31 KB | abhijith s |
| #24 | interdiff_21-24.txt | 3.76 KB | sarvjeetsingh |
Issue fork drupal-3077520
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gueguerreiroThis would be a duplicate of https://www.drupal.org/project/drupal/issues/2940420, but I was looking through the documentation for that class in more detail and there are a couple more documentation errors there. I think we can turn this one into a general fix for documentation errors/improvements for DateTimePlus?
Most of my assumptions are according to what's currently in https://www.drupal.org/node/1354, but I assume all of what's in there to be correct.
The class docblock
Uses @method tags. While these are correct according to phpdoc, the Drupal API doesn't support them. The page displays these as a huge paragraph:
The
@param $timezonedocblocks:Have a type of
mixed. A more correct value would be, as the description states,\DateTimeZone|string|nullThe
@param $settingsdocblock on__construct():The only operation with the $settings parameter is the following:
The 'debug' key is never used. It should be removed.
Also, according to the API documentation and comments standards:
The
@param timedocblock oncreateFromFormat():The type is documented as
mixed. It is actually a string, the same one accepted at https://www.php.net/manual/en/datetime.construct.php and the same type as most of the other $type parameters on that class.Of course, multiple instances of @see tags as a child of the @param tag:
I don't think a @see __construct() is even needed in the first place. We can just copy the description of these parameters from the __construct() and paste it there. If we do need it we should link it at the very bottom of the docblock, as
@see self::__construct()instead.Note that the $settings param from createFromFormat() is the same as __construct(), with the exception that it can also contain a "validate_format" key. It seems to be the only one that is any different from the other ones.
Also some nitpicks:
The description text should be after the short description text, and the @see tag should be at the bottom.
Comment #3
gueguerreiroThis patch should address the issues raised on #3. In addition to those, I added some @see tags (And regular See links, when using them inside @params) where I thought appropriate.
Comment #4
gueguerreiroI had some trailing whitespaces. This one fixes those.
Comment #5
volkswagenchickTagging this for badcamp2019. (October 2-5)
Comment #7
capysara commentedPatch in #4 applies cleanly to 8.9.
Comment #8
joachim commentedThanks everyone for working on this!
This line needs wrapping.
A two-letter language code is an ISOwhatsit, right? We should say that.
Wrapping.
It might be better to keep a reference to __construct() rather than repeating the same docs.
The question in my original report was really -- how should this be made correctly?
Comment #9
joachim commentedAccording to #2989497: Link to 'self::method()' doesn't work in documentation blocks, '@see self::__construct()' should work.
Comment #10
mradcliffeI added the needs issue summary update tag because I think that it is a bit unclear what is left to be done on the issue. We should apply the standard issue summary template. THe issue summary should include the current state of the issue with respect to @joachim's comments and the latest patch.
Comment #11
mradcliffeAdding novice tag.
Comment #12
Hmengland commentedI'm working on this ticket at DrupalCon Amsterdam
Comment #13
Hmengland commentedupdated issue summary to follow the standard issue summary template.
Comment #14
shubham.prakash commentedChanges have been made as per #8 and #9
Comment #16
neclimdulThese are all IDE hints. Unfortunate that Drupal API doesn't support them but removing them is a big DX hit so seems a no go.
Comment #18
ayushmishra206 commentedPatch #14 Fails to Apply. Needs Reroll.
Comment #19
kishor_kolekar commentedhere the re-roll patch
Comment #20
alvar0hurtad0This still needs to address the comment #16
Comment #21
alvar0hurtad0This patch fixes #16
Comment #22
gueguerreiroAddressing #16, I looked into it a bit more, and there is an issue to add the
@methodtags for the magic methods to the DateTimePlus docblock on #2902707: Document magic methods in DateTimePlus and DrupalDateTime using phpDoc @method. There's also an issue opened to support these on the Drupal Coding Standards API here #2920333: Allow PHPDoc @method annotations in class headers., which I agree with.We should keep them and focus the attention on changing the Drupal Coding Standards API instead.
Comment #23
neclimdulDon't understand why these need space. also, trailing spaces.
not sure why we're moving this. Also maybe relevant to documenting this. #3177385: Deprecate DateTimePlugs::DATE_RFC7231 constant
What does format have to do with createFromTimestamp? Side note, I still don't understand why we can't use see comments per the phpdoc standard.
again, why format?
>80 character comments.
Does this provide extra context? Isn't the return time clear?
Additional note, I think links to php.net documentation are suppose to remove the language from the path so it redirects for non-english speakers.
Comment #24
sarvjeetsingh commentedUpdated the patch as suggested in #23.
- For point 3&4, the use of format() method is mentioned in the comment and I think that's why it is referenced.
- Not sure about point 2. still needs to be addressed.
Comment #25
sarvjeetsingh commentedComment #26
abhijith s commentedApplied patch #24 and it is working fine.The problems addressed in #23 is fixed accordingly.
Comment #27
abhijith s commentedComment #28
quietone commentedIn #24 there is a comment that #23.2 needs to be addressed.
Also #23.6 needs to be answered.
I think this still needs and Issue Summary Update. The proposed resolution is simply a link to the API documentation standards which is a useful link but there is nothing to state what is exactly to be improved here. As a reviewer, it is impossible to know if the patch fixes the issue.
Comment #33
kunalgautam commentedUpdated patch for Drupal version 10.1.x
Comment #34
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
FYI #24 still cleanly applies to 10.1 so removing credit for #33
@kkalashnikov you can test by clicking retest.
Points in #28 still need to happen.
Comment #35
nitin_lamaComment #36
nitin_lamaAddressed #23.2
Here's the updated patch. Please review.
Comment #37
nitin_lamaComment #38
smustgrave commentedFYI if you’re only going to address 1 point and not attempt the others the ticket is not ready for review
Comment #42
quietone commentedI think that in the state this issue is in it is no longer suitable for as a Novice issue. I am removing the 'Novice' tag because there isn't sufficient detail for someone new to Drupal contribution. Issues tagged Novice should met the criteria list in What makes a good novice task.