From 92bacc26d7b9e0a176e899831c7a0b361d68f6d6 Mon Sep 17 00:00:00 2001 From: Tom Faulhaber Date: Fri, 23 Jul 2010 10:01:58 -0700 Subject: [PATCH] Autodoc commit for master/29a94caf, 1.1.x/d132c5f1 --- api-index.html | 37 +++- index.html | 37 +++- json-api.html | 90 +++++++- pprint-api.html | 562 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 710 insertions(+), 16 deletions(-) diff --git a/api-index.html b/api-index.html index 8af2559b..c20d2e4e 100644 --- a/api-index.html +++ b/api-index.html @@ -157,6 +157,7 @@

B

C

  *char-array-type*            var           io                 Type object for a Java primitive char array..
+ *code-dispatch*              multimethod   pprint             The pretty print dispatch function for pretty prin...
  *connection*                 var           jmx                The connection to be used for JMX ops. Defaults to...
  call-cc                      function      monads             A computation in the cont monad that calls functio...
  call-method                  function      reflect            Calls a private or protected method.  params is a ...
@@ -179,6 +180,7 @@ 

C

chop function str-utils Removes the last character of string.. chop function str-utils2 Removes the last character of string, does nothing... chop function string Removes the last character of string, does nothing... + cl-format function pprint An implementation of a Common Lisp compatible form... classpath function classpath Returns a sequence of File objects of the elements... classpath-directories function classpath Returns a sequence of File objects for the directo... classpath-jarfiles function classpath Returns a sequence of JarFile objects for the JAR ... @@ -190,6 +192,7 @@

C

combinations function combinatorics All the unique ways of taking n different elements... combine multimethod accumulators Combine the values of the accumulators acc1 and ac... comment? function find-namespaces Returns true if form is a (comment ...). + compile-format function pprint Compiles format-str into a compiled format which c... component-graph function graph Given a graph, perhaps with cycles, return a reduc... components function miglayout Returns a map from id (a keyword) to component for... compose-fixtures function test-is Composes two fixture functions, creating a new fix... @@ -349,8 +352,11 @@

F

flush function monadic-io-streams Flush. fmap multimethod generic.functor Applies function f to each item in the data struct... fnmap function fnmap Creates a fnmap, or functional map. A fnmap behav... + formatter macro pprint Makes a function which can directly run format-in.... + formatter-out macro pprint Makes a function which can directly run format-in.... frequencies function seq DEPRECATED. Prefer clojure.core version. Returns a... frequencies function seq-utils DEPRECATED. Prefer clojure.core version. Returns a... + fresh-line function pprint Make a newline if the Writer is not already at the... function? function test-is Returns true if argument is a function or a symbol...
@@ -435,6 +441,7 @@

J

join function string Returns a string of all elements in coll, separate... join-fixtures function test-is Composes a collection of fixtures, in order. Alwa... join-with function probabilities.finite-distributions Returns the distribution of (f x y... + json-str function json Converts x to a JSON-formatted string..

K

@@ -539,7 +546,16 @@

O

P

- *print-pretty*               var           pprint             Bind to true if you want write to use pretty print...
+ *print-base*                 var           pprint             The base to use for printing integers and rational...
+ *print-circle*               var           pprint             Mark circular structures (N.B. This is not yet use...
+ *print-lines*                var           pprint             Maximum number of lines to print in a pretty print...
+ *print-miser-width*          var           pprint             The column at which to enter miser style. Dependin...
+ *print-pprint-dispatch*      var           pprint             The pretty print dispatch function. Use with-pprin...
+ *print-pretty*               var           pprint             Bind to true if you want write to use pretty print...
+ *print-radix*                var           pprint             Print a radix specifier in front of integers and r...
+ *print-right-margin*         var           pprint             Pretty printing will try to avoid anything going b...
+ *print-shared*               var           pprint             Mark repeated structures rather than repeat them (...
+ *print-suppress-namespaces*  var           pprint             Don't print namespaces with symbols. This is parti...
  *prxml-indent*               var           prxml              The number of spaces to indent sub-tags.  nil for ...
  parse-seq                    function      lazy-xml           Parses the source s, which can be a File, InputStr...
  parse-trim                   function      lazy-xml           Parses the source s, which can be a File, InputStr...
@@ -560,11 +576,19 @@ 

P

post-ordered-nodes function graph Return a sequence of indexes of a post-ordered wal... pow multimethod generic.math-functions Return the pow of x and y.. powers-of-2 function lazy-seqs Returns a lazy sequence of all the powers of 2. + pp macro pprint A convenience macro that pretty prints the last th... + pprint function pprint Pretty print object to the optional output writer.... + pprint-indent function pprint Create an indent at this point in the pretty print... + pprint-json function json Pretty-prints JSON representation of x to *out*. + pprint-logical-block macro pprint Execute the body as a pretty printing logical bloc... + pprint-newline function pprint Print a conditional newline to a pretty printing s... + pprint-tab function pprint Tab at this point in the pretty printing stream. k... primes var lazy-seqs Lazy sequence of all the prime numbers.. print function monadic-io-streams Print obj. print-dataflow function dataflow Prints a dataflow, one cell per line. print-dir function ns-utils Prints a sorted directory of public vars in a name... print-docs function ns-utils Prints documentation for the public vars in a name... + print-json function json Write JSON-formatted output to *out*. print-repl-info function repl-ln Prints info about the current repl. print-stack-trace function condition Prints a stack trace for a condition or Throwable.... print-summary function profile Prints a table of the results returned by summariz... @@ -605,6 +629,8 @@

R

read var jmx Read an mbean property.. read-char function monadic-io-streams Read a single character. read-file-ns-decl function find-namespaces Attempts to read a (ns ...) declaration from file,... + read-json function json Reads one JSON value from input String or Reader. ... + read-json-from function json Reads one JSON value from input String or Reader. ... read-line function monadic-io-streams Read a single line. read-lines function duck-streams Like clojure.core/line-seq but opens f with reader... read-lines function io Like clojure.core/line-seq but opens f with reader... @@ -672,7 +698,8 @@

R

S

- *stack-trace-depth*          var           test-is            The maximum depth of stack traces to print when an...
+ *simple-dispatch*            multimethod   pprint             The pretty print dispatch function for simple data...
+ *stack-trace-depth*          var           test-is            The maximum depth of stack traces to print when an...
  safe-get                     function      map-utils          Like get, but throws an exception if the key is no...
  safe-get-in                  function      map-utils          Like get-in, but throws an exception if any key is...
  sample                       function      probabilities.monte-carlo Return the distribution of samples of lengt...
@@ -694,6 +721,7 @@ 

S

sequence-t function monads Monad transformer that transforms a monad m into a... server-error? function http.agent Returns true if the HTTP response code was in the ... set-m var monads Monad describing multi-valued computations, like s... + set-pprint-dispatch function pprint Set the pretty print dispatch function to a functi... set-repl-name function repl-ln Sets the repl name format to the string name-fmt. ... set-repl-prompt function repl-ln Sets the repl prompt. Include the following codes ... set-rollback-only function sql Marks the outermost transaction such that it will ... @@ -802,6 +830,7 @@

U

upper-case function str-utils2 Converts string to all upper-case.. upper-case function string Converts string to all upper-case.. use-fixtures multimethod test-is Wrap test runs in a fixture function to perform se... + use-method function pprint Installs a function as a new method of multimethod...

V

@@ -830,6 +859,7 @@

W

with-out-append-writer macro io Like with-out-writer but appends to file.. with-out-writer macro duck-streams Opens a writer on f, binds it to *out*, and evalut... with-out-writer macro io Opens a writer on f, binds it to *out*, and evalut... + with-pprint-dispatch macro pprint Execute body with the pretty print dispatch functi... with-profile-data macro profile Executes body with *profile-data* bound to an atom... with-query-results macro sql Executes a query, then evaluates body with results... with-reader function monadic-io-streams Create a reader from reader-spec, run the monadic ... @@ -842,8 +872,11 @@

W

with-test-out macro test-is Runs body with *out* bound to the value of *test-o... with-writer function monadic-io-streams Create a writer from writer-spec, run the monadic ... write function monadic-io-streams Write text (a string). + write function pprint Write an object subject to the current bindings of... + write-json function json Print object to PrintWriter out as JSON. write-lines function duck-streams Writes lines (a seq) to f, separated by newlines. ... write-lines function io Writes lines (a seq) to f, separated by newlines. ... + write-out function pprint Write an object to *out* subject to the current bi... write-properties function java-utils Write properties to file-able.. write-properties function properties Write properties to file-able.. writer multimethod duck-streams Attempts to coerce its argument into an open java.... diff --git a/index.html b/index.html index 98ffe7f7..c84d5fe0 100644 --- a/index.html +++ b/index.html @@ -1308,7 +1308,7 @@

json

Public variables and functions: -
+ json-str pprint-json print-json read-json read-json-from write-json

@@ -1671,21 +1671,44 @@

ns-utils



pprint

- + by Tom Faulhaber
Detailed API documentation
-

-  
+  
This module comprises two elements:
+1) A pretty printer for Clojure data structures, implemented in the 
+   function "pprint"
+2) A Common Lisp compatible format function, implemented as 
+   "cl-format" because Clojure is using the name "format" 
+   for its Java-based format function.
+
+See documentation for those functions for more information or complete 
+documentation on the the clojure-contrib web site on github.
+
+As of the 1.2 release, pprint has been moved to clojure.pprint. Please prefer
+the clojure.pprint version for new code.
+ Deprecated since clojure-contrib version 1.2
Public variables and functions: - *print-pretty*
+ *code-dispatch* *print-base* *print-circle* *print-lines* *print-miser-width* *print-pprint-dispatch* *print-pretty* *print-radix* *print-right-margin* *print-shared* *print-suppress-namespaces* *simple-dispatch* cl-format compile-format formatter formatter-out fresh-line pp pprint pprint-indent pprint-logical-block pprint-newline pprint-tab set-pprint-dispatch use-method with-pprint-dispatch write write-out

Variables and functions in pprint.examples.json: - + + dispatch-json + + json-str + + print-json +

Variables and functions in pprint.examples.xml: - + + *html-compatible* + + *prxml-indent* + + prxml +
diff --git a/json-api.html b/json-api.html index 13b64d11..676a7308 100644 --- a/json-api.html +++ b/json-api.html @@ -53,7 +53,19 @@

Clojure-cont

Table of Contents

@@ -75,7 +87,81 @@

Table of Contents


Public Variables and Functions

- +
+
+
+

json-str

+ function
+
Usage: (json-str x)
+
+
Converts x to a JSON-formatted string.
+ + + Source +
+
+
+

pprint-json

+ function
+
Usage: (pprint-json x)
+
+
Pretty-prints JSON representation of x to *out*
+ + + Source +
+
+
+

print-json

+ function
+
Usage: (print-json x)
+
+
Write JSON-formatted output to *out*
+ + + Source +
+
+
+

read-json

+ function
+
Usage: (read-json input)
+       (read-json input keywordize?)
+       (read-json input keywordize? eof-error? eof-value)
+
+
Reads one JSON value from input String or Reader.
+If keywordize? is true (default), object keys will be converted to
+keywords.  If eof-error? is true (default), empty input will throw
+an EOFException; if false EOF will return eof-value. 
+ + + Source +
+
+
+

read-json-from

+ function
+
Usage: (read-json-from input keywordize? eof-error? eof-value)
+
+
Reads one JSON value from input String or Reader.
+If keywordize? is true, object keys will be converted to keywords.
+If eof-error? is true, empty input will throw an EOFException; if
+false EOF will return eof-value. 
+ + + +
+
+
+

write-json

+ function
+
Usage: (write-json object out)
+
+
Print object to PrintWriter out as JSON
+ + + +
diff --git a/pprint-api.html b/pprint-api.html index fb741c2a..74340610 100644 --- a/pprint-api.html +++ b/pprint-api.html @@ -54,32 +54,109 @@

Table of Contents

Overview
+ *code-dispatch* +
+ *print-base* +
+ *print-circle* +
+ *print-lines* +
+ *print-miser-width* +
+ *print-pprint-dispatch* +
*print-pretty* +
+ *print-radix* +
+ *print-right-margin* +
+ *print-shared* +
+ *print-suppress-namespaces* +
+ *simple-dispatch* +
+ cl-format +
+ compile-format +
+ formatter +
+ formatter-out +
+ fresh-line +
+ pp +
+ pprint +
+ pprint-indent +
+ pprint-logical-block +
+ pprint-newline +
+ pprint-tab +
+ set-pprint-dispatch +
+ use-method +
+ with-pprint-dispatch +
+ write +
+ write-out

pprint.examples.json - +
+ dispatch-json +
+ json-str +
+ print-json +

pprint.examples.xml - +
+ *html-compatible* +
+ *prxml-indent* +
+ prxml +

API for pprint (master branch)

- +by Tom Faulhaber

Usage:
 (ns your-namespace
   (:require clojure.contrib.pprint))
 
 

Overview

-

+
This module comprises two elements:
+1) A pretty printer for Clojure data structures, implemented in the 
+   function "pprint"
+2) A Common Lisp compatible format function, implemented as 
+   "cl-format" because Clojure is using the name "format" 
+   for its Java-based format function.
+
+See documentation for those functions for more information or complete 
+documentation on the the clojure-contrib web site on github.
 
