Render references to source code lines inline
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Need the ability to see referenced source code lines directly in an issue comment.
Right now if the link to source code is pasted, people still need to:
- open new tab to read the code
- know where to get permalink to reference the code (so that it won't shift over time)
Proposal
- Automatically transform source code URLs into permalinks (#537874)
- Render standalone permalinks as code blocks
How to test the issue is solved
When user pastes link to the source code on a separate line, GitLab should:
- fetch the permalink for the provided source link (#537874)
- fetch source code lines for the provided permalink (say 2 above and 5 below by default)
- render source code, in the comment, with appropriate highlighter and referenced line (3) highlighted
- render permalink in the comment
Example
Line
https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/project_ci_cd_setting.rb#L20
should turn into this permalink while editing the post
https://gitlab.com/gitlab-org/gitlab/-/blob/3f1076db0d34c46f0bf4f824a268941bbc943e23/app/models/project_ci_cd_setting.rb#L20
and then rendered as
allow_nil: true
->default_value_for :forward_deployment_enabled, true<------- THIS LINE IS HIGHLIGHTED
default_value_for :separated_caches, true
chronic_duration_attr :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval
def forward_deployment_enabled?
Similar issues
#19480 proposes adding menu at line anchor to copy permalink.
Links / references
Edited by 🤖 GitLab Bot 🤖