Git Product home page Git Product logo

liima's Introduction

liima

A tool for gluing snippets of your Clojure code into your docs. Inspired by literate programming.

Based on rewrite-clj.

Why?

Code is hardly ever optimized for pedagogy. Unlike org-babel, WEB, or noweb, most literate-programming-inspired tools I know of are lacking in one crucial aspect: the sheer difficulty of "out-of-order" presentation of ideas (from the perspective of the resultant code). So, I wanted to experiment and try out something that:

  • would provide the bare minimum for creating out-of-order documentation using fragments of actual code
  • wouldn't cause noticeable changes in workflow

Usage

A Contrived Example

Supposing you had the following code on your classpath:

(defn my-fn
  "An example fn for demonstrative purposes"
  []
  (println "hello world!")
  (+ 1 1))

and you wanted to include that snippet as-is in your documentation, so that the println form gets replaced with <<println>>. First, add some metadata:

^{:liima/ref :my.ns/my-fn}
(defn my-fn
  "An example fn for demonstrative purposes"
  []
  ^{:liima/ref :my.ns/print}
  (println "hello world!")
  (+ 1 1))

Next, add the following in a Markdown file:

Here's a neat function:

```
@{{content :my.ns/my-fn :my.ns/print "<<println>>"}}
```

where `<<println>>` is: `@{{content :my.ns/print}}`

Then, evaluate:

(liima.docs/process-notes! {:docs-root "/path/to/docs" :output-root "./target/docs"})

A version of the original Markdown file has been dumped under ./target/docs with the template replaced:

Here's a neat function:

```
(defn my-fn
  "An example fn for demonstrative purposes"
  []
  <<println>>
  (+ 1 1))
```

where `<<println>>` is: `(println "hello world!")`

For content replacements, currently only content and ns (for attempted inference of the code block's namespace) are supported. Links can be replaced by appending the typical Markdown notation with @, like so:

@[My Link](./linked-page.md)

which would become

[My Link](./linked-page/index.html)

Limitations

  • All :liima/ref values must be either unqualified, or fully qualified, keywords (i.e., can't use ::keyword sugar).
  • Only code that supports metadata can be tagged

liima's People

Contributors

joonaskeppo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.