diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index ac7031e..9db63ad 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -208,74 +208,56 @@ public function buildByExtension($extension) { * * This method sets the parsed information onto the library property. * - * Info files are formatted as YAML. If the 'version' key is set to 'VERSION' - * in any info file, then the value will be substituted with the current - * version of Drupal core. Each library is listed as an entry detailing the - * CSS and JS assets. - * - * @code - * drupal.editor: - * version: VERSION + * Library information is parsed from *.libraries.yml files; see + * editor.library.yml for an example. Every library must have at least one js + * or css entry. Each entry starts with a machine name and defines the + * following elements: + * - js: A list of Javascript files to include. Each file is keyed by the file + * path. An item can have several attributes (like weight or HTML + * attributes). For example: + * @code + * js: + * path/js/file.js: { attributes: { defer: true } } + * @endcode + * If the file has no special attributes, just use an empty object: + * @code * js: - * js/editor.js: {} + * path/js/file.js: {} + * @endcode + * The path of the file is relative to the module or theme directory, unless + * it starts with a /, in which case it is relative to the Drupal root. If + * the file path starts with //, it will be treated as an external resource. + * - css: A list of categories for which the library provides CSS files. The + * available categories are: + * - base + * - layout + * - component + * - state + * - theme + * Each category is itself a key for a sub-list of CSS files to include: + * @code * css: * component: - * css/editor.css: {} - * dependencies: - * - core/jquery - * - core/drupal - * - core/drupalSettings - * - core/jquery.once - * - core/drupal.dialog - * - * quickedit.inPlaceEditor.formattedText: - * version: VERSION - * js: - * js/editor.formattedTextEditor.js: { attributes: { defer: true } } - * dependencies: - * - quickedit/quickedit - * - editor/drupal.editor - * - core/drupal.ajax - * - core/drupalSettings - * @endcode - * - * Information stored in all .libraries.yml entries: - * - 'js': A list of Javascript files to include. Each file is the key of an - * object definition, which allows modules to set attributes for the - * particular file, like weight or HTML attributes. The path of the file is - * relative to the module or theme directory, unless it starts with a - * forward slash, in which case it is relative to the Drupal root. If the - * file path starts with 2 forward slashes, it will be treated as an - * external resource. Required if no 'css' key is present. - * - 'css': A list of categories for which the library provides CSS files. - * Each category is itself a key for a sub-list of CSS files to include. + * css/file.css: {} + * @endcode * Just like with Javascript files, each CSS file is the key of an object - * which can define specific attributes. The available categories are: - * - 'base' - * - 'layout' - * - 'component' - * - 'state' - * - 'theme' - * The CSS files for each category will get loaded in this order, meaning - * 'base' CSS files with get loaded before 'layout' files, and so on. The - * format of the file path is the same as for the Javascript files. The - * 'css' key is required if no 'js' key is present. - * - 'dependencies': A list of libraries this library depends on. + * which can define specific attributes. The format of the file path is the + * same as for the Javascript files. + * - dependencies: A list of libraries this library depends on. + * - version: If the version key is set to "VERSION", then the value will + * be substituted with the current version of Drupal core. * * @todo Document the following keys and their usage: - * - 'remote' - * - 'license' - * - 'header' - * - 'weight' (special rules for JS) - * - 'type' - * - 'data' - * - 'minified' - * - 'version' - * - * See editor.libraries.yml for an example of a module .libraries.yml file. + * - remote + * - license + * - header + * - weight (special rules for JS) + * - type + * - data + * - minified * - * See @link https://www.drupal.org/node/2274843#define-library Defining a library @endlink - * for a more detailed explanation. + * See https://www.drupal.org/node/2274843#define-library for more + * information. * * @param string $extension * The name of the extension that registered a library.