Attributes are not rendered when showing the source code

Created on 24 May 2024, 12 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

User interface

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 in classes Active 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 โ†’ (Merged) created by Unnamed author
  • Pipeline finished with Failed
    8 months ago
    Total: 368s
    #285255
  • Pipeline finished with Success
    8 months ago
    Total: 210s
    #285326
  • Pipeline finished with Success
    8 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
    8 months ago
    Total: 190s
    #286096
  • Pipeline finished with Success
    8 months ago
    Total: 222s
    #286220
  • Pipeline finished with Success
    8 months ago
    Total: 204s
    #290320
  • Pipeline finished with Success
    8 months ago
    Total: 226s
    #290460
  • Pipeline finished with Success
    7 months ago
    Total: 222s
    #293489
  • Pipeline finished with Failed
    7 months ago
    Total: 666s
    #302162
  • Pipeline finished with Canceled
    7 months ago
    Total: 63s
    #308140
  • Pipeline finished with Success
    7 months ago
    Total: 308s
    #308143
  • Status changed to Needs review 3 days ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Trying to add some tests.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    The failing tests in the CI are mostly unrelated to the changes here, and defo not a blocker.

    This is how it's rendered in the tests:

    The code looks good and it opens the door to some of the other critical issues.
    RTBC.

  • Pipeline finished with Skipped
    1 day ago
    #491516
  • Pipeline finished with Skipped
    1 day ago
    #491519
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Merged as this will unblock some other critical issues. We can create follow-ups if needed.

    This will go with the next deployment round to api.drupal.org.

    Thanks so much!

Production build 0.71.5 2024