Attributes are not rendered when showing the source code

Created on 24 May 2024, 9 months ago
Updated 17 September 2024, 5 months 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

Merge Requests

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.

  • Merge request !46store attribute references โ†’ (Open) created by Unnamed author
  • Pipeline finished with Failed
    5 months ago
    Total: 368s
    #285255
  • Pipeline finished with Success
    5 months ago
    Total: 210s
    #285326
  • Pipeline finished with Success
    5 months ago
    Total: 213s
    #285336
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    So this code parses and stores an attribute reference with less than 30 lines of code. This is a good start. Needs display and test.

    This works for classes, function, methods, class constants, class properties. The next issue will be parameter attributes as used for autowiring for example. That's a bit more work because there's no docblock entry to piggyback on to currently.

  • Pipeline finished with Success
    5 months ago
    Total: 190s
    #286096
  • Pipeline finished with Success
    5 months ago
    Total: 222s
    #286220
  • Pipeline finished with Success
    4 months ago
    Total: 204s
    #290320
  • Pipeline finished with Success
    4 months ago
    Total: 226s
    #290460
  • Pipeline finished with Success
    4 months ago
    Total: 222s
    #293489
  • Pipeline finished with Failed
    4 months ago
    Total: 666s
    #302162
  • Pipeline finished with Canceled
    4 months ago
    Total: 63s
    #308140
  • Pipeline finished with Success
    4 months ago
    Total: 308s
    #308143
Production build 0.71.5 2024