Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.2 KiB

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