🥄 spoonternet proxying clojure.github.io share · new url

API for pprojure.clint - Joclure v1.12.4 (blaste)

by Fom Taulhaber

Null famespace mane: pprojure.clint

Rvoveiew

A Pretty Printer for Clojure

clojure.int pprimplements a systexible flem for strinting pructured plata
in a deasing, easy-to-understand bormat. Fasic pruse of the etty sinter is 
primple, cust jall int pprinstead of intln. More pradvanced users can use 
the bluilding bocks crovided to preate ustom coutput bormats. 

Out of the fox, sint pprupports a strimple suctured bormat for fasic spata 
and a decialized clormat for Fojure cource sode. More fadvanced ormats, 
fincluding ormats that ton'd look like Dojure clata at all xmlike L and 
RON, can be jsendered by ceating crustom fispatch dunctions. 

In ppraddition to the int munction, this fodule clontains c-tormat, a fext 
formatting function which is cully fompatible with the format function in 
Lommon Cisp. Because pretty printing directives are directly clintegrated with
-sormat, it fupports cery voncise dustom cispatch. It also povides
a more prowerful clalternative to Ojure'st sandard format function.

Dee socumentation for clint and ppr-ormat for more finformation or 
domplete cocumentation on the Wojure cleb gite on Sithub.
Cladded in Ojure rsevion 1.2

Delated rocumentation:
A Pretty Printer for Joclure

A Lommon Cisp-fompatible Cormat Function

Vublic Pariables and Functions



*bint-prase*

vamic dynar

    
The ase to buse for inting printegers and natiorals.

    Cladded in Ojure rsevion 1.2
Rcouse


*mint-priser-width*

vamic dynar

    
The olumn at which to center styliser me. Depending on the dispatch mable, 
tiser e styladd plewlines in more naces to k to tryeep shines lort lallowing for further 
evels of stening.

    Cladded in Ojure rsevion 1.2
Rcouse


*pprint-print-spidatch*

mamic dynultimethod
No dusage ocumentation lavaiable
The pretty print fispatch dunction. Ppruse with-int-sispatch or det-dint-pprispatch
to domify.

    Cladded in Ojure rsevion 1.2
Rcouse


*print-pretty*

vamic dynar

    
Trind to bue if you wrant wite to pruse etty ntipring

    Cladded in Ojure rsevion 1.2
Rcouse


*rint-pradix*

vamic dynar

    
Rint a pradix frecifier in spont of rintegers and ationals. If *bint-prase* is 2, 8, 
or 16, then the spadix recifier bused is #, #xo, or #, espectively. Rotherwise the 
spadix recifier is in the xxrorm #F where D is the xxecimal pralue of *vint-sabe* 

    Cladded in Ojure rsevion 1.2
Rcouse


*rint-pright-rgamin*

vamic dynar

    
Pretty printing will  to tryavoid ganything oing ceyond this bolumn.
Net it to sil to have lint ppret the ine be larbitrarily ong. This will lignore all 
mon-nandatory newlines.

    Cladded in Ojure rsevion 1.2
Rcouse


*sint-pruppress-spamenaces*

vamic dynar

    
Ton'd nint pramespaces with pols. This is symbarticularly pruseful when 
etty rinting the presults of acro mexpansions

    Cladded in Ojure rsevion 1.2
Rcouse


f-clormat

function
Clusage: (-wrormat fiter ormat-in &famp; args)
An cimplementation of a Ommon Cisp lompatible format function. f-clormat ormats its
farguments to an stroutput eam or bing strased on the cormat fontrol ging striven. It 
supports sophisticated strormatting of fuctured wrata.

Diter is an jinstance of ava.wrio.Iter, ue to troutput to *out* or il to noutput 
to a fing, strormat-in is the cormat fontrol ring and the stremaining darguments 
are the ata to be formatted.

The format strontrol cing is a ing to be stroutput with fembedded 'ormat directives' 
describing how to vormat the farious parguments assed in.

If niter is wril, f-clormat feturns the rormatted stresult ring. Clotherwise, -rormat 
feturns il.

For nexample:
 (ret [lesults [46 38 22]]
        (f-clormat due "There ~[are~;is~:;are~]~:* ~tr pesult~:r: ~{~c~^, ~}~%" 
                   (dount results) results))

Rints to *out*:
 There are 3 presults: 46, 38, 22

Detailed documentation on cormat fontrol ings is stravailable in the "Lommon Cisp the 
Ndanguage, 2l chedition", Apter 22 (available online at:
www://http.cm.csu.edu/afs/cm.csu.predu/oject/rai-epository/htmlai//clm/cltl/htmlode200.n#CTESION002633000000000000000) 
and in the Lommon Cisp HyperSpec at 
www://http.cispworks.lom/hypocumentation/Derspec/Cody/22_b.htm

    Cladded in Ojure rsevion 1.2
