Permalink
Browse files

added/changes some docstrings

  • Loading branch information...
1 parent d122801 commit 9ac25a0e1d3f8f2e4343ea45edeeb3e9693e7d66 @senior senior committed Jan 27, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/main/clojure/clojure/data/xml.clj
@@ -249,8 +249,8 @@
(.getEncoding stream) ")")))))
(defn emit-stream
- "Prints the given Element tree as XML text to *out*. See element-tree.
- Options:
+ "Prints the given Element tree as XML text to stream.
+ Options:
:indent <num> Amount to increase indent depth each time
:encoding <str> Character encoding to use"
[e ^java.io.Writer stream & {:as opts}]
@@ -265,7 +265,12 @@
(.writeEndDocument writer)
stream))
-(defn emit [e & {:as opts}]
+(defn emit
+ "Prints the given Element tree as XML text to *out*.
+ Options:
+ :indent <num> Amount to increase indent depth each time
+ :encoding <str> Character encoding to use"
+ [e & {:as opts}]
(apply emit-stream e *out* opts))
(defn indenting-transformer []
@@ -274,7 +279,11 @@
(.setOutputProperty (javax.xml.transform.OutputKeys/METHOD) "xml")
(.setOutputProperty "{http://xml.apache.org/xslt}indent-amount" "2")))
-(defn indent [e ^java.io.Writer stream & {:as opts}]
+(defn indent
+ "Uses emit-stream to emit XML and indents the result. WARNING: this is slow
+ it will emit the XML and read it in again to indent it. Intended for
+ debugging/testing only."
+ [e ^java.io.Writer stream & {:as opts}]
(let [sw (java.io.StringWriter.)
_ (apply emit-stream e sw opts)
source (-> sw .toString java.io.StringReader. javax.xml.transform.stream.StreamSource.)

0 comments on commit 9ac25a0

Please sign in to comment.