Add a link to the source on git.drupalcode.org

Created on 19 June 2024, 9 days ago
Updated 20 June 2024, 8 days ago

Now that the code on api.drupal.org is rendered using a four-space indentation and two empty lines are put between functions/methods, having a link to the source code on git.drupalcode.org would help who needs to see how the code is really formatted, for example because the code needs to be copy-pasted in an issue.

A link to the source file would also help people who look for a function on api.drupal.org to understand in which file that function is, but then need to see the source file, for example because they are looking for line 110, which is inside that function.

โœจ Feature request
Status

Needs review

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
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Adding mockup:

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    My suggestion is to add a "Git URL" field to the Project entity that, when populated, will make the link to the source code be shown. If the link is not populated, then no link will be shown.

  • Status changed to Needs review 9 days ago
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    The MR is ready for review.

    As this module is theme agnostic, it just adds the link with wrapping classes and a "git" icon. Any theme can easily format that div and icon as needed. The default look is:

    If the approach here is good, we will create a Bluecheese issue to style this new element.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    Yay! Great feature. I think "View file on ..." would be the proper English not "in"? Otherwise UI looks good. Did not review the code in detail.

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

    Just a little note: Code like new TranslatableMarkup('@link_to_file', ['@link_to_file' => Formatter::linkFile($file_entity)]); does not get translations. What the people who translate on localize.drupal.org see as text to translate is @link_to_file, and since that is a placeholder, they would just put @link_to_file because placeholders are not translated.

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

    That is not really an issue is what returned from Formatter::linkFile($file_entity) is already a translated string; otherwise, $link_to_file = new TranslatableMarkup('@link_to_file', ['@link_to_file' => Formatter::linkFile($file_entity)]); will always show a link in English.

    If Formatter::linkFile($file_entity) returns a translated string, then it is not necessary TranslatableMarkup, but FormattableMarkup

  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Changed the text to "View on" as the word "File" is just above and is not needed.

    Also changed the translatable strings to use the direct value instead (I know this is not part of this issue but I'm just trying to get in as a quick fix to remote the phpcs issues).

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    Added a few small remarks. Nothing major so leaving at NR.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium BramDriesen Belgium ๐Ÿ‡ง๐Ÿ‡ช

    Funky, about the order. But if style-lint is happy I guess it's good ;-)

Production build 0.69.0 2024