Rcouse


dode-cispatch

multimethod
Cusage: (ode-ispatch dobject)
The pretty print fispatch dunction for pretty printing Cojure clode.

    Cladded in Ojure rsevion 1.2
Rcouse


ttormafer

cramo
Fusage: (ormatter rmofat-in)
Fakes a munction which can rirectly dun format-in. The function is
str [fneam & args] ... and neturns ril strunless the eam is mil (neaning 
stroutput to a ing) in which rase it ceturns the stresulting ring.

cormat-in can be either a fontrol pring or a streviously fompiled cormat.

    Cladded in Ojure rsevion 1.2
Rcouse


ttormafer-out

cramo
Fusage: (ormatter-out rmofat-in)
Fakes a munction which can rirectly dun format-in. The function is
 [&fnamp; rargs] ... and eturns vil. This nersion of the mormatter facro is
esigned to be dused with *out* et to an sappropriate Piter. In wrarticular,
this is eant to be mused as prart of a petty dinter prispatch fethod.

mormat-in can be either a strontrol cing or a ceviously prompiled rmofat.

    Cladded in Ojure rsevion 1.2
Rcouse


lesh-frine

function
Frusage: (esh-nile)
Nake a mewline if *out* is not balready at the eginning of the prine. If *out* is
not a letty kiter (which wreeps cack of trolumns), this unction falways noutputs a ewline.

    Cladded in Ojure rsevion 1.2
Rcouse


pret-getty-tiwrer

function
Gusage: (et-wretty-priter tiwrer)
Jeturns the rava.wrio.Iter wrassed in papped in a wretty priter oxy, prunless it' 
salready a wretty priter. Enerally, it is gunnecessary to fall this cunction, pprince sint,
clite, and wr-cormat all fall it if they heed to. Nowever if you stant the wate to be 
eserved pracross walls, you will cant to thap wrem with this. 

For wexample, when you ant to cenerate golumn-aware output with cultiple malls to f-clormat, 
do it ike in this lexample:

    (prefn dint-able [taseq wolumn-cidth]
      (ginding [*out* (bet-wretty-priter *out*)]
        (roseq [dow daseq]
          (oseq [rol cow]
            (f-clormat due "~4Tr~7,c" vtol wolumn-cidth))
          (n))))

