Liking cljdoc? Tell your friends :D

std.pretty.engine


annotate-beginclj

(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}]
raw docstring

annotate-rightclj

(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}]
raw docstring

format-nodesclj

(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"]
raw docstring

pprint-documentclj

(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"
raw docstring

serializeclj

(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}]
raw docstring

serialize-node-alignclj

(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}]
raw docstring

serialize-node-breakclj

(serialize-node-break & _)

creates a :break operation

(serialize-node-break [:break]) => [{:op :break}]

creates a :break operation

(serialize-node-break [:break])
=> [{:op :break}]
raw docstring

serialize-node-escapedclj

(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"}]
raw docstring

serialize-node-groupclj

(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}]
raw docstring

serialize-node-lineclj

(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 ""}]
raw docstring

serialize-node-nestclj

(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}]
raw docstring

serialize-node-passclj

(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"}]
raw docstring

serialize-node-spanclj

(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"}]
raw docstring

serialize-node-textclj

(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"}]
raw docstring

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

× close