Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the papyrus Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:36:03 2020 GMT+0.
• Introduction | What papyrus is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
(in-package #:cl-user)
(defpackage #:papyrus.README
(:use :cl :papyrus :named-readtables))
(in-package #:papyrus.README)
(in-readtable :papyrus)
A literate programming tool
Papyrus is the name of a programming style as well as the name of a tool with which to implement it. The author of papyrus developed it to do literate programming in LISP better than WEB, developed by Donald Knuth. WEB and it's derived softwares are used in various programming languages. They require developers compiling with them to obtain the source code. It is required in order to do literate programming in C and Pascal, but isn't in Common Lisp because Common Lisp has the reader macro which changes the source code when the system reads it.
Papyrus makes your markdown executable with the reader macro of Common Lisp.
For example, the author wrote this document with Papyrus. You can execute it
by running ros run -l papyrus.asd -e '(require :papyrus)' -l README.md -q
.
How about this? Let's make your project more beautiful and useful!
(princ "Hello, Papyrus!")
Copyright (c) 2019 Fernado Garcia Borges All Rights Reserved
MIT. See the license texts.
This is a new project. Please send me your feedback if you find any issues.
In Papyrus, you can write any text but you have to write a title (#
) at
the top of the document, like the following, and make the file extension
.md
. Also, you can write with Markdown,
especially CommonMark whose specification can be found at
commonmark.org. Papyrus only evaluates codeblocks
after the title (#
) that are enclosed by ```lisp
and ```
. The
indented codeblock before the title (#
) is important, as this codeblock
specifies the required packages. Please do not forget it.
(in-package :cl-user)
(defpackage :tutorial
(:use :cl :papyrus :named-readtables)
(:export :hello)
(in-package :tutorial)
(in-readtable :papyrus)
# My First Document
This is my first document.
This will say "Hello, world!".
```lisp
(defun hello ()
(princ "Hello, world!"))
```
If you try this tutorial, save it as tutorial.md
, as this is the filename
used in this section. Now, there are two ways to generate the document,
REPL and ASDF. The following are quick tutorials for each. For more
information, please see the Reference section.
A REPL is a good environment to experiment with your Papyrus documents. We can load them and test the behaivor quickly and it is convenient to use them with SLIME.
Papyrus is available in QuickLisp. To install Just type,
> (ql:quickload :papyrus)
Or, you can install Papyrus with Roswell.
$ ros install asciian/papyrus
Next you can load document as follows:
> (require :papyrus)
nil
> (load #p"tutorial.md")
nil
> (tutorial:hello)
Hello, World!
Let's write a small project whose files are the following.
tutorial.asd
tutorial.md
tutorial.md
is the file written in the REPL section, and
tutorial.asd
is this:
(in-package :cl-user)
(defpackage tutorial-asd
(:use :cl :asdf))
(in-package :tutorial-asd)
(defclass papyrus (cl-source-file)
((type :initform "md")))
(defsystem tutorial
:version "0.1"
:author "Your name"
:license "MIT"
:depends-on (:papyrus :named-readtables)
:components ((:papyrus "tutorial"))
:description "A Literate Programming Framework")
Now that you have both files, tutorial.md
and tutorial.asd
,
you will be able to load this system like this.
> (load #p"tutorial.asd")
nil
> (require :tutorial)
nil
> (tutorial:hello)
Hello, World!
Of course, users of your project won't need to load anything else.
papyrus
This is a readtable defined by named-readtables
. You can use this with
named-readtable:in-readtable
like this document.
(in-package #:cl-user)
(defpackage #:sample
(:use :cl :named-readtables :papyrus)
(:export #:sample-function))
(in-package :sample)
(in-readtable :papyrus)
# Sample
This is a sample code. The following function just says "Hello, world!"
```lisp
(defun sample-function () (princ "Hello, world!"))
```
Try to use polymode
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))
If you use emacs, there is mmm-mode
which highlights the syntax of lisp
codeblocks in Markdown, but SLIME doesn't works well in mmm-mode
.
(require 'mmm-mode)
(setq mmm-global-mode 'maybe)
(set-face-background 'mmm-default-submode-face nil)
(mmm-add-mode-ext-class nil "\\.md?\\'" 'lisp-markdown)
(mmm-add-classes
'((lisp-markdown
:submode lisp-mode
:front "```lisp"
:back "```")))
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The papyrus system |
asciian
MIT
A Literate Programming Tool
0.1
named-readtables
papyrus.asd (file)
papyrus.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The papyrus.asd file | ||
• The papyrus/papyrus.lisp file |
Next: The papyrus/papyrus․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
papyrus.asd
papyrus (system)
Previous: The papyrus․asd file, Up: Lisp files [Contents][Index]
papyrus (system)
papyrus.lisp
papyrus-reader (function)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The papyrus-asd package | ||
• The papyrus package |
Next: The papyrus package, Previous: Packages, Up: Packages [Contents][Index]
papyrus.asd
Previous: The papyrus-asd package, Up: Packages [Contents][Index]
papyrus.lisp (file)
papyrus-reader (function)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Internal definitions |
Previous: Definitions, Up: Definitions [Contents][Index]
• Internal functions |
Previous: Internal definitions, Up: Internal definitions [Contents][Index]
papyrus.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L P |
---|
Jump to: | F L P |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | F P |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
F | |||
Function, papyrus-reader : | Internal functions | ||
| |||
P | |||
papyrus-reader : | Internal functions | ||
|
Jump to: | F P |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | P S |
---|
Jump to: | P S |
---|