Skip to content

Commit

Permalink
Fixing travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Zheng committed Apr 19, 2014
1 parent b445576 commit e21fb9e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 89 deletions.
1 change: 1 addition & 0 deletions .nrepl-port
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
52539
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: clojure
lein: lein2
script: lein2 midje
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

`lein-midje-doc` fixes the problem of incorrectly documented examples by bridging the gap between writing tests and writing documentation.

[![Build Status](https://travis-ci.org/zcaudate/lein-midje-doc.svg?branch=master)](https://travis-ci.org/zcaudate/lein-midje-doc)

### Installation

Expand Down
6 changes: 3 additions & 3 deletions test/leiningen/midje_doc/test_midje_doc.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns midje-doc.test-midje-doc
(:require [leiningen.midje-doc :refer [process-doc]] :reload))
(ns leiningen.midje-doc.test-midje-doc
(:require [leiningen.midje-doc.run :refer [run-doc]] :reload))


#_(process-doc "my-first-document"
Expand All @@ -11,7 +11,7 @@
:version "v0.0.12"
:website "www.example.com"})

(process-doc "my-first-document"
#_(run-doc "my-first-document"
{:input "/Users/zhengc/dev/chit/purnam-angular/test/cljs/midje_doc/purnam_angular_guide.cljs"
:title "purnam.angular"
:sub-title "Angular.js DSL in Clojurescript"
Expand Down
120 changes: 41 additions & 79 deletions test/leiningen/midje_doc/test_parser.clj
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
(ns leiningen.midje-doc.test-parser
(:require [midje.sweet :refer :all]
[leiningen.midje-doc.parser :as t]
[leiningen.midje-doc.renderer :as r]
[leiningen.midje-doc.run.parser :as t]
[leiningen.midje-doc.run.renderer :as r]
[rewrite-clj.zip :as z]
[hiccup.core :as html]
[me.raynes.conch :refer [programs]]))

(fact "doc-element?"
(t/doc-element?
(z/of-string "[[:document {}]]"))
=> true)

(fact "chapter-element?"
(t/chapter-element?
(z/of-string "[[:chapter {}]]"))
Expand All @@ -25,18 +20,20 @@
(z/of-string "[[{:hello :world}]]") {} {})
=> [[] {:attrs {:hello :world}} {}])

(t/parse-chapter-element
(z/of-string "[[:chapter {:title \"Standard Exception Flow\"}]]") {:chapter 1} {})
[({:tag "standard-exception-flow", :num "2", :type :chapter, :title "Standard Exception Flow"})
{:example 1, :section 1, :subsubsection 1, :fact-level 0, :subsection 1, :chapter 2}
{"standard-exception-flow" "2"}]

(fact "parse-chapter-element"
(t/parse-chapter-element
(z/of-string "[[:chapter {:title \"Standard Exception Flow\"}]]") {:chapter 1} {})
'[({:tag "standard-exception-flow", :num "2", :type :chapter, :title "Standard Exception Flow"})
{:example 1, :section 1, :subsubsection 1, :fact-level 0, :subsection 1, :chapter 2}
{"standard-exception-flow" "2"}])


