Skip to content

Commit 30e3ae6

Browse files
committed
Add scala-mode snippet to define functions along with their docstring
1 parent 88e2099 commit 30e3ae6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

snippets/scala-mode/docfun

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
# name: docstring function
3+
# contributor: Andrea Giugliano
4+
# inspired by a snippet by Tibor Simko et al.
5+
# --
6+
/**
7+
* $1
8+
* ${3:$
9+
(let* ((indent
10+
(concat "\n * "))
11+
(args
12+
(mapconcat
13+
'(lambda (x)
14+
(if (not (string= (nth 0 x) ""))
15+
;; in Scala I get a separator : for the type
16+
(let ((par-type (mapcar 'string-trim (split-string (nth 0 x) ":")))) (concat "@param " (first par-type) indent "@tparam " (second par-type) indent))
17+
))
18+
(mapcar
19+
'(lambda (x)
20+
(mapcar
21+
'(lambda (x)
22+
(replace-regexp-in-string "[[:blank:]]*$" ""
23+
(replace-regexp-in-string "^[[:blank:]]*" "" x)))
24+
x))
25+
(mapcar '(lambda (x) (split-string x "="))
26+
(split-string yas-text ",")))
27+
indent)))
28+
(if (string= args "")
29+
(concat indent "@return: " indent "@rtype: " indent (make-string 3 34))
30+
(mapconcat
31+
'identity
32+
(list "" args )
33+
indent)))
34+
}
35+
* @return ${4:$(yas-text)}
36+
*
37+
**/
38+
def ${2:name}($3): $4 = $0

0 commit comments

Comments
 (0)