Last active
October 25, 2017 06:07
-
-
Save tom-tan/d5814bbc6f213c428455120141bca264 to your computer and use it in GitHub Desktop.
cwl のワークフローを可視化したい
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; requirements: cwltool, graphviz, open コマンド | |
(defvar cwl-workflow-figure nil) | |
(make-variable-buffer-local 'cwl-workflow-figure) | |
(defun cwl-generate-figure (&optional buffer) | |
(interactive) | |
(unless flycheck-current-errors | |
(let* ((tmpdir "/tmp/") | |
(cwl (buffer-file-name buffer)) | |
(base (file-name-base cwl)) | |
(dot (concat tmpdir base ".dot")) | |
(pdf (concat tmpdir base ".pdf")) | |
(pt (point))) | |
(goto-char (point-min)) | |
(when (re-search-forward (rx "class:" (zero-or-more blank) "Workflow") nil t) | |
(progn | |
(async-shell-command | |
(format "cwltool --print-dot %s > %s; dot %s -Tpdf -o %s" cwl dot dot pdf)) | |
(setq cwl-workflow-figure pdf))) | |
(goto-char pt)))) | |
(defun cwl-view-workflow () | |
(interactive) | |
;;; 今のところ Mac 限定: open は他の OS に存在しない | |
(shell-command (concat "open " cwl-workflow-figure))) | |
(add-hook 'after-save-hook | |
(lambda () | |
(when (eq major-mode 'cwl-mode) | |
(cwl-generate-figure)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment