Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix doc strings

  • Loading branch information...
commit 768d670fdedb8c82c567086acd11543faff95fba 1 parent 35a9546
@joodie joodie authored
Showing with 22 additions and 12 deletions.
  1. +22 −12 src/clojure_refactoring/support/core.clj
View
34 src/clojure_refactoring/support/core.clj
@@ -3,8 +3,9 @@
[clojure.contrib.seq-utils :only [find-first]]
[clojure.walk :only [postwalk-replace]]))
-(defn format-code [node]
+(defn format-code
"Outputs code roughly how a human would format it."
+ [node]
(with-out-str
(with-pprint-dispatch *code-dispatch*
(pprint node))))
@@ -14,50 +15,59 @@
(fn [& fns] (fn [& args]
(f identity (map apply fns (repeat args))))))
-(def any-of? ^{:doc "Takes predicates and returns a function
+(def ^{:doc "Takes predicates and returns a function
that returns true if any of the predicates are true"}
- (predicater-by some))
+ any-of?
+ (predicater-by some))
-(def all-of? ^{:doc "Takes predicates and returns a function
+(def ^{:doc "Takes predicates and returns a function
that returns true if all of the predicates are true"}
- (predicater-by every?))
+ all-of?
+ (predicater-by every?))
(defn sub-nodes [tree]
(tree-seq (any-of? sequential? map? set?)
seq tree))
-(defn count= [seq n]
+(defn count=
"Checks if the count of seq is equal to n"
+ [seq n]
(= (count seq) n))
(def binding-forms
#{'let 'fn 'binding 'for 'doseq 'dotimes 'defn 'loop 'defmacro
'if-let 'when-let 'defn- 'defmethod 'defmethod-})
-(defn evens [coll]
+(defn evens
"Returns every other item of coll"
+ [coll]
(take-nth 2 coll))
-(defn tree-contains? [coll obj]
+(defn tree-contains?
"True if coll contains obj at some level of nesting"
+ [coll obj]
(some #{obj} (sub-nodes coll)))
-(defn replace-when [pred f coll]
+(defn replace-when
"Replaces each element of coll if pred returns true on it."
+ [pred f coll]
(map
(fn [elem]
(if (pred elem) (f elem) elem)) coll))
-(defn first= [x y]
+(defn first=
+ [x y]
(= (first x) y))
-(defn but-second [coll]
+(defn but-second
+ [coll]
(->> (first coll)
(conj (drop 2 coll))))
-(defn after-each [pred elems coll]
+(defn after-each
"After each item in coll that matches predicate
add elems."
+ [pred elems coll]
(reduce
(fn [accum elem]
(if (pred elem)
Please sign in to comment.
Something went wrong with that request. Please try again.