aboutsummaryrefslogtreecommitdiffstats
path: root/docs/gen
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-06-03 10:50:20 +0000
committers-ol <s-ol@users.noreply.github.com>2020-06-03 11:04:00 +0000
commit4b8a0f024606ca8c602a4e886767d414995ca0a2 (patch)
tree0477d875efed4bc495827ccf265c1bb44397ce4e /docs/gen
parentadd loop/recur (diff)
downloadalive-4b8a0f024606ca8c602a4e886767d414995ca0a2.tar.gz
alive-4b8a0f024606ca8c602a4e886767d414995ca0a2.zip
split guide into guide and reference
Diffstat (limited to 'docs/gen')
-rwxr-xr-xdocs/gen/index43
-rw-r--r--docs/gen/layout.moon42
-rwxr-xr-xdocs/gen/module16
3 files changed, 55 insertions, 46 deletions
diff --git a/docs/gen/index b/docs/gen/index
index dff601a..20fb3bd 100755
--- a/docs/gen/index
+++ b/docs/gen/index
@@ -1,8 +1,8 @@
#!/usr/bin/env moon
require 'alv'
-import render, layout, autoref from require 'docs.gen.layout'
+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 opairs from require 'alv.util'
+import compile from require 'discount'
export OUT
@@ -16,34 +16,15 @@ spit = (file, str) ->
file\write str
file\close!
-{ OUT } = arg
+{ 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
- title: 'reference'
- body: {
- h1 (code 'alive'), " language reference"
- p "This section documents all builtins and modules that are currently
- available in the alive programming language."
- p autoref "If you are new to alive, the [getting started guide][:../guide/:] is
- the recommended place to start. If you are looking for
- information on adding your own module or contributing to alive, check
- out the [developer documentation][:../internals/index/:]."
- section {
- id: 'modules'
- h2 a "module index", href: '#modules'
- p autoref "These modules can be imported using [require][], " ..
- "[import][] and [import*][]."
- ul for file in *arg[2,]
- path = file\match '^alv%-lib/(.*)%.moon$'
- name = path\gsub '/', '.'
- li a (code name), href: "#{path}.html"
- }
- section {
- id: 'builtins'
- h2 a "builtins", href: '#builtins'
- p "These definitions are automatically loaded into the global Scope of
- every alive session."
- ul for key, val in opairs (require 'alv.builtins').values
- li render key, val.result
- }
- }
+ body: table.concat { sub, content.body }, '\n\n'
diff --git a/docs/gen/layout.moon b/docs/gen/layout.moon
index 1b1cdaa..7d3c4e1 100644
--- a/docs/gen/layout.moon
+++ b/docs/gen/layout.moon
@@ -67,7 +67,10 @@ link = (ref) ->
return version.release if ref == '*release*'
mod, sym = ref\match '^(.+)/(.*)$'
- abs "reference/#{mod or 'index'}.html##{sym or ref}"
+ if mod
+ abs "reference/module/#{mod}.html##{sym or ref}"
+ else
+ abs "reference/builtins.html##{sym or ref}"
-- link to a reference
r = (text, ref) ->
@@ -88,10 +91,33 @@ autoref = (str) ->
subnav = do
split_name = (file) ->
- href, label = file\match '^docs/(.*/([%w%-]+)%.html)'
+ if href = file\match '^docs/(.*/index.html)$'
+ return 'index', href
+
+ href, label = file\match '^docs/(.*/([%d%w-_]+)%.html)$'
+ label = (label\match '^[%d-]+_([%w-]+)$') or label
label = label\gsub '-', ' '
label, href
+ title = (file) ->
+ if file == 'docs/guide/index.html'
+ return "getting started guide"
+ if file == 'docs/reference/index.html'
+ return "<code>alv</code> language reference"
+ elseif mod = file\match '^docs/reference/module/(.*)%.html$'
+ return "<code>#{mod}</code> module reference"
+ elseif href = file\match '^docs/(.*/index.html)$'
+ error "index page without hardcoded name: #{href}"
+
+ num, label = file\match '/([%d-]+)_([%w%-]+)%.html$'
+ if num
+ num = num\gsub '%f[%d]0', ''
+ num = num\gsub '-', '.'
+ label = label\gsub '-', ' '
+ "#{num}. #{label}"
+ else
+ (file\match '/([%w%-]+)%.html$')
+
subnav_link = (dir, file) ->
import span, a, u from dom
@@ -119,7 +145,7 @@ subnav = do
div {
class: 'subheader'
- h1 (split_name OUT)
+ h1 (title OUT)
nav {
subnav_link 'l', all[c-1]
subnav_link 'r', all[c+1]
@@ -129,7 +155,7 @@ subnav = do
aopts = (href, pat) ->
{
href: abs href
- class: if OUT\match "^docs/#{pat}" then 'active'
+ class: if OUT\match pat then 'active'
}
-- layout and write a doc page
@@ -149,10 +175,10 @@ layout = (opts) ->
' documentation'
}
div class: 'grow'
- a 'home', aopts 'index.html', 'index.html$'
- a 'guide', aopts 'guide/getting-started-guide.html', 'guide'
- a 'reference', aopts 'reference/index.html', 'reference'
- a 'internals', aopts 'internals/index.html', 'ldoc'
+ a 'home', aopts 'index.html', '^docs/index.html$'
+ a 'guide', aopts 'guide/index.html', '^docs/guide'
+ a 'reference', aopts 'reference/index.html', '^docs/reference'
+ a 'internals', aopts 'internals/index.html', '^docs/ldoc'
}
body = article opts.body
title = if opts.title
diff --git a/docs/gen/module b/docs/gen/module
index d726845..77336cf 100755
--- a/docs/gen/module
+++ b/docs/gen/module
@@ -1,7 +1,7 @@
#!/usr/bin/env moon
-import Scope from require 'alv'
-import render, layout from require 'docs.gen.layout'
-import section, h2, h3, ul, li, code from require 'docs.gen.dom'
+import Constant from require 'alv'
+import render, layout, subnav from require 'docs.gen.layout'
+import h2, h3, ul, li, code from require 'docs.gen.dom'
import opairs from require 'alv.util'
export OUT, require
@@ -26,11 +26,13 @@ spit = (file, str) ->
{ OUT, module, name } = arg
name or= module
-module = Scope.from_table require module
+const = Constant.wrap require module
+module = const\unwrap!
spit OUT, layout
- title: "#{name} reference"
- body: section {
+ title: "#{name} module reference"
+ body: table.concat {
+ subnav [a for a in *arg[4,]]
h2 (code name), ' module reference'
h3 'index'
ul for key, node in opairs module.values
@@ -38,4 +40,4 @@ spit OUT, layout
h3 'details'
ul for key, node in opairs module.values
li render key, node.result
- }
+ }, ''