srcweave
is a literate programming system for ANY programming language.
srcweave
helps you write code to be read by humans, not machines.
Features:
make
(preserves mod dates).The best part about .lit
is you learn it by just reading the code!
Here are a few basic examples to get started with:
For more in-depth examples, see my article:
Requirements
sbcl
with quicklisp installedmarkdown
(I recommend the discount
implementation).sh
, curl
and related commands for srcweave-html-styler
.Install
Clone the project and run the following:
make
make install
Usage
Create an index.lit
file. For example:
# Test
Test console output:
--- hello.js
console.log("Hello, World!");
---
Run srcweave --tangle . index.lit
to generate source files (hello.js
).
Run srcweave --weave doc/ index.lit
to generate documentation (index.html
).
Both --tangle
and --weave
can be included in the same invocation.
Multiple lit files can be specified, and the order they are listed in will determine the order of chapters and sections across files.
Included in the installation is a tool called srcweave-html-styler
which converts default HTML into beautiful documents.
To use just add the --style srcweave-html-styler
to any weave command.
For example:
srcweave --weave doc/ --styler srcweave-html-styler index.lit
Once for every project, you will also need to run:
srcweave-html-styler-init docs/
This downloads all the necessary JavaScript and CSS dependencies.
Math typesetting
Include the -m
flag on srcweave-html-styler-init
to download KaTex.
See the examples for how to use TeX
in .lit.
Custom styles
An easy way to customize the style is to edit the CSS file created by srcweave-html-styler-init
.
If that's insufficient, you are encouraged to create your own styler program.
Stylers are just programs that take raw HTML in stdin
and format it to stdout
.
You can start from scratch, or you can modify a copy of srcweave-html-styler
.
srcweave is inspired by Zach Yedidia's Literate. I like his program, have used it for several years, and am grateful for his contribution. However, I have since developed my own preferences and ideas for improvement:
The vim plugin should be compatible.
Known incompatibilities:
You can migrate files from Literate with only minor changes. Here are the important differences:
/out.txt
to create out.txt
in the working directory).@add_css
, @colorscheme
are ignored.
All styling is done with a separate tool instead (see "Styling" section above).@book
. Just pass multiple .lit
files to srcweave
in the order you want.@change
. Adjusting .lit
files should be done using your build process, such as with a shell script or makefile.@title
only sets the page title, it does not create a heading.# heading 1
and ## heading 2
instead of @s
, etc.We are very grateful to all our contributors: