The utilities.print-tree Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The utilities.print-tree Reference Manual

This is the utilities.print-tree Reference Manual, version 0.1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 06:07:14 2022 GMT+0.

Table of Contents


1 Introduction

#+TITLE:       utilities.print-tree README
#+AUTHOR:      Jan Moringen
#+EMAIL:       jmoringe@techfak.uni-bielefeld.de
#+DESCRIPTION: A simple system for pretty-printing tree structures
#+KEYWORDS:    common lisp, tree, printing, pretty-printing
#+LANGUAGE:    en

* Introduction
  The =utilities.print-tree= system provides simple facilities for
  printing tree structures in an easy to read way using either ASCII
  or Unicode characters to render the parent-child relations. One
  focus is playing nicely with pretty printing.

  #+ATTR_HTML: :alt "build status image" :title Build Status :align right
  [[https://travis-ci.org/scymtym/utilities.print-tree][https://travis-ci.org/scymtym/utilities.print-tree.svg]]

  The following example shows the result of printing the
  =utilities.print-tree= ASDF system without and with additional
  details added to nodes:
  #+begin_example
  utilities.print-tree
  ├─src
  │ ├─package
  │ └─print-tree
  └─README.org
  #+end_example
  Note how pretty-printing of the "Depends-on" entry works seamlessly
  with tree printing:
  #+begin_example
  utilities.print-tree
  │ Pathname   /home/jmoringe/code/cl/utilities.print-tree/
  │ Encoding   UTF-8
  │ Depends-on ((# #
  │              #)
  │             (PREPARE-OP #)
  │             (COMPILE-OP #))
  ├─src
  │ │ Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/
  │ │ Encoding   UTF-8
  │ │ Depends-on ((#
  │ │              #
  │ │              #)
  │ │             (PREPARE-OP #)
  │ │             (COMPILE-OP #))
  │ ├─package
  │ │   Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/package.lisp
  │ │   Encoding   UTF-8
  │ │   Depends-on ((PREPARE-OP
  │ │                #)
  │ │               (COMPILE-OP
  │ │                #))
  │ └─print-tree
  │     Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/print-tree.lisp
  │     Encoding   UTF-8
  │     Depends-on ((PREPARE-OP
  │                  #)
  │                 (COMPILE-OP
  │                  #))
  └─README.org
      Pathname   /home/jmoringe/code/cl/utilities.print-tree/README.org
      Encoding   UTF-8
      Depends-on ((PREPARE-OP #)
                  (COMPILE-OP #))
  #+end_example

  The following code produces this output:
  #+begin_src lisp
    (defmethod print-component ((target stream) (depth t) (component asdf:component))
      (princ (asdf:component-name component) target))

    (defmethod print-details ((target stream) (depth t) (component asdf:component))
      (format target "Pathname   ~A~@:_~
                      Encoding   ~A~@:_~
                      Depends-on ~A"
              (asdf:component-pathname   component)
              (asdf:component-encoding   component)
              (asdf:component-depends-on 'asdf:load-op component)))

    (defmethod asdf:component-children ((component t))
      '())

    (labels ((do-it (details?)
               (fresh-line)
               (terpri)
               (print-tree *standard-output* (asdf:find-system :utilities.print-tree)
                           (make-node-printer #'print-component
                                              (when details? #'print-details)
                                              #'asdf:component-children))))
      (do-it nil)
      (do-it t))
  #+end_src
  The full code of this example is available in [[file:examples/asdf.lisp]].
* settings                                                         :noexport:
#+STARTUP: content

# Local Variables:
# mode: org
# indent-tabs-mode: nil
# End:


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 utilities.print-tree

This system provides simple facilities for printing tree structures.

Maintainer

Jan Moringen <jmoringe@techfak.uni-bielefeld.de>

Author

Jan Moringen <jmoringe@techfak.uni-bielefeld.de>

License

LLGPLv3

Version

0.1.0

Dependency

alexandria (system).

Source

utilities.print-tree.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 utilities.print-tree/src

Source

utilities.print-tree.asd.

Parent Component

utilities.print-tree (system).

Child Components

3.2 utilities.print-tree/examples

Source

utilities.print-tree.asd.

Parent Component

utilities.print-tree (system).

Child Components

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Next: , Previous: , Up: Files   [Contents][Index]

4.1 Lisp


4.1.1 utilities.print-tree/utilities.print-tree.asd

Source

utilities.print-tree.asd.

Parent Component

utilities.print-tree (system).

ASDF Systems

utilities.print-tree.


4.1.2 utilities.print-tree/src/package.lisp

Source

utilities.print-tree.asd.

Parent Component

src (module).

Packages

utilities.print-tree.


4.1.3 utilities.print-tree/src/print-tree.lisp

Dependency

package.lisp (file).

Source

utilities.print-tree.asd.

Parent Component

src (module).

Public Interface
Internals

Previous: , Up: Files   [Contents][Index]

4.2 Static


4.2.1 utilities.print-tree/README.org

Source

utilities.print-tree.asd.

Parent Component

utilities.print-tree (system).


4.2.2 utilities.print-tree/examples/minimal.lisp

Source

utilities.print-tree.asd.

Parent Component

examples (module).


4.2.3 utilities.print-tree/examples/asdf.lisp

Source

utilities.print-tree.asd.

Parent Component

examples (module).


5 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

5.1 utilities.print-tree

This package provides functions for printing tree structures.

The main entry point is the ‘print-tree’ function. It accepts a stream, a tree object and a printer function.

In common cases, tree printer functions can be creating using ‘make-node-printer’ or ‘make-folding-node-printer’.

Source

package.lisp.

Use List
  • alexandria.
  • common-lisp.
Public Interface
Internals

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Public Interface


6.1.1 Special variables

Special Variable: *use-unicode?*
Package

utilities.print-tree.

Source

print-tree.lisp.


6.1.2 Ordinary functions

Function: make-folding-node-printer (first-line-printer rest-printer children predicate)

Like ‘make-node-printer’, return a node printer function that used FIRST-LINE-PRINTER, REST-PRINTER and CHILDREN.

PREDICATE is called to determine whether and to what extend nodes should be printed. When called with the depth of a node and node as its arguments, PREDICATE must return a list of "bits" of the node that should be printed. The following bits are recognized:

:first

Print first line of the node by calling FIRST-LINE-PRINTER?

:content

Print more details for the node by calling REST-PRINTER?

:children

Print children of the node?

:children-ellipsis

Print ellipsis of the form "…", if the node has children butlast the :children bit has not been specified?

When PREDICATE returns T, all bits are printed.

Package

utilities.print-tree.

Source

print-tree.lisp.

Function: make-node-printer (first-line-printer rest-printer children)

Return a node printer function that used FIRST-LINE-PRINTER, REST-PRINTER and CHILDREN.

FIRST-LINE-PRINTER is called with the destination stream, the depth of the node and the node and should print a one-line representation of the node to the stream. The function should return true if REST-PRINTER should be called to print more details for the node.

REST-PRINTER is also called with the destination stream, the depth of the node and node. It is not restricted to only producing a single line, however.

CHILDREN is called with a node and must return a (possibly empty) list of children of the node.

Package

utilities.print-tree.

Source

print-tree.lisp.

Function: print-node-contents (stream printer &optional final? depth)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: print-subtree (stream nodes printer &optional final? depth)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: print-tree (stream root printer)

Print the tree ROOT to STREAM using PRINTER.

PRINTER is called with four arguments, STREAM, ROOT, the keyword :root and the integer 0, indicating depth zero. PRINTER will usually call ‘print-node’, ‘print-subree’ and ‘print-node-contents’ to do the actual work.

Functions suitable for use as PRINTER can, for many common cases, be constructed via ‘make-node-printer’ and ‘make-folding-node-printer’.

Package

utilities.print-tree.

Source

print-tree.lisp.


6.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

6.2.1 Constants

Constant: +tree-child/final+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-child/final/ascii+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-child/inner+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-child/inner/ascii+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-prefix/final+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-prefix/final/ascii+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-prefix/inner+
Package

utilities.print-tree.

Source

print-tree.lisp.

Constant: +tree-prefix/inner/ascii+
Package

utilities.print-tree.

Source

print-tree.lisp.


Previous: , Up: Internals   [Contents][Index]

6.2.2 Ordinary functions

Function: print-nodes (stream nodes printer depth)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-child (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-child/ascii (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-child/unicode (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-prefix (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-prefix/ascii (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.

Function: tree-prefix/unicode (kind)
Package

utilities.print-tree.

Source

print-tree.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   E   F   M   P   R   S   U  
Index Entry  Section

A
asdf.lisp: The utilities․print-tree/examples/asdf․lisp file

E
examples: The utilities․print-tree/examples module

F
File, asdf.lisp: The utilities․print-tree/examples/asdf․lisp file
File, minimal.lisp: The utilities․print-tree/examples/minimal․lisp file
File, package.lisp: The utilities․print-tree/src/package․lisp file
File, print-tree.lisp: The utilities․print-tree/src/print-tree․lisp file
File, readme.org: The utilities․print-tree/readme․org file
File, utilities.print-tree.asd: The utilities․print-tree/utilities․print-tree․asd file

M
minimal.lisp: The utilities․print-tree/examples/minimal․lisp file
Module, examples: The utilities․print-tree/examples module
Module, src: The utilities․print-tree/src module

P
Package, utilities.print-tree: The utilities․print-tree package
package.lisp: The utilities․print-tree/src/package․lisp file
print-tree.lisp: The utilities․print-tree/src/print-tree․lisp file

R
readme.org: The utilities․print-tree/readme․org file

S
src: The utilities․print-tree/src module
System, utilities.print-tree: The utilities․print-tree system

U
utilities.print-tree: The utilities․print-tree system
utilities.print-tree: The utilities․print-tree package
utilities.print-tree.asd: The utilities․print-tree/utilities․print-tree․asd file

Jump to:   A   E   F   M   P   R   S   U