(annotate-begin width)
(annotate-begin width {:keys [position buffers]})
recalculates :right
value of {:op :begin}
nodes given line width
(eduction (annotate-right) (annotate-begin 4) (serialize -doc-)) => [{:op :begin, :right :too-far} {:op :text, :text "A", :right 1} {:op :line, :inline " ", :terminate "", :right 2} {:op :nest, :offset 2, :right 2} {:op :text, :text "B", :right 3} {:op :line, :inline " ", :terminate "", :right 4} {:op :text, :text "C", :right 5} {:op :outdent, :right 5} {:op :line, :inline " ", :terminate "", :right 6} {:op :text, :text "D", :right 7} {:op :end, :right 7}]
recalculates `:right` value of `{:op :begin}` nodes given line width (eduction (annotate-right) (annotate-begin 4) (serialize -doc-)) => [{:op :begin, :right :too-far} {:op :text, :text "A", :right 1} {:op :line, :inline " ", :terminate "", :right 2} {:op :nest, :offset 2, :right 2} {:op :text, :text "B", :right 3} {:op :line, :inline " ", :terminate "", :right 4} {:op :text, :text "C", :right 5} {:op :outdent, :right 5} {:op :line, :inline " ", :terminate "", :right 6} {:op :text, :text "D", :right 7} {:op :end, :right 7}]
(annotate-right)
(annotate-right {:keys [position] :as state})
adds :right <position>
to all nodes
(def -doc- [:group "A" :line [:nest 2 "B" :line "C"] :line "D"])
(eduction (annotate-right) (serialize -doc-)) => [{:op :begin, :right 0} {:op :text, :text "A", :right 1} {:op :line, :inline " ", :terminate "", :right 2} {:op :nest, :offset 2, :right 2} {:op :text, :text "B", :right 3} {:op :line, :inline " ", :terminate "", :right 4} {:op :text, :text "C", :right 5} {:op :outdent, :right 5} {:op :line, :inline " ", :terminate "", :right 6} {:op :text, :text "D", :right 7} {:op :end, :right 7}]
adds `:right <position>` to all nodes (def -doc- [:group "A" :line [:nest 2 "B" :line "C"] :line "D"]) (eduction (annotate-right) (serialize -doc-)) => [{:op :begin, :right 0} {:op :text, :text "A", :right 1} {:op :line, :inline " ", :terminate "", :right 2} {:op :nest, :offset 2, :right 2} {:op :text, :text "B", :right 3} {:op :line, :inline " ", :terminate "", :right 4} {:op :text, :text "C", :right 5} {:op :outdent, :right 5} {:op :line, :inline " ", :terminate "", :right 6} {:op :text, :text "D", :right 7} {:op :end, :right 7}]
(format-nodes width)
(format-nodes width {:keys [fits length tab-stops column]})
formats nodes given line width
(eduction (annotate-right) (annotate-begin 4) (format-nodes 4) (serialize -doc-)) => ["" "A" "\n" " " "B" "\n" " " "C" "\n" "" "D"]
formats nodes given line width (eduction (annotate-right) (annotate-begin 4) (format-nodes 4) (serialize -doc-)) => ["" "A" "\n" " " "B" "\n" " " "C" "\n" "" "D"]
(pprint-document doc)
(pprint-document doc {:keys [width] :or {width 70}})
pretty prints a document
(with-out-str (pprint-document [:group "A" :line [:nest 2 "B" :line "C"] :line "D"])) => "A B C D"
(with-out-str (pprint-document [:group "A" :line [:nest 2 "B" :line "C"] :line "D"] {:width 4})) => "A\n B\n C\nD"
pretty prints a document (with-out-str (pprint-document [:group "A" :line [:nest 2 "B" :line "C"] :line "D"])) => "A B C D" (with-out-str (pprint-document [:group "A" :line [:nest 2 "B" :line "C"] :line "D"] {:width 4})) => "A\n B\n C\nD"
(serialize input)
main serialize method, converts input into a set of operations
(serialize [:span "apple" [:group "ball" :line "cat"]]) => [{:op :text, :text "apple"} {:op :begin} {:op :text, :text "ball"} {:op :line, :inline " ", :terminate ""} {:op :text, :text "cat"} {:op :end}]
main serialize method, converts input into a set of operations (serialize [:span "apple" [:group "ball" :line "cat"]]) => [{:op :text, :text "apple"} {:op :begin} {:op :text, :text "ball"} {:op :line, :inline " ", :terminate ""} {:op :text, :text "cat"} {:op :end}]
(serialize-node-align [_ & args])
creates an :align operation
(serialize-node-align [:align 2 "apple" "ball"]) => [{:op :align, :offset 2} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :outdent}]
creates an :align operation (serialize-node-align [:align 2 "apple" "ball"]) => [{:op :align, :offset 2} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :outdent}]
(serialize-node-break & _)
creates a :break operation
(serialize-node-break [:break]) => [{:op :break}]
creates a :break operation (serialize-node-break [:break]) => [{:op :break}]
(serialize-node-escaped [_ text])
creates an :escaped operation
(serialize-node-escaped [:escaped "apple"]) => [{:op :escaped, :text "apple"}]
creates an :escaped operation (serialize-node-escaped [:escaped "apple"]) => [{:op :escaped, :text "apple"}]
(serialize-node-group [_ & children])
creates a :group operation
(serialize-node-group [:group "apple" "ball"]) => [{:op :begin} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :end}]
creates a :group operation (serialize-node-group [:group "apple" "ball"]) => [{:op :begin} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :end}]
(serialize-node-line [_ inline terminate])
creates a :line operation
(serialize-node-line [:line]) => [{:op :line, :inline " ", :terminate ""}]
creates a :line operation (serialize-node-line [:line]) => [{:op :line, :inline " ", :terminate ""}]
(serialize-node-nest [_ & args])
creates a :nest operation
(serialize-node-nest [:nest 2 "apple" "ball"]) => [{:op :nest, :offset 2} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :outdent}]
creates a :nest operation (serialize-node-nest [:nest 2 "apple" "ball"]) => [{:op :nest, :offset 2} {:op :text, :text "apple"} {:op :text, :text "ball"} {:op :outdent}]
(serialize-node-pass [_ & text])
creates a :pass operation
(serialize-node-pass [:pass "apple" "ball"]) => [{:op :pass, :text "appleball"}]
creates a :pass operation (serialize-node-pass [:pass "apple" "ball"]) => [{:op :pass, :text "appleball"}]
(serialize-node-span [_ & children])
creates a :span operation
(serialize-node-span [:span "apple" "ball"]) => [{:op :text, :text "apple"} {:op :text, :text "ball"}]
creates a :span operation (serialize-node-span [:span "apple" "ball"]) => [{:op :text, :text "apple"} {:op :text, :text "ball"}]
(serialize-node-text [_ & text])
creates a :text operation
(serialize-node-text [:text "apple" "ball"]) => [{:op :text, :text "appleball"}]
creates a :text operation (serialize-node-text [:text "apple" "ball"]) => [{:op :text, :text "appleball"}]
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close