(fact
(t/parse-image-element
(z/of-string "[[:image {:src \"image.png\" :height \"100px\"}]]")
{:chapter 1 :image 1} {})
=> [[{:num "1.1", :type :image, :height "100px", :src "image.png"}]
=> [[{:num "2", :type :image, :height "100px", :src "image.png"}]
{:image 2, :chapter 1} {}])

(fact
Expand Down Expand Up @@ -74,10 +71,9 @@

(z/of-string "() ;;hello")

(spit "test.html"
(r/render
(comment
(t/parse-content
(z/of-string "[[:chapter {:tag \"heel\"}]]
(z/of-string "[[:chapter {:tag \"heel\"}]]
[[:chapter {}]]
[[:section {}]]
(fact
Expand All @@ -86,74 +82,40 @@
[[{:tag \"first-eq\"}]]
(inc 1) => (int 12
[23 454])
[[:chapter {}]])"))))
[[:chapter {}]])"))


(spit "ribol.html"
(r/render-elements
(t/parse-content
(z/of-file
"/Users/Chris/dev/chit/ribol/test/ribol/test_ribol_strategies.clj"))))

(spit
"example/hello-ribol.html"
(html/html
[:html
[:head
[:style
(str
(slurp "example/bootstrap.css")
"\n\n"
(slurp "example/shCore.css")
"\n\n")]
[:script {:type "text/javascript"}
(str
(slurp "example/shCore.js")
"\n\n"
(slurp "example/shBrushClojure.js")
"\n\nSyntaxHighlighter.all()"
"\n\n")]]
[:body {:class "container"}
[:div {:class "row"}
[:div {:class "col-lg-1"}]
[:div {:class "col-lg-3"}
[:h1 "Ribol"]
[:hr]
[:h4 [:a {:href "#overview"} "1   Overview"]]
[:h4 [:a {:href "#standard-exception-flow"} "2   Standard Exception Flow"]]
[:h4 [:i " &nbsp"
[:a {:href "#standard-exception-flow"} "2.1   Normal Operation"]]]

[:div {:class "col-lg-7"}
(map r/render-element
(t/parse-content
(z/of-file
"/Users/Chris/dev/chit/ribol/test/ribol/test_ribol_strategies.clj")))]]]])))
#_(spit "ribol.html"
(r/render-elements
(t/parse-content
(z/of-file
"/Users/Chris/dev/chit/ribol/test/ribol/test_ribol_strategies.clj"))))

(fact
(binding [r/*plain* true]
(r/render-html-doc
"minimal-ribol.html"
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author "Chris Zheng" :email "z@caudate.me" :version "0.0.9" :revision "0.1"}
(t/parse-content
(z/of-string "[[:file {:src \"/Users/Chris/dev/chit/ribol/test/ribol/test_ribol_strategies.clj\"}]]"))))
=> nil)
(fact
(binding [r/*plain* true]
(r/render-html-doc
"minimal-ribol.html"
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author "Chris Zheng" :email "z@caudate.me" :version "0.0.9" :revision "0.1"}
(t/parse-content
(z/of-string "[[:file {:src \"/Users/Chris/dev/chit/ribol/test/ribol/test_ribol_strategies.clj\"}]]"))))
=> nil)

(fact
(binding [r/*plain* true]
(r/render-html-doc
"minimal-ribol.html"
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author "Chris Zheng" :email "z@caudate.me" :version "0.0.9" :revision "0.1"}
(t/parse-content (z/of-file "test/midje_doc/midje_doc_guide.clj"))))
=> nil)
(fact
(binding [r/*plain* true]
(r/render-html-doc
"minimal-ribol.html"
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author "Chris Zheng" :email "z@caudate.me" :version "0.0.9" :revision "0.1"}
(t/parse-content (z/of-file "test/midje_doc/midje_doc_guide.clj"))))
=> nil)

(r/render-heading
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author ""})
(r/render-heading
{:title "Ribol Strategies" :sub-title "Use Cases for Conditional Resets" :author ""})


(fact
(t/parse-content
(z/of-string "(int 1) => 1"))
=> [{:tag nil, :num "0.1", :content "\n(int 1)\n => 1", :type :code}])
(fact
(t/parse-content
(z/of-string "(int 1) => 1"))
=> [{:tag nil, :num "0.1", :content "\n(int 1)\n => 1", :type :code}])

(clojure.java.shell/sh "bash" "echo" "'ouoeuoe'")
(clojure.java.shell/sh "bash" "echo" "'ouoeuoe'")
)
11 changes: 6 additions & 5 deletions test/midje_doc/api.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(ns midje-doc.api)
(ns midje-doc.api
(:use midje.sweet))

[[:chapter {:title "API Reference"}]]

Expand Down Expand Up @@ -203,7 +204,7 @@ Documentation examples put in `facts` forms allows the code to be verified for c
(deref a) => 1

[[{:title "Updating the atom" :tag "c-facts-2"}]]
(update a inc 1)
(swap! a inc)
(deref a) => 2))

(facts
Expand All @@ -212,7 +213,7 @@ Documentation examples put in `facts` forms allows the code to be verified for c
(deref a) => 1

[[{:title "Updating the atom" :tag "c-factss-2"}]]
(update a inc 1)
(swap! a inc)
(deref a) => 2)

[[:subsection {:title "fact form"}]]
Expand All @@ -226,15 +227,15 @@ Documentation examples put in `facts` forms allows the code to be verified for c
(def a (atom 1))
(deref a) => 1

(update a inc 1)
(swap! a inc 1)
(deref a) => 2))

[[{:title "Fact Form Output"}]]
(fact
(def a (atom 1))
(deref a) => 1

(update a inc 1)
(swap! a inc)
(deref a) => 2)

[[:subsection {:title "comments"}]]
Expand Down
4 changes: 2 additions & 2 deletions test/midje_doc/my_first_document.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@


(fact
(+ 1 0) => 2
(+ 1 3) => 2)
(+ 1 0) => 1
(+ 1 3) => 4)

(comment
(+ 1 1) => 2
Expand Down

0 comments on commit e21fb9e

Please sign in to comment.