+As of the 1.2 release, pprint has been moved to clojure.pprint. Please prefer
+the clojure.pprint version for new code.
+Deprecated since clojure-contrib version 1.2

Related documentation: @@ -89,6 +166,70 @@

Table of Contents



Public Variables and Functions

+
+
+

*code-dispatch*

+ multimethod
+
Usage: (*code-dispatch* object)
+
+
The pretty print dispatch function for pretty printing Clojure code.
+ + + Source +
+
+
+

*print-base*

+ var
+

+  
The base to use for printing integers and rationals.
+ + + Source +
+
+
+

*print-circle*

+ var
+

+  
Mark circular structures (N.B. This is not yet used)
+ + + Source +
+
+
+

*print-lines*

+ var
+

+  
Maximum number of lines to print in a pretty print instance (N.B. This is not yet used)
+ + + Source +
+
+
+

*print-miser-width*

+ var
+

+  
The column at which to enter miser style. Depending on the dispatch table, 
+miser style add newlines in more places to try to keep lines short allowing for further 
+levels of nesting.
+ + + Source +
+
+
+

*print-pprint-dispatch*

+ var
+

+  
The pretty print dispatch function. Use with-pprint-dispatch or set-pprint-dispatch
+to modify.
+ + + Source +


*print-pretty*

@@ -98,6 +239,334 @@

*print-pretty*

Source +
+
+
+

*print-radix*

+ var
+

+  
Print a radix specifier in front of integers and rationals. If *print-base* is 2, 8, 
+or 16, then the radix specifier used is #b, #o, or #x, respectively. Otherwise the 
+radix specifier is in the form #XXr where XX is the decimal value of *print-base* 
+ + + Source +
+
+
+

*print-right-margin*

+ var
+

+  
Pretty printing will try to avoid anything going beyond this column.
+Set it to nil to have pprint let the line be arbitrarily long. This will ignore all 
+non-mandatory newlines.
+ + + Source +
+
+
+

*print-shared*

+ var
+

+  
Mark repeated structures rather than repeat them (N.B. This is not yet used)
+ + + Source +
+
+
+

*print-suppress-namespaces*

+ var
+

+  
Don't print namespaces with symbols. This is particularly useful when 
+pretty printing the results of macro expansions
+ + + Source +
+
+
+

*simple-dispatch*

+ multimethod
+
Usage: (*simple-dispatch* object)
+
+
The pretty print dispatch function for simple data structure format.
+ + + Source +
+
+
+

cl-format

+ function
+
Usage: (cl-format writer format-in & args)
+
+
An implementation of a Common Lisp compatible format function. cl-format formats its
+arguments to an output stream or string based on the format control string given. It 
+supports sophisticated formatting of structured data.
+
+Writer is an instance of java.io.Writer, true to output to *out* or nil to output 
+to a string, format-in is the format control string and the remaining arguments 
+are the data to be formatted.
+
+The format control string is a string to be output with embedded 'format directives' 
+describing how to format the various arguments passed in.
+
+If writer is nil, cl-format returns the formatted result string. Otherwise, cl-format 
+returns nil.
+
+For example:
+ (let [results [46 38 22]]
+        (cl-format true "There ~[are~;is~:;are~]~:* ~d result~:p: ~{~d~^, ~}~%" 
+                   (count results) results))
+
+Prints to *out*:
+ There are 3 results: 46, 38, 22
+
+Detailed documentation on format control strings is available in the "Common Lisp the 
+Language, 2nd edition", Chapter 22 (available online at:
+http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node200.html#SECTION002633000000000000000) 
+and in the Common Lisp HyperSpec at 
+http://www.lispworks.com/documentation/HyperSpec/Body/22_c.htm
+ + + Source +
+
+
+

