Skip to content

Commit a7cfb84

Browse files
authored
Merge pull request #12 from steffenhaug/main
Docstrings on lone identifiers and SQLStrings language injection
2 parents e73a76b + 0e33f3d commit a7cfb84

File tree

3 files changed

+130
-2
lines changed

3 files changed

+130
-2
lines changed

languages/julia/highlights.scm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,29 @@
567567
(function_definition)
568568
(assignment)
569569
(const_statement)
570+
])
571+
572+
((macrocall_expression
573+
(macro_identifier "@" (identifier)) @function.macro
574+
(macro_argument_list
575+
.
576+
(string_literal) @comment.doc))
577+
(#eq? @function.macro "@doc"))
578+
579+
(source_file
580+
(string_literal) @comment.doc
581+
.
582+
[
583+
(identifier)
584+
(open_tuple
585+
(identifier))
586+
])
587+
588+
(module_definition
589+
(string_literal) @comment.doc
590+
.
591+
[
592+
(identifier)
570593
(open_tuple
571594
(identifier))
572595
])

languages/julia/injections.scm

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,38 @@
99
(function_definition)
1010
(assignment)
1111
(const_statement)
12-
(open_tuple
13-
(identifier))
1412
]
1513
(#match? @content "^\"\"\"")
1614
(#set! "language" "markdown"))
1715

16+
((macrocall_expression
17+
(macro_identifier "@" (identifier)) @function.macro
18+
(macro_argument_list
19+
.
20+
(string_literal) @content))
21+
(#eq? @function.macro "@doc")
22+
(#set! "language" "markdown"))
23+
24+
((source_file
25+
(string_literal) @content
26+
.
27+
[
28+
(identifier)
29+
(open_tuple
30+
(identifier))
31+
])
32+
(#set! "language" "markdown"))
33+
34+
((module_definition
35+
(string_literal) @content
36+
.
37+
[
38+
(identifier)
39+
(open_tuple
40+
(identifier))
41+
])
42+
(#set! "language" "markdown"))
43+
1844
([
1945
(line_comment)
2046
(block_comment)
@@ -25,3 +51,8 @@
2551
prefix: (identifier) @_prefix) @content
2652
(#eq? @_prefix "r")
2753
(#set! "language" "regex"))
54+
55+
((prefixed_command_literal
56+
prefix: (identifier) @_prefix) @content
57+
(#eq? @_prefix "sql")
58+
(#set! "language" "sql"))

syntax-test-cases/docstrings.jl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# (module_definition)
2+
"""
3+
This _should_ have `markdown` injected!
4+
"""
5+
module A end
6+
7+
# (abstract_definition)
8+
"""
9+
This _should_ have `markdown` injected!
10+
"""
11+
abstract type AbstractT end
12+
13+
# (struct_definition)
14+
"""
15+
This _should_ have `markdown` injected!
16+
"""
17+
struct S end
18+
19+
# (function_definition)
20+
"""
21+
This _should_ have `markdown` injected!
22+
"""
23+
function f end
24+
25+
# (assignment)
26+
"""
27+
This _should_ have `markdown` injected!
28+
"""
29+
x = 73
30+
31+
# (const_statement)
32+
"""
33+
This _should_ have `markdown` injected!
34+
"""
35+
const y = 42
36+
37+
# (macrocall_expression) with (macro_identifier) eq. "@doc"
38+
@doc "This _should_ have `markdown` injected!" x
39+
40+
# (macrocall_expression) with (macro_identifier) not eq. "@doc"
41+
@info "This should _not_ have `markdown` injected!" x
42+
43+
# (source_file (string_literal) (identifier))
44+
"""
45+
This _should_ have `markdown` injected!
46+
"""
47+
x
48+
49+
module B
50+
# (identifier)
51+
"""
52+
This _should_ have `markdown` injected!
53+
"""
54+
x
55+
end
56+
57+
begin
58+
# (identifier)
59+
"""
60+
This _should_ have `markdown` injected!
61+
"""
62+
x
63+
end
64+
65+
let
66+
# (identifier)
67+
"""
68+
This _should_ have `markdown` injected!
69+
"""
70+
x
71+
end
72+
73+
# (call_expression)
74+
foobar("This should _not_ have `markdown` injected!", x)

0 commit comments

Comments
 (0)