aboutsummaryrefslogtreecommitdiffstats
path: root/docs/gen/md
blob: d07ab5ff2d5ccf38dafac4d845748abccf812e6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env moon
import compile, layout, subnav, autoref from require 'docs.gen.layout'

export OUT, ESCAPE

slurp = (file) ->
  file = io.open file, 'r'
  with file\read '*all'
    file\close!

spit = (file, str) ->
  file = io.open file, 'w'
  file\write str
  file\close!

ESCAPE = (str) ->
  (str\gsub '([*`])', '\\%1')

{ OUT, file } = arg
content = compile autoref slurp file
if #arg > 2
  sub = subnav [a for a in *arg[3,]]
  content = table.concat { sub, content }, '\n\n'
spit OUT, layout body: content