diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-08 13:26:33 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-08 13:26:33 +0100 |
commit | db36a25839be0a799be2a229b9fd0d45da57635b (patch) | |
tree | c6787e78879c7c2c86938e8d7c659fd756609ffd /crates/ra_ide/src/snapshots | |
parent | ab86f15ff2c237ac3f4237961e4484ae71cedf00 (diff) | |
parent | 4a2efb2f42494f62891ac801e0a27d246bd36684 (diff) |
Merge #4683
4683: Implement syntax highlighting for doctests r=ltentrup a=ltentrup
The implementation is more complicated than the previous injection logic as the doctest comments consist of multiple ranges. The implementation extracts the doctests together with an offset-mapping, applies the syntax highlighting, and updates the text ranges.
<img width="478" alt="Bildschirmfoto 2020-06-01 um 15 45 25" src="https://user-images.githubusercontent.com/201808/83415249-1f0b5800-a41f-11ea-8fa6-c282434d6ff7.png">
Part of #4170.
Co-authored-by: Leander Tentrup <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/snapshots')
-rw-r--r-- | crates/ra_ide/src/snapshots/highlight_doctest.html | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/crates/ra_ide/src/snapshots/highlight_doctest.html b/crates/ra_ide/src/snapshots/highlight_doctest.html new file mode 100644 index 000000000..2f2d8c900 --- /dev/null +++ b/crates/ra_ide/src/snapshots/highlight_doctest.html | |||
@@ -0,0 +1,70 @@ | |||
1 | |||
2 | <style> | ||
3 | body { margin: 0; } | ||
4 | pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } | ||
5 | |||
6 | .lifetime { color: #DFAF8F; font-style: italic; } | ||
7 | .comment { color: #7F9F7F; } | ||
8 | .struct, .enum { color: #7CB8BB; } | ||
9 | .enum_variant { color: #BDE0F3; } | ||
10 | .string_literal { color: #CC9393; } | ||
11 | .field { color: #94BFF3; } | ||
12 | .function { color: #93E0E3; } | ||
13 | .operator.unsafe { color: #E28C14; } | ||
14 | .parameter { color: #94BFF3; } | ||
15 | .text { color: #DCDCCC; } | ||
16 | .type { color: #7CB8BB; } | ||
17 | .builtin_type { color: #8CD0D3; } | ||
18 | .type_param { color: #DFAF8F; } | ||
19 | .attribute { color: #94BFF3; } | ||
20 | .numeric_literal { color: #BFEBBF; } | ||
21 | .bool_literal { color: #BFE6EB; } | ||
22 | .macro { color: #94BFF3; } | ||
23 | .module { color: #AFD8AF; } | ||
24 | .variable { color: #DCDCCC; } | ||
25 | .format_specifier { color: #CC696B; } | ||
26 | .mutable { text-decoration: underline; } | ||
27 | |||
28 | .keyword { color: #F0DFAF; font-weight: bold; } | ||
29 | .keyword.unsafe { color: #BC8383; font-weight: bold; } | ||
30 | .control { font-style: italic; } | ||
31 | </style> | ||
32 | <pre><code><span class="keyword">impl</span> <span class="unresolved_reference">Foo</span> { | ||
33 | <span class="comment">/// Constructs a new `Foo`.</span> | ||
34 | <span class="comment">///</span> | ||
35 | <span class="comment">/// # Examples</span> | ||
36 | <span class="comment">///</span> | ||
37 | <span class="comment">/// ```</span> | ||
38 | <span class="comment">/// #</span> <span class="attribute">#![</span><span class="function attribute">allow</span><span class="attribute">(unused_mut)]</span> | ||
39 | <span class="comment">/// </span><span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">foo</span>: <span class="unresolved_reference">Foo</span> = <span class="unresolved_reference">Foo</span>::<span class="unresolved_reference">new</span>(); | ||
40 | <span class="comment">/// ```</span> | ||
41 | <span class="keyword">pub</span> <span class="keyword">const</span> <span class="keyword">fn</span> <span class="function declaration">new</span>() -> <span class="unresolved_reference">Foo</span> { | ||
42 | <span class="unresolved_reference">Foo</span> { } | ||
43 | } | ||
44 | |||
45 | <span class="comment">/// `bar` method on `Foo`.</span> | ||
46 | <span class="comment">///</span> | ||
47 | <span class="comment">/// # Examples</span> | ||
48 | <span class="comment">///</span> | ||
49 | <span class="comment">/// ```</span> | ||
50 | <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">foo</span> = <span class="unresolved_reference">Foo</span>::<span class="unresolved_reference">new</span>(); | ||
51 | <span class="comment">///</span> | ||
52 | <span class="comment">/// </span><span class="comment">// calls bar on foo</span> | ||
53 | <span class="comment">/// </span><span class="macro">assert!</span>(foo.bar()); | ||
54 | <span class="comment">///</span> | ||
55 | <span class="comment">/// </span><span class="comment">/* multi-line | ||
56 | </span><span class="comment">/// </span><span class="comment"> comment */</span> | ||
57 | <span class="comment">///</span> | ||
58 | <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">multi_line_string</span> = <span class="string_literal">"Foo | ||
59 | </span><span class="comment">/// </span><span class="string_literal"> bar | ||
60 | </span><span class="comment">/// </span><span class="string_literal"> "</span>; | ||
61 | <span class="comment">///</span> | ||
62 | <span class="comment">/// ```</span> | ||
63 | <span class="comment">///</span> | ||
64 | <span class="comment">/// ```</span> | ||
65 | <span class="comment">/// </span><span class="keyword">let</span> <span class="variable declaration">foobar</span> = <span class="unresolved_reference">Foo</span>::<span class="unresolved_reference">new</span>().<span class="unresolved_reference">bar</span>(); | ||
66 | <span class="comment">/// ```</span> | ||
67 | <span class="keyword">pub</span> <span class="keyword">fn</span> <span class="function declaration">foo</span>(&<span class="self_keyword">self</span>) -> <span class="builtin_type">bool</span> { | ||
68 | <span class="bool_literal">true</span> | ||
69 | } | ||
70 | }</code></pre> \ No newline at end of file | ||