Attributes are not rendered when showing the source code

Created on 24 May 2024, 4 months ago
Updated 16 September 2024, about 2 hours ago

(I apologize if this has been already reported; I looked at the last issues and did not find one.)

Looking at GDToolkit.php, for example, I noticed the attributes are not shown in the code.
I was trying to understand how to convert the code for a module I maintain, and noticed there was the use Drupal\Core\ImageToolkit\Attribute\ImageToolkit; line which made me look at the code directly in the repository, where I noticed the code is the following one.

/**
 * Defines the GD2 toolkit for image manipulation within Drupal.
 */
#[ImageToolkit(
  id: "gd",
  title: new TranslatableMarkup("GD2 image manipulation toolkit"),
)]
class GDToolkit extends ImageToolkitBase {
๐Ÿ› Bug report
Status

Active

Version

2.0

Component

Parser

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @apaderno
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    The question we need to first to answer is: what is the desired outcome here? I think the attribute class itself already has an api page because it is a class, after all. Everything marked with that attribute should have a reference to this page and vice versa much like it happens with annotations. I imagine there would be an object-type of attribute, and an attributes reference type for buildReferencesSection / findReferences. This is a fairly trivial affair, โœจ Support for OO hooks implementations in classes Postponed shows how to parse attributes.

    A much more difficult question would be: what happens to the arguments of the attribute? The issue linked above definitely needs it -- perhaps it should special case for now and this issue should just store attributes as separate docblock entries and punt on argument processing. A followup would probably parse the arguments, use https://github.com/nikic/PHP-Parser/blob/master/doc/component/Constant_expression_evaluation.markdown and reference any classes and constants used here.

Production build 0.71.5 2024