Skip to content
Permalink
Browse files

Fixing tests

  • Loading branch information
zcaudate committed Apr 21, 2015
1 parent f93af23 commit f2b36ab1d46cfc39516a958d4a8f570b9f43008e
Showing with 30 additions and 28 deletions.
  1. +2 −1 .gitignore
  2. +7 −7 project.clj
  3. +8 −8 src/leiningen/midje_doc/import.clj
  4. +13 −12 src/leiningen/midje_doc/run/parser.clj
@@ -16,4 +16,5 @@ pom.xml.asc
*.html
/example
/scratch
.DS_Store
.DS_Store
*.*#
@@ -1,18 +1,18 @@
(defproject lein-midje-doc "0.0.24"
(defproject lein-midje-doc "0.0.25"
:description "Documentation generator for midje"
:url "http://www.github.com/zcaudate/lein-midje-doc"
:license {:name "The MIT License"
:url "http://http://opensource.org/licenses/MIT"}
:dependencies [[org.clojure/clojure "1.5.1"]
[rewrite-clj "0.3.9"]
[hiccup "1.0.4"]
:dependencies [[org.clojure/clojure "1.6.0"]
[rewrite-clj "0.4.12"]
[hiccup "1.0.5"]
[markdown-clj "0.9.29"]
[stencil "0.3.2"]
[stencil "0.3.5"]
[me.raynes/conch "0.6.0"]
[org.clojars.zcaudate/watchtower "0.1.2"]]
:profiles {:dev {:dependencies [[midje "1.6.3"]
[leiningen "2.5.0"]
[lein-midje "3.1.3"]]}}
[leiningen "2.5.0"]]
:plugins [[lein-midje "3.1.3"]]}}
:documentation {:files {"docs/index"
{:input "test/midje_doc/midje_doc_guide.clj"
:title "midje-doc"
@@ -1,6 +1,6 @@
(ns leiningen.midje-doc.import
(:require [rewrite-clj.zip :as z]
[rewrite-clj.printer :as p]
;;[rewrite-clj.printer :as p]
[clojure.java.io :as io]
[clojure.string :as string]
[leiningen.midje-doc.common :refer :all])
@@ -9,7 +9,7 @@
(defn fact-attr [zloc]
(and (= :meta (z/tag zloc))
(-> zloc z/value)
(-> zloc z/value p/->string read-string)))
(-> zloc z/value z/->string read-string)))

(defn fact-form [zloc]
(if (= :meta (z/tag zloc))
@@ -79,7 +79,7 @@
(defn fact-doc [zloc]
(->> ((compose z/down z/right z/down z/right) zloc)
(fact-to-doc-nodes)
(map p/->string)
(map z/->string)
(apply str)))

(defn fact-pair [zloc]
@@ -102,23 +102,23 @@
nstr (str (z/value nloc))]
(if-let [{:keys [attrs docs]} (get idx nstr)]
(let [dloc (-> nloc
(fast-zip.core/insert-right
(clojure.zip/insert-right
[:newline "\n"])
(z/right*)
(fast-zip.core/insert-right
(clojure.zip/insert-right
[:whitespace " "])
(z/right*)
(fast-zip.core/insert-right
(clojure.zip/insert-right
(apply vector :multi-line
(string/split-lines docs)))
(z/right*))
attrloc (if (empty? attrs)
dloc
(-> dloc
(fast-zip.core/insert-right
(clojure.zip/insert-right
[:newline "\n"])
(z/right*)
(fast-zip.core/insert-right
(clojure.zip/insert-right
[:whitespace " "])
(z/right*)
(z/insert-right attrs)))]
@@ -1,6 +1,7 @@
(ns leiningen.midje-doc.run.parser
(:require [rewrite-clj.parser :as p]
[rewrite-clj.zip :as z]
[rewrite-clj.node :as node]
[stencil.core :as stc]
[hiccup.util :refer [escape-html]]))

@@ -22,40 +23,40 @@
(z/tag sfzip))
(cond (nil? pred) true
:else
(let [v (-> sfzip z/down z/node)]
(let [v (-> sfzip z/down z/sexpr)]
(if (fn? pred)
(pred v)
(= v pred))))))))

(defn file-element? [fzip]
(double-vector? fzip [:token :file]))
(double-vector? fzip :file))

(defn ns-element? [fzip]
(double-vector? fzip [:token :ns]))
(double-vector? fzip :ns))

(defn chapter-element? [fzip]
(double-vector? fzip [:token :chapter]))
(double-vector? fzip :chapter))

(defn include-element? [fzip]
(double-vector? fzip [:token :include]))
(double-vector? fzip :include))

(defn section-element? [fzip]
(double-vector? fzip [:token :section]))
(double-vector? fzip :section))

(defn subsection-element? [fzip]
(double-vector? fzip [:token :subsection]))
(double-vector? fzip :subsection))

(defn subsubsection-element? [fzip]
(double-vector? fzip [:token :subsubsection]))
(double-vector? fzip :subsubsection))

(defn image-element? [fzip]
(double-vector? fzip [:token :image]))
(double-vector? fzip :image))

(defn paragraph-element? [fzip]
(double-vector? fzip [:token :paragraph]))
(double-vector? fzip :paragraph))

(defn code-element? [fzip]
(double-vector? fzip [:token :code]))
(double-vector? fzip :code))

(defn paragraph? [fzip]
(and (= :token (z/tag fzip))
@@ -65,7 +66,7 @@
(= :multi-line (z/tag fzip)))

(defn attribute? [fzip]
(double-vector? fzip #(-> % first (= :map))))
(double-vector? fzip map?))

(defn whitespace? [fzip]
(= :whitespace (z/tag fzip)))

0 comments on commit f2b36ab

Please sign in to comment.
You can’t perform that action at this time.