Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
dashboards
Commits
0650740c9f11
Commit
365008c5
authored
Nov 25, 2020
by
Laurent Peuch
Browse files
feat(deprecated): anchors to lines on links to files
parent
d17d0efea687
Changes
4
Hide whitespace changes
Inline
Side-by-side
deprecated-warnings.py
View file @
0650740c
...
...
@@ -16,7 +16,8 @@ from pygments.formatters.html import HtmlFormatter
def
highlight_code
(
file_content
,
lineno
,
full_file
=
False
):
if
full_file
:
return
highlight
(
file_content
,
get_lexer_by_name
(
"python"
,
stripnl
=
False
),
HtmlFormatter
(
wrapcode
=
True
,
linenos
=
True
,
hl_lines
=
[
lineno
]))
HtmlFormatter
(
wrapcode
=
True
,
linenos
=
True
,
lineanchors
=
"L"
,
anchorlinenos
=
True
,
hl_lines
=
[
lineno
]))
file_content
=
file_content
.
split
(
"
\n
"
)[:
lineno
+
4
]
...
...
public/css/style.css
View file @
0650740c
...
...
@@ -127,3 +127,9 @@ table.qa td.readthedocs a {
.highlighttable
pre
{
margin-top
:
0
;
}
.highlighttable
a
{
color
:
black
;
text-decoration
:
none
;
padding-top
:
300px
;
}
template/deprecated-warnings.html
View file @
0650740c
...
...
@@ -59,7 +59,7 @@
{% if "file_content" in warning %}
{% set file_uri_path = str(project.id) + "_" + path.replace("/", "_") %}
{{- render_source_code_file(warning["file_content"], file_uri_path, path, warning["lineno"]) or "" -}}
In
<a
href=
"file/{{ file_uri_path }}.html#{{ warning["
lineno
"]
}}"
>
{{ path }}
</a>
line {{ lineno }} (
<a
href=
"traceback/{{ traceback_id }}.html"
>
full traceback
</a>
)
In
<a
href=
"file/{{ file_uri_path }}.html#
L-
{{ warning["
lineno
"]
}}"
>
{{ path }}
</a>
line {{ lineno }} (
<a
href=
"traceback/{{ traceback_id }}.html"
>
full traceback
</a>
)
{% else %}
In
<u>
{{ path }}
</u>
line {{ lineno }} (
<a
href=
"traceback/{{ traceback_id }}.html"
>
full traceback
</a>
)
{% endif %}
...
...
template/traceback.html
View file @
0650740c
...
...
@@ -15,7 +15,7 @@
{% if frame["file_content"] %}
{% set file_uri_path = str(project_id) + "_" + frame["filename"].replace("/", "_") %}
{{- render_source_code_file(frame["file_content"], file_uri_path, frame["filename"], frame["lineno"]) or "" -}}
<span><a
href=
"../file/{{ file_uri_path }}.html#{{ frame["
lineno
"]
}}"
>
{{ frame["filename"] }}
</a>
line {{ frame["lineno"] }}
<span>
<span><a
href=
"../file/{{ file_uri_path }}.html#
L-
{{ frame["
lineno
"]
}}"
>
{{ frame["filename"] }}
</a>
line {{ frame["lineno"] }}
<span>
{{ highlight_code(frame["file_content"], frame["lineno"]) }}
{% else %}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment