utilities.print-tree

2022-11-07

This system provides simple facilities for printing tree structures.

Upstream URL

github.com/scymtym/utilities.print-tree

Author

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

Maintainer

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

License

LLGPLv3
README
utilities.print-tree README

1Introduction

The utilities.print-tree system provides simple facilities forprinting tree structures in an easy to read way using either ASCIIor Unicode characters to render the parent-child relations. Onefocus is playing nicely with pretty printing.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:

  utilities.print-tree
  ├─src
  │ ├─package
  │ └─print-tree
  └─README.org
Note how pretty-printing of the "Depends-on" entry works seamlesslywith tree printing:
  utilities.print-tree
  │ Pathname   /home/jmoringe/code/cl/utilities.print-tree/
  │ Encoding   UTF-8
  │ Depends-on ((#<LOAD-OP > #<MODULE "utilities.print-tree" "src">
  │              #<STATIC-FILE "utilities.print-tree" "README.org">)
  │             (PREPARE-OP #<SYSTEM "utilities.print-tree">)
  │             (COMPILE-OP #<SYSTEM "utilities.print-tree">))
  ├─src
  │ │ Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/
  │ │ Encoding   UTF-8
  │ │ Depends-on ((#<LOAD-OP >
  │ │              #<CL-SOURCE-FILE "utilities.print-tree" "src" "package">
  │ │              #<CL-SOURCE-FILE "utilities.print-tree" "src" "print-tree">)
  │ │             (PREPARE-OP #<MODULE "utilities.print-tree" "src">)
  │ │             (COMPILE-OP #<MODULE "utilities.print-tree" "src">))
  │ ├─package
  │ │   Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/package.lisp
  │ │   Encoding   UTF-8
  │ │   Depends-on ((PREPARE-OP
  │ │                #<CL-SOURCE-FILE "utilities.print-tree" "src" "package">)
  │ │               (COMPILE-OP
  │ │                #<CL-SOURCE-FILE "utilities.print-tree" "src" "package">))
  │ └─print-tree
  │     Pathname   /home/jmoringe/code/cl/utilities.print-tree/src/print-tree.lisp
  │     Encoding   UTF-8
  │     Depends-on ((PREPARE-OP
  │                  #<CL-SOURCE-FILE "utilities.print-tree" "src" "print-tree">)
  │                 (COMPILE-OP
  │                  #<CL-SOURCE-FILE "utilities.print-tree" "src" "print-tree">))
  └─README.org
      Pathname   /home/jmoringe/code/cl/utilities.print-tree/README.org
      Encoding   UTF-8
      Depends-on ((PREPARE-OP #<STATIC-FILE "utilities.print-tree" "README.org">)
                  (COMPILE-OP #<STATIC-FILE "utilities.print-tree" "README.org">))

The following code produces this output:

    (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))
The full code of this example is available in file:examples/asdf.lisp.

2settings :noexport:

Dependencies (3)

  • alexandria
  • fiveam
  • uiop
  • GitHub
  • Quicklisp