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.
Child of #2323895: [Meta] Document format/content of various YML files (we have been discussing how to document *.yml files).
There is currently no information on how to define a library in a *.libraries.yml file, on api.drupal.org.
There should be. It should be linked from
https://api.drupal.org/api/drupal/core!modules!system!theme.api.php/grou...
or added to that page.
We do have some documentation on drupal.org : https://www.drupal.org/node/2274843
So the topic on api.drupal.org should give a minimal example and link to this page.
Comment | File | Size | Author |
---|---|---|---|
#15 | interdiff.txt | 1.84 KB | wadmiraal |
#15 | drupal_libraries-yml-format-documentation_2390241_15.patch | 3.84 KB | wadmiraal |
#10 | interdiff.txt | 2.74 KB | wadmiraal |
#10 | drupal_libraries-yml-format-documentation_2390241_10.patch | 3.62 KB | wadmiraal |
#6 | interdiff.txt | 4.93 KB | wadmiraal |
Comments
Comment #1
alexpottSee #2323895-29: [Meta] Document format/content of various YML files
Comment #2
wadmiraal CreditAttribution: wadmiraal commentedI'll have a look.
Comment #3
wadmiraal CreditAttribution: wadmiraal commentedDocumentation for module, theme and profile
*.info.yml
files is provided directly incore/lib/Drupal/Core/Extension/InfoParserInterface.php::parse()
. I suggest we add the*.libraries.yml
documentation incore/lib/Core/Asset/LibraryDiscoveryParser::parseLibraryInfo()
.Comment #4
wadmiraal CreditAttribution: wadmiraal commentedHere is a documentation docblock for the
LibraryDiscoveryParser::parseLibraryInfo()
method, as well as an added link fortheme.api.php
to this information.We should note, however, that the documentation is still incomplete. The documentation at https://www.drupal.org/node/2274843#define-library is not complete at all. A lot of information is missing. In fact, the class method documentation is now more complete than the aforementioned node. We should clarify how the libraries are parsed (especially for the
'data'
and'header'
keys). I added a @todo to the method docblock.Comment #5
jhodgdonGreat start, and thanks for reviving this issue!
I have a few suggestions:
I would put this information about the version key in the docs below that tell about 'js', 'css', and etc.
Actually, maybe this whole paragraph can be omitted? We could just say something like:
Library information is parsed from *.libraries.yml files; see foo.library.yml for an example. Each entry starts with a machine name, and the information below has the following elements:
and then list the js, css, etc. as well as the note about VERSION.
I don't think we really need to put in a full example of a libraries.yml file in here. I would instead suggest saying something like "See foo.libraries.yml for an example" (replace 'foo' with the name of an actual library file that exists in Core).
This is the line I'd suggest combining with that previous paragraph.
Maybe instead of saying "forward slash" just put in '/' and '//'? More concise?
Actually, we don't normally want to put '' on list item keys. See https://www.drupal.org/node/1354#lists
This probably needs more details. I cannot figure out what it means.
Maybe this would be clearer if it said "Every library needs to have at least one js or css entry"?
Hm, again not really sure what this means? What are "categories"?
Ah, I see you have an example listed; just move this up into the main paragraph. :)
We can leave out the @link here. Just say "See https://whatever for more information".
Comment #6
wadmiraal CreditAttribution: wadmiraal commentedYeah, I wasn't really sure all that was very clear. How's this? I still feel there should be some example in there. It's pretty hard to understand just based on words.
Comment #7
jhodgdonGreat! I agree that the short examples you put in this time are good and necessary, and I think it's much better this way than including a whole example with documentation that is separate.
A few things to address:
Nitpick: should be JavaScript not Javascript throughout this patch
Nitpick: which -> that
We should probably start by saying "The library version." before launching into saying about the "VERSION" special value. :) Also I think this would be clearer if it said:
version: The library version. The string "VERSION" can be used to mean the current Drupal core version.
We need to take care of this before the patch is finalized. Alternatively, if we think these are not used much, we could just put in another - list item saying something like:
- Additional information can also be specified, such as the weight. See ... for more information.
Comment #8
nod_About the additional stuff there are a few things that shouldn't be used/documented:
Stuff we need to document (see core.libraries.yml for examples):
Comment #9
wadmiraal CreditAttribution: wadmiraal commentedThanks for the feedback and the additional info. Will update.
Comment #10
wadmiraal CreditAttribution: wadmiraal commentedUpdated, taking into account both your comments.
Comment #11
wadmiraal CreditAttribution: wadmiraal commentedComment #12
wadmiraal CreditAttribution: wadmiraal commentedComment #13
jhodgdonLooking good! I'm sitting next to you, so these comments are brief, so others can see the review:
Need to talk about stream wrappers and http:// stuff here?
Should use TRUE and FALSE in docs, not true/false.
Maybe say something like "for reference"? I think this is just for documentation and/or human readers so they can visit the project page, right?
boolean => Boolean
Comment #14
wadmiraal CreditAttribution: wadmiraal commentedComment #15
wadmiraal CreditAttribution: wadmiraal at educa.ch commentedI did not capitalize the boolean TRUE and FALSE values, as in this context we're talking about a YAML format (which should use lowercase true and false).
Comment #16
jhodgdonThanks! I think this is ready to go now.
Comment #17
wadmiraal CreditAttribution: wadmiraal at educa.ch commentedJust setting the organization for the credits.
Comment #18
nod_Great, thanks a lot!
Should we update the doc page as well or just refer to the api for more details?
Comment #19
jhodgdonIs the page on drupal.org wrong? The point of this issue was to make sure we have docs on api.drupal.org about libraries. I don't think there was a problem with the d.o docs.
Comment #20
nod_Fair enough, it's not wrong, just not very detailed.
Comment #21
webchickYay, Moar Docs! :)
Committed and pushed to 8.0.x. Thanks!