aboutsummaryrefslogtreecommitdiffstats
path: root/docs/gen/index
blob: 20fb3bdd21a789291b8b7f46e1ce6363d7c17f07 (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
25
26
27
28
29
30
#!/usr/bin/env moon
require 'alv'
import render, layout, autoref, subnav from require 'docs.gen.layout'
import section, h1, h2, p, ul, li, a, code from require 'docs.gen.dom'
import compile from require 'discount'

export OUT

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!

{ OUT, file } = arg

md = slurp file
for file in *arg[3,]
  if mod = file\match '/module/(.*)%.html'
    name = mod\gsub '/', '.'
    md ..= "   - [`#{name}`](module/#{mod}.html)\n"

content = compile (autoref md), 'githubtags', 'fencedcode'
sub = subnav [a for a in *arg[3,]]
spit OUT, layout
  body: table.concat { sub, content.body }, '\n\n'