2012-08-25 00:16:41 +02:00
|
|
|
;;; ein-testing-cell.el --- Testing utilities for cell module
|
|
|
|
|
|
|
|
;; Copyright (C) 2012 Takafumi Arakaki
|
|
|
|
|
|
|
|
;; Author: Takafumi Arakaki <aka.tkf at gmail.com>
|
|
|
|
|
|
|
|
;; This file is NOT part of GNU Emacs.
|
|
|
|
|
|
|
|
;; ein-testing-cell.el is free software: you can redistribute it
|
|
|
|
;; and/or modify it under the terms of the GNU General Public License
|
|
|
|
;; as published by the Free Software Foundation, either version 3 of
|
|
|
|
;; the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
;; ein-testing-cell.el is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with ein-testing-cell.el.
|
|
|
|
;; If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
(require 'json)
|
|
|
|
|
2012-08-26 19:55:28 +02:00
|
|
|
(defun ein:testing-codecell-pyout-data (text &optional prompt-number)
|
|
|
|
"Create a plist representing JSON data for code-cell output.
|
|
|
|
TEXT is a string and PROMPT-NUMBER is an integer."
|
|
|
|
(list :output_type "pyout"
|
|
|
|
:prompt_number (or prompt-number 0)
|
|
|
|
:text text))
|
|
|
|
|
2012-08-25 00:16:41 +02:00
|
|
|
(defun ein:testing-codecell-data (&optional input prompt-number outputs)
|
2012-08-26 19:55:28 +02:00
|
|
|
"Create a plist representing JSON data for code-type cell.
|
|
|
|
To make OUTPUTS data, use `ein:testing-codecell-pyout-data'."
|
2012-08-25 00:16:41 +02:00
|
|
|
(list :cell_type "code"
|
|
|
|
:input (or input "")
|
|
|
|
:language "python"
|
2012-08-26 20:17:15 +02:00
|
|
|
:outputs outputs
|
2012-08-25 00:16:41 +02:00
|
|
|
:collapsed json-false
|
|
|
|
:prompt_number prompt-number))
|
|
|
|
|
|
|
|
(defun ein:testing-textcell-data (&optional source cell-type)
|
|
|
|
(list :cell_type cell-type
|
|
|
|
:source (or source "")))
|
|
|
|
|
|
|
|
(defun ein:testing-markdowncell-data (&optional source)
|
|
|
|
(ein:testing-textcell-data source "markdown"))
|
|
|
|
|
|
|
|
(defun ein:testing-rawcell-data (&optional source)
|
|
|
|
(ein:testing-textcell-data source "raw"))
|
|
|
|
|
|
|
|
(defun ein:testing-htmlcell-data (&optional source)
|
|
|
|
(ein:testing-textcell-data source "html"))
|
|
|
|
|
|
|
|
(defun ein:testing-headingcell-data (&optional source level)
|
|
|
|
(append (ein:testing-textcell-data source "heading")
|
|
|
|
(list :level (or level 1))))
|
|
|
|
|
|
|
|
(provide 'ein-testing-cell)
|
|
|
|
|
|
|
|
;;; ein-testing-cell.el ends here
|