aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-04-17 14:08:45 +0000
committers-ol <s-ol@users.noreply.github.com>2020-04-17 14:08:45 +0000
commitaedd7f485397b322fc88c60241fa1e5e684fd2b4 (patch)
tree2727053dbe2b8585430e20d779a2b25c9bae0d2b
parentremove defunct alv-copilot.bat (diff)
downloadalive-aedd7f485397b322fc88c60241fa1e5e684fd2b4.tar.gz
alive-aedd7f485397b322fc88c60241fa1e5e684fd2b4.zip
move extra/ to docs/gen/ and split up
-rw-r--r--Makefile23
-rw-r--r--docs/gen/dom.moon (renamed from extra/dom.moon)0
-rwxr-xr-xdocs/gen/git-version (renamed from extra/git-version.sh)0
-rwxr-xr-xdocs/gen/index48
-rw-r--r--docs/gen/layout.moon (renamed from extra/layout.moon)13
-rwxr-xr-x[-rw-r--r--]docs/gen/ldoc (renamed from extra/docs.moon)102
-rwxr-xr-xdocs/gen/md23
-rwxr-xr-xdocs/gen/module40
8 files changed, 145 insertions, 104 deletions
diff --git a/Makefile b/Makefile
index 3f3dfff..b6ac592 100644
--- a/Makefile
+++ b/Makefile
@@ -1,35 +1,40 @@
MODULES=$(wildcard alv-lib/*.moon) alv-lib/midi/launchctl.moon
MODREFS=$(MODULES:alv-lib/%.moon=docs/reference/%.html)
CORE=$(wildcard alv/*.moon alv/**/*.moon) $(wildcard alv/*.md)
-DEPS=alv/version.moon extra/docs.moon extra/layout.moon extra/dom.moon
+DEPS=alv/version.moon $(wildcard docs/gen/*.moon)
-.PHONY: docs reference internals release clean
+.PHONY: docs test release clean reference internals
docs: docs/index.html docs/guide.html reference internals
-reference: $(MODREFS) docs/reference/index.html
-internals: docs/internals/index.html
+
+test:
+ busted
release:
rm -f alv/version.moon
- extra/git-version.sh >alv/version.moon
+ docs/gen/git-version >alv/version.moon
+
+# docs parts
+reference: $(MODREFS) docs/reference/index.html
+internals: docs/internals/index.html
docs/%.html: docs/%.md $(DEPS)
@echo "building page $<"
- moon extra/docs.moon $@ markdown $<
+ docs/gen/md $@ $<
docs/reference/%.html: alv-lib/%.moon $(DEPS)
@echo "building docs for $<"
@mkdir -p `dirname $@`
- moon extra/docs.moon $@ module alv-lib.$(subst /,.,$*) $(subst /,.,$*)
+ docs/gen/module $@ alv-lib.$(subst /,.,$*) $(subst /,.,$*)
docs/reference/index.html: $(MODREFS) $(DEPS)
- moon extra/docs.moon $@ reference $(MODULES)
+ docs/gen/index $@ $(MODULES)
docs/ldoc.css: docs/style.css
cp $< $@
docs/ldoc.ltp: $(DEPS)
- moon extra/docs.moon $@ ldoc
+ docs/gen/ldoc $@
docs/internals/index.html: alv/config.ld docs/ldoc.ltp docs/ldoc.css $(CORE)
ldoc alv
diff --git a/extra/dom.moon b/docs/gen/dom.moon
index 7541fbd..7541fbd 100644
--- a/extra/dom.moon
+++ b/docs/gen/dom.moon
diff --git a/extra/git-version.sh b/docs/gen/git-version
index 495b679..495b679 100755
--- a/extra/git-version.sh
+++ b/docs/gen/git-version
diff --git a/docs/gen/index b/docs/gen/index
new file mode 100755
index 0000000..5b06b9d
--- /dev/null
+++ b/docs/gen/index
@@ -0,0 +1,48 @@
+#!/usr/bin/env moon
+import ValueStream from require 'alv'
+import render, layout, autoref from require 'docs.gen.layout'
+import section, h1, h2, p, ul, li, a, code from require 'docs.gen.dom'
+
+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 } = arg
+
+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.builtin'
+ li render key, ValueStream.wrap val
+ }
+ }
diff --git a/extra/layout.moon b/docs/gen/layout.moon
index a0d8df1..084807e 100644
--- a/extra/layout.moon
+++ b/docs/gen/layout.moon
@@ -1,8 +1,9 @@
version = require 'alv.version'
+dom = require 'docs.gen.dom'
import compile from require 'discount'
render_meta = (meta) ->
- import p, code from require 'extra.dom'
+ import p, code from dom
contents = {}
if meta.examples
-- table.insert contents, h4 'signature'
@@ -16,7 +17,7 @@ render_meta = (meta) ->
-- render an ALV Value to a HTML string
render = (name, value, prefix=nil, index=false) ->
- import div, label, code, ul, li, i, a, pre from require 'extra.dom'
+ import div, label, code, ul, li, i, a, pre from dom
id = if prefix then "#{prefix}/#{name}" else name
type = i value.type
@@ -66,17 +67,15 @@ link = (ref) ->
mod, sym = ref\match '^(.+)/(.*)$'
abs "reference/#{mod or 'index'}.html##{sym or ref}"
-escape = (str) ->
- (str\gsub '([*`])', '\\%1')
-
-- link to a reference
r = (text, ref) ->
- import a, code from require 'extra.dom'
+ import a, code from dom
href = link ref or text
if ref
a text, :href
else
text = text\gsub '/$', ''
+ escape = ESCAPE or (i) -> i
a (code escape text), :href
-- substitute markdown-style reference links
@@ -98,7 +97,7 @@ aopts = (href, pat) ->
-- - style
-- - body (str or table)
layout = (opts) ->
- import header, footer, nav, div, span, b, code, a, article from require 'extra.dom'
+ import header, footer, nav, div, span, b, code, a, article from dom
head = header nav {
span {
diff --git a/extra/docs.moon b/docs/gen/ldoc
index 6ed5ea0..b75740d 100644..100755
--- a/extra/docs.moon
+++ b/docs/gen/ldoc
@@ -1,93 +1,21 @@
-import ValueStream, Scope from require 'alv'
-import render, layout, autoref from require 'extra.layout'
-import section, h1, h2, h3, p, ul, li, a, code, r from require 'extra.dom'
+#!/usr/bin/env moon
+import layout from require 'docs.gen.layout'
-export OUT, BASE, require
-{ OUT, command } = arg
-
-slurp = (file) ->
- file = io.open file, 'r'
- with file\read '*all'
- file\close!
+export OUT, BASE
spit = (file, str) ->
file = io.open file, 'w'
file\write str
file\close!
-spit OUT, switch command
- when 'module'
- { _, _, module, name } = arg
-
- require = do
- old_require = require
- blacklist = {k, true for k in *{'osc', 'socket', 'system', 'luartmidi'}}
- (mod, ...) ->
- return {} if blacklist[mod]
- old_require mod, ...
-
- name or= module
- module = Scope.from_table require module
-
- layout
- title: "#{name} reference"
- body: section {
- h2 (code name), ' module reference'
- h3 'index'
- ul for key, res in opairs module.values
- li render key, res.value, nil, true
- h3 'details'
- ul for key, res in opairs module.values
- li render key, res.value
- }
-
- when 'reference'
- 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[3,]
- 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.builtin'
- li render key, ValueStream.wrap val
- }
- }
-
- when 'markdown'
- import compile from require 'discount'
-
- { _, _, file } = arg
- contents = slurp file
- require 'discount'
-
- layout compile (autoref contents), 'githubtags', 'fencedcode'
+{ OUT } = arg
+BASE = '$(base)'
- when 'ldoc'
- BASE = '$(base)'
- layout
- style: '$(ldoc.css)'
- title: '$(ldoc.title)'
- class: 'ldoc'
- preamble: '
+spit OUT, layout
+ style: '$(ldoc.css)'
+ title: '$(ldoc.title)'
+ class: 'ldoc'
+ preamble: '
# local iter = ldoc.modules.iter
# local M = ldoc.markup
# local function display_name(item)
@@ -99,9 +27,9 @@ spit OUT, switch command
# if #ls > 1 then return "<li>","</li>" else return "","" end
# end
# local base = module and "../../" or "../"'
- body: {
- class: 'ldoc'
- '
+ body: {
+ class: 'ldoc'
+ '
# if ldoc.body then
$(ldoc.body)
# elseif not module then
@@ -265,6 +193,4 @@ spit OUT, switch command
# end
# end
'
- }
- else
- error "unknown command '#{command}'"
+ }
diff --git a/docs/gen/md b/docs/gen/md
new file mode 100755
index 0000000..32d4fdd
--- /dev/null
+++ b/docs/gen/md
@@ -0,0 +1,23 @@
+#!/usr/bin/env moon
+import layout, autoref from require 'docs.gen.layout'
+import compile from require 'discount'
+
+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
+
+contents = slurp file
+spit OUT, layout compile (autoref contents), 'githubtags', 'fencedcode'
diff --git a/docs/gen/module b/docs/gen/module
new file mode 100755
index 0000000..143e3fe
--- /dev/null
+++ b/docs/gen/module
@@ -0,0 +1,40 @@
+#!/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'
+
+export OUT, require
+
+require = do
+ old_require = require
+ blacklist = {k, true for k in *{'osc', 'socket', 'system', 'luartmidi'}}
+ (mod, ...) ->
+ return {} if blacklist[mod]
+ old_require mod, ...
+
+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, module, name } = arg
+
+name or= module
+module = Scope.from_table require module
+
+spit OUT, layout
+ title: "#{name} reference"
+ body: section {
+ h2 (code name), ' module reference'
+ h3 'index'
+ ul for key, res in opairs module.values
+ li render key, res.value, nil, true
+ h3 'details'
+ ul for key, res in opairs module.values
+ li render key, res.value
+ }