diff options
| author | Stig Brautaset <sbrautaset@laterpay.net> | 2016-02-24 19:52:05 +0000 |
|---|---|---|
| committer | Stig Brautaset <sbrautaset@laterpay.net> | 2016-02-25 14:00:10 +0000 |
| commit | 79e619a78f70dc9b4a3ad197085302946b690a90 (patch) | |
| tree | 727e904ab27c0cef5c5c5daeebdda1670e41cecb | |
| parent | 759f2cddec547a9fc9940fa9de8d7c4c558b87c5 (diff) | |
Replaced bootstrap tests with one that actually invokes org
Add transcoders for `section' and `headline' elements to make our
initial test pass!
| -rw-r--r-- | ox-jira.el | 16 | ||||
| -rw-r--r-- | ox-jira.org | 33 | ||||
| -rw-r--r-- | test/ox-jira-test.el | 14 | ||||
| -rw-r--r-- | test/ox-jira-test.org | 20 |
4 files changed, 58 insertions, 25 deletions
@@ -40,7 +40,9 @@ (org-export-define-backend 'jira '((bold . org-jira-bold) - (paragraph . org-jira-paragraph)) + (headline . org-jira-headline) + (paragraph . org-jira-paragraph) + (section . org-jira-section)) :menu-entry '(?j "Export to JIRA" ((?j "As JIRA buffer" org-jira-export-as-jira)))) @@ -53,12 +55,24 @@ CONTENTS is the text with bold markup. INFO is a plist holding contextual information." (format "*%s*" contents)) +(defun org-jira-headline (headline contents info) + "Transcode a HEADLINE element from Org to JIRA. +CONTENTS is the contents of the headline, as a string. INFO is +the plist used as a communication channel." + contents) + (defun org-jira-paragraph (paragraph contents info) "Transcode a PARAGRAPH element from Org to JIRA. CONTENTS is the contents of the paragraph, as a string. INFO is the plist used as a communication channel." contents) +(defun org-jira-section (section contents info) + "Transcode a SECTION element from Org to JIRA. +CONTENTS is the contents of the section, as a string. INFO is +the plist used as a communication channel." + contents) + (defun org-jira-export-as-jira (&optional async subtreep visible-only body-only ext-plist) "Export current buffer as a Jira buffer. diff --git a/ox-jira.org b/ox-jira.org index d4a26da..6fa1e31 100644 --- a/ox-jira.org +++ b/ox-jira.org @@ -129,7 +129,9 @@ #+BEGIN_SRC emacs-lisp (org-export-define-backend 'jira '((bold . org-jira-bold) - (paragraph . org-jira-paragraph)) + (headline . org-jira-headline) + (paragraph . org-jira-paragraph) + (section . org-jira-section)) :menu-entry '(?j "Export to JIRA" ((?j "As JIRA buffer" org-jira-export-as-jira)))) @@ -153,6 +155,16 @@ (format "*%s*" contents)) #+END_SRC +**** Headline + + #+BEGIN_SRC emacs-lisp + (defun org-jira-headline (headline contents info) + "Transcode a HEADLINE element from Org to JIRA. + CONTENTS is the contents of the headline, as a string. INFO is + the plist used as a communication channel." + contents) + #+END_SRC + **** Paragraph #+BEGIN_SRC emacs-lisp @@ -163,6 +175,20 @@ contents) #+END_SRC +**** Section + + Paragraphs are grouped into sections. I've not found any mention in the + Org documentation, but it appears to be essential for any export to + happen. I've essentially cribbed this from `ox-latex.el`[fn:1]. + + #+BEGIN_SRC emacs-lisp + (defun org-jira-section (section contents info) + "Transcode a SECTION element from Org to JIRA. + CONTENTS is the contents of the section, as a string. INFO is + the plist used as a communication channel." + contents) + #+END_SRC + *** End-user functions This is our main export function. This can be called from @@ -223,3 +249,8 @@ All that does is help people figure out if a file has been truncated. If they see that comment, they know they don't have just half the file. Weird, huh? + +* Footnotes + +[fn:1] Does this mean I have to use the GPL? Is a NOOP function _that you have +to implement to satisfy an interface_ subject to copyright? diff --git a/test/ox-jira-test.el b/test/ox-jira-test.el index 7e646c0..00f9169 100644 --- a/test/ox-jira-test.el +++ b/test/ox-jira-test.el @@ -1,4 +1,3 @@ - ;;; ox-jira-test.el --- tests for ox-jira.el ;;; Author: Stig Brautaset <stig@brautaset.org> @@ -28,18 +27,11 @@ ;;; Code: (require 'ert) +(require 'ox) (require 'ox-jira) -(ert-deftest test-bootstrap-success () - (should (equal 1 1)) - (should (equal "foo" "foo"))) - -(ert-deftest test-bootstrap-fail () - (should (equal "foo" "bar"))) - - -(ert-deftest test-bootstrap-success-2 () - (should (equal 4 4))) +(ert-deftest ox-jira-test/hello-world () + (should (equal "hello world\n" (org-export-string-as "hello world" 'jira)))) (provide 'ox-jira-test) diff --git a/test/ox-jira-test.org b/test/ox-jira-test.org index 3bc2e67..622fa61 100644 --- a/test/ox-jira-test.org +++ b/test/ox-jira-test.org @@ -1,6 +1,6 @@ #+TITLE: ox-jira-test #+AUTHOR: Stig Brautaset -#+PROPERTY: header-args:emacs-lisp :tangle yes +#+PROPERTY: header-args:emacs-lisp :tangle yes :results silent * ox-jira-test.el --- tests for ox-jira.el This is my first foray into testing in Emacs. Please be patient. @@ -71,22 +71,18 @@ #+BEGIN_SRC emacs-lisp (require 'ert) + (require 'ox) (require 'ox-jira) #+END_SRC -*** Define a bootstrapping test that doesn't require ox-jira at all +*** Hello World - #+BEGIN_SRC emacs-lisp - (ert-deftest test-bootstrap-success () - (should (equal 1 1)) - (should (equal "foo" "foo"))) - - (ert-deftest test-bootstrap-fail () - (should (equal "foo" "bar"))) - - (ert-deftest test-bootstrap-success-2 () - (should (equal 4 4))) + Let's write the simplest possible test that actually invokes anything org + export related. + #+BEGIN_SRC emacs-lisp + (ert-deftest ox-jira-test/hello-world () + (should (equal "hello world\n" (org-export-string-as "hello world" 'jira)))) #+END_SRC *** Provide |