compile-format

+ function
+
Usage: (compile-format format-str)
+
+
Compiles format-str into a compiled format which can be used as an argument
+to cl-format just like a plain format string. Use this function for improved 
+performance when you're using the same format string repeatedly
+ + + Source +
+
+
+

formatter

+ macro
+
Usage: (formatter format-in)
+
+
Makes a function which can directly run format-in. The function is
+fn [stream & args] ... and returns nil unless the stream is nil (meaning 
+output to a string) in which case it returns the resulting string.
+
+format-in can be either a control string or a previously compiled format.
+ + + Source +
+
+
+

formatter-out

+ macro
+
Usage: (formatter-out format-in)
+
+
Makes a function which can directly run format-in. The function is
+fn [& args] ... and returns nil. This version of the formatter macro is
+designed to be used with *out* set to an appropriate Writer. In particular,
+this is meant to be used as part of a pretty printer dispatch method.
+
+format-in can be either a control string or a previously compiled format.
+ + + Source +
+
+
+

fresh-line

+ function
+
Usage: (fresh-line)
+
+
Make a newline if the Writer is not already at the beginning of the line.
+N.B. Only works on ColumnWriters right now.
+ + + Source +
+
+
+

pp

+ macro
+
Usage: (pp)
+
+
A convenience macro that pretty prints the last thing output. This is
+exactly equivalent to (pprint *1).
+ + + Source +
+
+
+

pprint

+ function
+
Usage: (pprint object)
+       (pprint object writer)
+
+
Pretty print object to the optional output writer. If the writer is not provided, 
+print the object to the currently bound value of *out*.
+ + + Source +
+
+
+

pprint-indent

+ function
+
Usage: (pprint-indent relative-to n)
+
+
Create an indent at this point in the pretty printing stream. This defines how 
+following lines are indented. relative-to can be either :block or :current depending 
+whether the indent should be computed relative to the start of the logical block or
+the current column position. n is an offset. 
+
+Output is sent to *out* which must be a pretty printing writer.
+ + + Source +
+
+
+

pprint-logical-block

+ macro
+
Usage: (pprint-logical-block options* body)
+
+
Execute the body as a pretty printing logical block with output to *out* which 
+must be a pretty printing writer. When used from pprint or cl-format, this can be 
+assumed. 
+
+Before the body, the caller can optionally specify options: :prefix, :per-line-prefix, 
+and :suffix.
+ + + Source +
+
+
+

pprint-newline

+ function
+
Usage: (pprint-newline kind)
+
+
Print a conditional newline to a pretty printing stream. kind specifies if the 
+newline is :linear, :miser, :fill, or :mandatory. 
+
+Output is sent to *out* which must be a pretty printing writer.
+ + + Source +
+
+
+

pprint-tab

+ function
+
Usage: (pprint-tab kind colnum colinc)
+
+
Tab at this point in the pretty printing stream. kind specifies whether the tab
+is :line, :section, :line-relative, or :section-relative. 
+
+Colnum and colinc specify the target column and the increment to move the target
+forward if the output is already past the original target.
+
+Output is sent to *out* which must be a pretty printing writer.
+
+THIS FUNCTION IS NOT YET IMPLEMENTED.
+ + + Source +
+
+
+

set-pprint-dispatch

+ function
+
Usage: (set-pprint-dispatch function)
+
+
Set the pretty print dispatch function to a function matching (fn [obj] ...)
+where obj is the object to pretty print. That function will be called with *out* set
+to a pretty printing writer to which it should do its printing.
+
+For example functions, see *simple-dispatch* and *code-dispatch* in 
+clojure.contrib.pprint.dispatch.clj.
+ + + Source +
+
+
+

use-method

+ function
+
Usage: (use-method multifn dispatch-val func)
+
+
Installs a function as a new method of multimethod associated with dispatch-value. 
+ + + Source +
+
+
+