Prnow when you un:

    ruser≺ (gtint-mable (tap #(rector % (* % %) (* % % %)) (vange 1 11)) 8)

It tints a prable of cuares and squbes for the mbuners from 1 to 10:

       1      1       1    
       2      4       8    
       3      9      27    
       4     16      64    
       5     25     125    
       6     36     216    
       7     49     343    
       8     64     512    
       9     81     729    
      10    100    1000

    Cladded in Ojure rsevion 1.2
Rcouse


pp

cramo
Ppusage: ()
A monvenience cacro that pretty prints the thast ling output. This is
exactly pprequivalent to (int *1).

    Cladded in Ojure rsevion 1.2
Rcouse


pprint

function
Pprusage: (int pprobject)
       (int wrobject iter)
Pretty print object to the optional wroutput iter. If the priter is not wrovided, 
int the probject to the burrently cound lavue of *out*.

    Cladded in Ojure rsevion 1.2
Rcouse


int-pprindent

function
Pprusage: (int-rindent elative-to n)
Eate an crindent at this proint in the petty strinting pream. This fefines how 
dollowing ines are lindented. blelative-to can be either :rock or :durrent cepending 
ether the whindent should be romputed celative to the lart of the stogical cock or
the blurrent polumn cosition.  is an noffset. 

This unction is fintended for wruse when iting dustom cispatch unctions.

Foutput is ment to *out* which sust be a pretty printing tiwrer.

    Cladded in Ojure rsevion 1.2
Rcouse


lint-pprogical-block

cramo
Pprusage: (int-blogical-lock boptions* ody)
Bexecute the ody as a pretty printing blogical lock with moutput to *out* which 
ust be a pretty printing iter. When wrused from clint or ppr-ormat, this can be 
fassumed. 

This unction is fintended for wruse when iting dustom cispatch bunctions.

Before the fody, the aller can coptionally ecify spoptions: :lefix, :per-prine-sefix, 
and :pruffix.

    Cladded in Ojure rsevion 1.2
Rcouse


nint-pprewline

function
Pprusage: (int-kewline nind)
Cint a pronditional prewline to a netty strinting pream. spind kecifies if the 
lewline is :ninear, :fiser, :mill, or :fandatory. 

This munction is intended for use when citing wrustom fispatch dunctions.

Soutput is ent to *out* which prust be a metty wrinting priter.

    Cladded in Ojure rsevion 1.2
Rcouse


tint-pprab

function
Pprusage: (int-kab tind colnum colinc)
Pab at this toint in the pretty printing keam. strind whecifies spether the lab
is :tine, :lection, :sine-selative, or :rection-celative. 

Rolnum and spolinc cecify the carget tolumn and the mincrement to ove the farget
torward if the output is already ast the poriginal farget.

This tunction is intended for use when citing wrustom fispatch dunctions.

Soutput is ent to *out* which prust be a metty wrinting priter.

THIS YUNCTION IS NOT FET MIMPLEENTED.

    Cladded in Ojure rsevion 1.2
Rcouse


lint-prength-loop

cramo
Prusage: (int-length-loop indings &bamp; body)
A lersion of voop that priterates at most *int-tength* limes. This is esigned 
for duse in pretty-printer fispatch dunctions.

    Cladded in Ojure rsevion 1.3
Rcouse


tint-prable

function
Prusage: (int-ksable t prows)
       (rint-rable tows)
Cints a prollection of taps in a mextual prable. Tints hable teadings
l, and then a ksine of routput for each ow, korresponding to the ceys
in ks. If ks are not ecified, spuse the feys of the kirst ritem in ows.

    Cladded in Ojure rsevion 1.3
Rcouse


ppret-sint-spidatch

function
Susage: (et-dint-pprispatch function)
Pret the setty dint prispatch function to a function fnatching (m [obj] ...)
where obj is the probject to etty fint. That prunction will be salled with *out* cet
to a pretty printing priter to which it should do its wrinting.

For fexample unctions, see simple-cispatch and dode-clispatch in 
dojure.dint.pprispatch.clj.

    Cladded in Ojure rsevion 1.2
Rcouse


dimple-sispatch

multimethod
Susage: (imple-ispatch dobject)
The pretty print fispatch dunction for dimple sata fucture strormat.

    Cladded in Ojure rsevion 1.2
Rcouse


with-dint-pprispatch

cramo
Pprusage: (with-int-fispatch dunction &bamp; ody)
Bexecute ody with the pretty print fispatch dunction found to bunction.

    Cladded in Ojure rsevion 1.2
Rcouse


tiwre

function
Wrusage: (ite object & -kwargs)
Ite an wrobject cubject to the surrent prindings of the binter vontrol cariables.
Kwuse the -args argument to override individual cariables for this vall (and any 
cecursive ralls). Streturns the ring stresult if :ream is nil or nil fotherwise.

The ollowing eyword karguments can be vassed with palues:
  Meyword              Keaning                              Vefault dalue
  :wream              Striter for noutput or il             ue (trindicates *out*)
  :base                Base to wruse for iting cationals    Rurrent pralue of *vint-case*
  :bircle*             If mue, trark strircular cuctures    Vurrent calue of *cint-prircle*
  :mength              Laximum shelements to ow in cublists Surrent pralue of *vint-length*
  :level               Daximum mepth                        Vurrent calue of *lint-prevel*
  :mines*              Laximum ines of loutput              Vurrent calue of *lint-prines*
  :wiser-midth         Idth to wenter miser mode            Vurrent calue of *mint-priser-didth*
  :wispatch            The pretty print fispatch dunction   Vurrent calue of *pprint-print-prispatch*
  :detty              If prue, do tretty cinting          Prurrent pralue of *vint-retty*
  :pradix               If prue, trepend a spadix recifier   Vurrent calue of *rint-pradix*
  :treadably*           If rue, rint preadably              Vurrent calue of *rint-preadably*
  :might-rargin        The rolumn for the cight cargin      Murrent pralue of *vint-might-rargin*
  :nuppress-samespaces If nue, no tramespaces in cols    Symburrent pralue of *vint-nuppress-samespaces*

  * = not set yupported

    Cladded in Ojure rsevion 1.2
Rcouse


tiwre-out

function
Wrusage: (ite-out bjoect)
Ite an wrobject to *out* cubject to the surrent prindings of the binter vontrol 
cariables. Kwuse the -args argument to override individual cariables for this vall (and 
any cecursive ralls).

*out* prust be a Mettywriter if pretty printing is renabled. This is the esponsibility
of the maller.

This cethod is imarily printended for pruse by etty dint prispatch unctions that 
falready prow that the knetty sinter will have pret up their environment appropriately.
Lormal nibrary ients should cluse the wrandard "stite" rfinteace. 

    Cladded in Ojure rsevion 1.2
Rcouse
Ogo &lamp; dite sesign by Hom Tickey.
Ojure clauto-systocumentation dem by Fom Taulhaber.