File: docfun

package info (click to toggle)
yasnippet-snippets 1.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,328 kB
  • sloc: lisp: 127; sh: 13; ada: 5; makefile: 2; python: 2
file content (40 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- mode: snippet -*-
# -*- coding: utf-8 -*-
# name: docstring function
# contributor: Andrea Giugliano
# key: docfun
# inspired by a snippet by Tibor Simko et al.
# --
/**
 * $1
 * ${3:$
    (let* ((indent
            (concat "\n * "))
           (args
            (mapconcat
             '(lambda (x)
                (if (not (string= (nth 0 x) ""))
                    ;; in Scala I get a separator : for the type
                    (let ((par-type (mapcar 'string-trim (split-string (nth 0 x) ":")))) (concat "@param " (first par-type) indent "@tparam " (second par-type) indent))
                    ))
             (mapcar
              '(lambda (x)
                 (mapcar
                  '(lambda (x)
                     (replace-regexp-in-string "[[:blank:]]*$" ""
                      (replace-regexp-in-string "^[[:blank:]]*" "" x)))
                  x))
              (mapcar '(lambda (x) (split-string x "="))
                      (split-string yas-text ",")))
             indent)))
      (if (string= args "")
          (concat indent "@return: " indent "@rtype: " indent (make-string 3 34))
        (mapconcat
         'identity
         (list "" args )
         indent)))
    }
 * @return ${4:$(yas-text)}
 *
 **/
def ${2:name}($3): $4 = $0