with-pprint-dispatch

+ macro
+
Usage: (with-pprint-dispatch function & body)
+
+
Execute body with the pretty print dispatch function bound to function.
+ + + Source +
+
+
+

write

+ function
+
Usage: (write object & kw-args)
+
+
Write an object subject to the current bindings of the printer control variables.
+Use the kw-args argument to override individual variables for this call (and any 
+recursive calls). Returns the string result if :stream is nil or nil otherwise.
+
+The following keyword arguments can be passed with values:
+  Keyword              Meaning                              Default value
+  :stream              Writer for output or nil             true (indicates *out*)
+  :base                Base to use for writing rationals    Current value of *print-base*
+  :circle*             If true, mark circular structures    Current value of *print-circle*
+  :length              Maximum elements to show in sublists Current value of *print-length*
+  :level               Maximum depth                        Current value of *print-level*
+  :lines*              Maximum lines of output              Current value of *print-lines*
+  :miser-width         Width to enter miser mode            Current value of *print-miser-width*
+  :dispatch            The pretty print dispatch function   Current value of *print-pprint-dispatch*
+  :pretty              If true, do pretty printing          Current value of *print-pretty*
+  :radix               If true, prepend a radix specifier   Current value of *print-radix*
+  :readably*           If true, print readably              Current value of *print-readably*
+  :right-margin        The column for the right margin      Current value of *print-right-margin*
+  :suppress-namespaces If true, no namespaces in symbols    Current value of *print-suppress-namespaces*
+
+  * = not yet supported
+ + + Source +
+
+
+

write-out

+ function
+
Usage: (write-out object)
+
+
Write an object to *out* subject to the current bindings of the printer control 
+variables. Use the kw-args argument to override individual variables for this call (and 
+any recursive calls).
+
+*out* must be a PrettyWriter if pretty printing is enabled. This is the responsibility
+of the caller.
+
+This method is primarily intended for use by pretty print dispatch functions that 
+already know that the pretty printer will have set up their environment appropriately.
+Normal library clients should use the standard "write" interface. 
+ + + Source

pprint.examples.json

Pretty printing JavaScript Object Notation (JSON) generator.
@@ -110,13 +579,96 @@ 

pprint.examples.json

JSON Home Page

- +
+
+

dispatch-json

+ multimethod
+
Usage: (dispatch-json x)
+
+
The dispatch function for printing objects as JSON
+ + + Source +
+
+

json-str

+ function
+
Usage: (json-str x)
+
+
Converts x to a JSON-formatted string.
+ + + Source +
+
+

print-json

+ function
+
Usage: (print-json x)
+
+
Prints x as JSON.  Nil becomes JSON null.  Keywords become
+strings, without the leading colon.  Maps become JSON objects, all
+other collection types become JSON arrays.  Java arrays become JSON
+arrays.  Unicode characters in strings are escaped as \uXXXX.
+Numbers print as with pr.
+ + + Source +

pprint.examples.xml

A version of prxml that uses a pretty print dispatch function.

+
+
+

*html-compatible*

+ var
+

+  
If true, empty tags will have a space before the closing />
+ + + Source +
+
+

*prxml-indent*

+ var
+

+  
The number of spaces to indent sub-tags.
+ + + Source +
+
+

prxml

+ function
+
Usage: (prxml & args)
+
+
Print XML to *out*.  Vectors become XML tags: the first item is the
+tag name; optional second item is a map of attributes.
+
+Sequences are processed recursively, so you can use map and other
+sequence functions inside prxml.
+
+  (prxml [:p {:class "greet"} [:i "Ladies & gentlemen"]])
+  ; => <p class="greet"><i>Ladies &amp; gentlemen</i></p>
+
+PSEUDO-TAGS: some keywords have special meaning:
 
+  :raw!      do not XML-escape contents
+  :comment!  create an XML comment
+  :decl!     create an XML declaration, with attributes
+  :cdata!    create a CDATA section
+  :doctype!  create a DOCTYPE!
+
+  (prxml [:p [:raw! "<i>here & gone</i>"]])
+  ; => <p><i>here & gone</i></p>
+
+  (prxml [:decl! {:version "1.1"}])
+  ; => <?xml version="1.1" encoding="UTF-8"?>
+ + + Source +