Liking cljdoc? Tell your friends :D

lucid.publish.parse


*indentation*clj


*namespace*clj


*spacing*clj


code-formclj

(code-form zloc symbol)

converts a form zipper into a code string

(-> (z/of-string "(fact (+ 1 1) \n => 2)") (code-form 'fact)) => "(+ 1 1) \n => 2"

converts a form zipper into a code string

(-> (z/of-string "(fact (+ 1 1) \n => 2)")
    (code-form 'fact))
=> "(+ 1 1) \n  => 2"
raw docstring

is-code-formclj

(is-code-form zloc)

converts the is form into a string

(is-code-form (z/of-string "(is (= (+ 1 1) 2))")) => "(+ 1 1)\n => 2"

(is-code-form (z/of-string "(is true)")) => "true"

converts the `is` form into a string

(is-code-form (z/of-string "(is (= (+ 1 1) 2))"))
=> "(+ 1 1)\n  => 2"

(is-code-form (z/of-string "(is true)"))
=> "true"
raw docstring

merge-currentclj

(merge-current output current)

if not whitespace, then merge output

if not whitespace, then merge output
raw docstring

parse-attributeclj

(parse-attribute zloc)

coverts an attribute zipper into an element

(-> (z/of-string "[[{:title "hello world"}]]") (parse-attribute)) => {:type :attribute, :title "hello world"}

coverts an attribute zipper into an element

(-> (z/of-string "[[{:title \"hello world\"}]]")
    (parse-attribute))
=> {:type :attribute, :title "hello world"}
raw docstring

parse-codeclj

(parse-code zloc)

coverts a code zipper into an element

(-> (z/of-string "(+ 1 1) (+ 2 2)") (parse-code)) => {:type :code, :indentation 0, :code ["(+ 1 1)"]}

coverts a code zipper into an element

(-> (z/of-string "(+ 1 1) (+ 2 2)")
    (parse-code))
=> {:type :code, :indentation 0, :code ["(+ 1 1)"]}
raw docstring

parse-code-directiveclj

(parse-code-directive zloc)

coverts an code directive zipper into an element

(-> (z/of-string "[[:code {:language :ruby} "1 + 1 == 2"]]") (parse-code-directive)) => {:type :block, :indentation 0 :code "1 + 1 == 2" :language :ruby}

coverts an code directive zipper into an element

(-> (z/of-string "[[:code {:language :ruby} \"1 + 1 == 2\"]]")
    (parse-code-directive))
=> {:type :block, :indentation 0 :code "1 + 1 == 2" :language :ruby}
raw docstring

parse-comment-formclj

(parse-comment-form zloc)

convert a comment zipper into an element

(-> (z/of-string "(comment (+ 1 1) \n => 2)") (parse-comment-form)) => {:type :block :indentation 2 :code "(+ 1 1) \n => 2"}

convert a comment zipper into an element

(-> (z/of-string "(comment (+ 1 1) \n => 2)")
    (parse-comment-form))
=> {:type :block :indentation 2 :code "(+ 1 1) \n => 2"}
raw docstring

parse-deftest-formclj

(parse-deftest-form zloc)

converts the deftest form into an element

(-> (z/of-string "(deftest hello)") (parse-deftest-form)) => {:type :test, :source {:row 1, :col 1, :end-row 1, :end-col 16}}

converts the `deftest` form into an element

(-> (z/of-string "(deftest hello)")
    (parse-deftest-form))
=> {:type :test, :source {:row 1, :col 1, :end-row 1, :end-col 16}}
raw docstring

parse-directiveclj

(parse-directive zloc)

converts a directive zipper into an element

(-> (z/of-string "[[:chapter {:title "hello world"}]]") (parse-directive)) => {:type :chapter :title "hello world"}

(binding [namespace 'example.core] (-> (z/of-string "[[:ns {:title "hello world"}]]") (parse-directive))) => {:type :ns, :title "hello world", :ns 'example.core}

converts a directive zipper into an element

(-> (z/of-string "[[:chapter {:title \"hello world\"}]]")
    (parse-directive))
=> {:type :chapter :title "hello world"}

(binding [*namespace* 'example.core]
  (-> (z/of-string "[[:ns {:title \"hello world\"}]]")
      (parse-directive)))
=> {:type :ns, :title "hello world", :ns 'example.core}
raw docstring

parse-fact-formclj

(parse-fact-form zloc)

convert a fact zipper into an element

(-> (z/of-string "(fact (+ 1 1) \n => 2)") (parse-fact-form)) => {:type :test :indentation 2 :code "(+ 1 1) \n => 2"}

convert a fact zipper into an element

(-> (z/of-string "(fact (+ 1 1) \n => 2)")
    (parse-fact-form))
=> {:type :test :indentation 2 :code "(+ 1 1) \n => 2"}
raw docstring

parse-facts-formclj

(parse-facts-form zloc)

converts a facts zipper into an element

(-> (z/of-string "(facts (+ 1 1) \n => 2)") (parse-facts-form)) => {:type :test :indentation 2 :code "(+ 1 1) \n => 2"}

converts a facts zipper into an element

(-> (z/of-string "(facts (+ 1 1) \n => 2)")
    (parse-facts-form))
=> {:type :test :indentation 2 :code "(+ 1 1) \n => 2"}
raw docstring

parse-fileclj

(parse-file file opts)

parses the entire file

parses the entire file
raw docstring

parse-innerclj

(parse-inner zloc f output current opts)

parses the inner form of the fact and comment function

parses the inner form of the fact and comment function
raw docstring

parse-is-formclj

(parse-is-form zloc)

converts an is form into an element (-> (z/of-string "(is (= (+ 1 1) 2))") (parse-is-form)) => {:type :block, :indentation 2, :code "(+ 1 1)\n=> 2"}

converts an `is` form into an element
(-> (z/of-string "(is (= (+ 1 1) 2))")
    (parse-is-form))
=> {:type :block, :indentation 2, :code "(+ 1 1)\n=> 2"}
raw docstring

parse-loopclj

(parse-loop zloc opts)
(parse-loop zloc opts current output)

the main loop for the parser

(-> (z/of-string "(ns example.core) [[:chapter {:title "hello"}]] (+ 1 1) (+ 2 2)") (parse-loop {}))

=> (contains-in [{:type :ns-form, :indentation 0, :ns 'example.core, :code "(ns example.core)"} {:type :chapter, :title "hello"} {:type :code, :indentation 0, :code ["(+ 1 1)" " " "\n" " " "(+ 2 2)"]}])

the main loop for the parser

(-> (z/of-string "(ns example.core) 
                  [[:chapter {:title \"hello\"}]] 
                  (+ 1 1) 
                  (+ 2 2)")
    (parse-loop {}))

=> (contains-in
    [{:type :ns-form,
     :indentation 0,
      :ns 'example.core,
      :code "(ns example.core)"}
     {:type :chapter, :title "hello"}
     {:type :code, :indentation 0, :code ["(+ 1 1)"
                                          " "
                                          "\n"
                                          "                    "
                                          "(+ 2 2)"]}])
raw docstring

parse-ns-formclj

(parse-ns-form zloc)

converts a ns zipper into an element

(-> (z/of-string "(ns example.core)") (parse-ns-form)) => {:type :ns-form :indentation 0 :meta {} :ns 'example.core :code "(ns example.core)"}

converts a ns zipper into an element

(-> (z/of-string "(ns example.core)")
    (parse-ns-form))
=> {:type :ns-form
    :indentation 0
    :meta {}
    :ns 'example.core
   :code "(ns example.core)"}
raw docstring

parse-paragraphclj

(parse-paragraph zloc)

converts a string zipper into an element

(-> (z/of-string ""this is a paragraph"") (parse-paragraph)) => {:type :paragraph :text "this is a paragraph"}

converts a string zipper into an element

(-> (z/of-string "\"this is a paragraph\"")
    (parse-paragraph))
=> {:type :paragraph :text "this is a paragraph"}
raw docstring

parse-singleclj

(parse-single zloc)

parse a single zloc

parse a single zloc
raw docstring

parse-whitespaceclj

(parse-whitespace zloc)

coverts a whitespace zipper into an element

(-> (z/of-string "1 2 3") (z/right*) (parse-whitespace)) => {:type :whitespace, :code [" "]}

coverts a whitespace zipper into an element

(-> (z/of-string "1 2 3")
    (z/right*)
    (parse-whitespace))
=> {:type :whitespace, :code [" "]}
raw docstring

wrap-line-infoclj

(wrap-line-info f)

helper to add the line information to the parser (used by parse-loop)

helper to add the line information to the parser (used by `parse-loop`)
raw docstring

wrap-metaclj

(wrap-meta f)

if form is meta, then go down a level

if form is meta, then go down a level
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close