Packaging

Snowballs are created with the package command. Simply give it the path to one or more R7RS library files and it will package them along with any include files. For example, if we wanted to package the old Earley parser from the CMU AI Repository, we would first trivially update it to R7RS, creating a file named, e.g. "earley.sld":

(define-library (feeley earley)
  (export make-parser parse->parsed?
          parse->trees parse->nb-trees tree-display)
  (import (scheme r5rs))
  (include "tree.scm")
  (include "earley.scm"))

This could then be packaged with:

snow-chibi package earley.sld

This will use your local username as the author, but provide no other information. We can add this with options:

snow-chibi package --version=1.0 --authors="Marc Feeley" \
  --maintainers="Me <me@myself.com>" earley.sld

We don't know the license or we'd include that with the --license option. Of course, packages are not much use without documentation, so we would want to add some:

snow-chibi package --version=1.0 --authors="Marc Feeley" \
  --maintainers="Me <me@myself.com>" --doc=earley.ps \
  --description="Earley Parser for Context-Free Grammars" \
  earley.sld

Any format (ps, pdf, html) is fine, as we simply include this file in the snowball and provide a link to it, however for ease of browsing from the public repo html is preferred. If you want to embed the docs in the code in a literate-programming fashion, you can also use the --doc-from-scribble option, which treats any line beginning with ";;>" as docs in scribble syntax, using backslash instead of @ as the escape character. In this case we can infer the description from the first sentence of documentation.

Finally, a well maintained library should provide tests. You can include these with the --test=<prog.scm> option, which should be an R7RS program that either exits with a non-zero status or outputs text including "ERROR" or "FAIL" on failure. If you want to keep your tests in a library you can alternately use --test-library=<mylib.scm>, which should be a library exporting a thunk run-tests, which when run has the same behavior as a test program. You can also specify (append-to-last -test) as the test-library, which would look for a library based on the packaged library with the given suffix, in this case (feeley earley-test). This is especially handy when packaging multiple libraries together.

Putting all of this together we have:

snow-chibi package --version=1.0 --authors="Marc Feeley" \
  --maintainers="Me <me@myself.com>" --doc=earley.ps \
  --description="Earley Parser for Context-Free Grammars" \
  --test=earley-test.scm earley.sld

The snow-chibi command uses (chibi app) to manage options and configuration, which means you can also specify defaults for any of these options in your "~/.snow/config.scm" file. If we put this all together, converting the docs to scribble, adding a VERSION file, and creating the (feeley earley-test) library, with the following config.scm:

((command
  (package
   (authors "Me <me@myself.com>")
   (doc-from-scribble #t)
   (version-file "VERSION")
   (test-library (append-to-last -test)))))

then the command becomes simply:

snow-chibi package --authors="Marc Feeley" earley.sld

Publishing

Once we have a package the next step is to share it. First generate a key with:

snow-chibi gen-key

which will ask you for your email address and a password, then register it with:

snow-chibi reg-key

You should receive an email with a link to complete the registration, after which you're ready to upload. In this case we can upload our package with:

snow-chibi upload feeley-earley-1.0.tgz
and we're done!