aboutsummaryrefslogtreecommitdiffstats
path: root/docs/gen
diff options
context:
space:
mode:
Diffstat (limited to 'docs/gen')
-rw-r--r--docs/gen/layout.moon43
-rwxr-xr-xdocs/gen/md10
2 files changed, 48 insertions, 5 deletions
diff --git a/docs/gen/layout.moon b/docs/gen/layout.moon
index 4d43737..1b1cdaa 100644
--- a/docs/gen/layout.moon
+++ b/docs/gen/layout.moon
@@ -86,6 +86,46 @@ autoref = (str) ->
str = str\gsub '%[([^%]]-)%]%[:(.-):%]', r
str
+subnav = do
+ split_name = (file) ->
+ href, label = file\match '^docs/(.*/([%w%-]+)%.html)'
+ label = label\gsub '-', ' '
+ label, href
+
+ subnav_link = (dir, file) ->
+ import span, a, u from dom
+
+ if not file
+ return span ''
+
+ label, href = split_name file
+ label = switch dir
+ when 'l'
+ "◂ back: #{u label}"
+ when 'r'
+ "next: #{u label} ▸"
+
+ a label, href: abs href
+
+ (all) ->
+ assert OUT, "OUT needs to be set"
+ import div, nav, h1 from dom
+
+ local c
+ for i, src in ipairs all
+ if OUT == src
+ c = i
+ break
+
+ div {
+ class: 'subheader'
+ h1 (split_name OUT)
+ nav {
+ subnav_link 'l', all[c-1]
+ subnav_link 'r', all[c+1]
+ }
+ }
+
aopts = (href, pat) ->
{
href: abs href
@@ -110,7 +150,7 @@ layout = (opts) ->
}
div class: 'grow'
a 'home', aopts 'index.html', 'index.html$'
- a 'getting started', aopts 'guide.html', 'guide.html$'
+ a 'guide', aopts 'guide/getting-started-guide.html', 'guide'
a 'reference', aopts 'reference/index.html', 'reference'
a 'internals', aopts 'internals/index.html', 'ldoc'
}
@@ -148,4 +188,5 @@ layout = (opts) ->
:autoref
:render
:layout
+ :subnav
}
diff --git a/docs/gen/md b/docs/gen/md
index 32d4fdd..f22268c 100755
--- a/docs/gen/md
+++ b/docs/gen/md
@@ -1,5 +1,5 @@
#!/usr/bin/env moon
-import layout, autoref from require 'docs.gen.layout'
+import layout, subnav, autoref from require 'docs.gen.layout'
import compile from require 'discount'
export OUT, ESCAPE
@@ -18,6 +18,8 @@ ESCAPE = (str) ->
(str\gsub '([*`])', '\\%1')
{ OUT, file } = arg
-
-contents = slurp file
-spit OUT, layout compile (autoref contents), 'githubtags', 'fencedcode'
+content = compile (autoref slurp file), 'githubtags', 'fencedcode'
+if #arg > 2
+ sub = subnav [a for a in *arg[3,]]
+ content.body = table.concat { sub, content.body }, '\n\n'
+spit OUT, layout content