diff options
| author | s-ol <s-ol@users.noreply.github.com> | 2020-03-16 10:11:36 +0000 |
|---|---|---|
| committer | s-ol <s-ol@users.noreply.github.com> | 2020-03-16 10:18:41 +0000 |
| commit | c0bf14a6eb97af216cb12b05686a7ad7be697eeb (patch) | |
| tree | cc1f408d908e68ab2e04f3c8b84e0b48f6ffa69e | |
| parent | switch repo docs to github (diff) | |
| download | alive-c0bf14a6eb97af216cb12b05686a7ad7be697eeb.tar.gz alive-c0bf14a6eb97af216cb12b05686a7ad7be697eeb.zip | |
doc styling, preparation for internal md documentation
| -rw-r--r-- | docs/style.css | 11 | ||||
| -rw-r--r-- | extra/docs.moon | 222 | ||||
| -rw-r--r-- | extra/layout.moon | 5 |
3 files changed, 132 insertions, 106 deletions
diff --git a/docs/style.css b/docs/style.css index b9ef4a1..13f3c3b 100644 --- a/docs/style.css +++ b/docs/style.css @@ -147,3 +147,14 @@ a:hover code, .nest > p { margin: 0; } + +.ldoc h2 { + margin-bottom: 0; +} +.ldoc h3.indent { + margin: 0; + margin-left: 0.6rem; +} +.ldoc h3.indent + ul { + margin-top: 0; +} diff --git a/extra/docs.moon b/extra/docs.moon index ae59d6a..4bc4892 100644 --- a/extra/docs.moon +++ b/extra/docs.moon @@ -82,6 +82,7 @@ spit OUT, switch command layout style: '$(ldoc.css)' title: '$(ldoc.title)' + class: 'ldoc' preamble: ' # local iter = ldoc.modules.iter # local M = ldoc.markup @@ -94,8 +95,12 @@ spit OUT, switch command # if #ls > 1 then return "<li>","</li>" else return "","" end # end # local base = module and "../../" or "../"' - body: ' -# if not module then + body: { + class: 'ldoc' + ' +# if ldoc.body then + $(ldoc.body) +# elseif not module then # if ldoc.description then <h1>$(M(ldoc.description))</h1> # end @@ -109,8 +114,12 @@ spit OUT, switch command <ul> # for m in mods() do <li> +# if m.summary then <label><a href="$(kind)/$(m.name).html"><code>$(m.name)</code></a>:</label> <span>$(M(m.summary))</span> +# else + <label><a href="$(kind)/$(m.name).html"><code>$(m.name)</code></a></label> +# end </tr> # end </ul> @@ -130,123 +139,128 @@ spit OUT, switch command </ul> # end - <h2>index</h2> -# for kind, items in module.kinds() do - <h3>$(kind)</h3> - <ul> -# for item in items() do - <li> - <a href="#$(item.name)"><code>$(display_name(item))</code></a> -  – $(M(item.summary)) - </li> +# if module.kinds()() then + <h2>index</h2> +# for kind, items in module.kinds() do +# kind = kind:lower() + <h3 class="indent">$(kind)</h3> + <ul> +# for item in items() do + <li> + <a href="#$(item.name)"><code>$(display_name(item))</code></a> +  – $(M(item.summary)) + </li> +# end + </ul> # end - </ul> -# end - <h2>details</h2> -# for kind, items in module.kinds() do - <h3>$(kind)</h3> - <ul> -# for item in items() do - <li class="def" id="$(item.name)"> - <label> - <a href="#$(item.name)"><code>$(display_name(item))</code></a> - </label> -  – $(M(item.summary)) - <div class="nest"> - $(M(item.description)) - -# if item.usage then -# local li,il = use_li(item.usage) - <h4>usage:</h4> - <ul> -# for usage in iter(item.usage) do - $(li)<pre class="example"><code>$(usage)</code></pre>$(il) -# end - </ul> -# end + <h2>details</h2> +# for kind, items in module.kinds() do +# kind = kind:lower() + <h3 class="indent">$(kind)</h3> + <ul> +# for item in items() do + <li class="def" id="$(item.name)"> + <label> + <a href="#$(item.name)"><code>$(display_name(item))</code></a> + </label> +  – $(M(item.summary)) + <div class="nest"> + $(M(item.description)) -# if item.params and #item.params > 0 then -# local subnames = module.kinds:type_of(item).subnames -# if subnames then - <h4>$(subnames:lower()):</h4> -# end - <ul> -# for parm in iter(item.params) do -# local param,sublist = item:subparam(parm) -# for p in iter(param) do -# local name = item:display_name_of(p) -# local tp = ldoc.typename(item:type_of_param(p)) -# local def = item:default_of_param(p) -# local desc = item.params.map[p] -# local col = desc and desc ~= "" and ":" or "" - <li> - <label> - <code>$(name)</code> -# if tp ~= "" then - ($(tp))$(col) -# else - $(col) -# end - </label> - $(M(desc,item)) -# if def == true then - (<em>optional</em>) -# elseif def then - (<em>default</em> $(def)) +# if item.usage then +# local li,il = use_li(item.usage) + <h4>usage:</h4> + <ul> +# for usage in iter(item.usage) do + $(li)<pre class="example"><code>$(usage)</code></pre>$(il) # end - </li> + </ul> # end -# end - </ul> -# end -# if item.retgroups then local groups = item.retgroups - <h4>returns:</h4> -# for i,group in ldoc.ipairs(groups) do - <ol> -# for r in group:iter() do -# local type, ctypes = item:return_type(r) -# local rt = ldoc.typename(type) -# local col = r.text and r.text ~= "" and ":" or "" - <li> -# if rt ~= "" then - ($(rt))$(col) -# end - $(M(r.text,item)) -# if ctypes then - <ul> -# for c in ctypes:iter() do - <li><span class="parameter">$(c.name)</span> - <span class="types">$(ldoc.typename(c.type))</span> - $(M(c.comment,item))</li> +# if item.params and #item.params > 0 then +# local subnames = module.kinds:type_of(item).subnames +# if subnames then + <h4>$(subnames:lower()):</h4> +# end + <ul> +# for parm in iter(item.params) do +# local param,sublist = item:subparam(parm) +# for p in iter(param) do +# local name = item:display_name_of(p) +# local tp = ldoc.typename(item:type_of_param(p)) +# local def = item:default_of_param(p) +# local desc = item.params.map[p] +# local col = desc and desc ~= "" and ":" or "" + <li> + <label> + <code>$(name)</code> +# if tp ~= "" then + ($(tp))$(col) +# else + $(col) +# end + </label> + $(M(desc,item)) +# if def == true then + (<em>optional</em>) +# elseif def then + (<em>default</em> $(def)) # end - </ul> + </li> # end - </li> +# end + </ul> # end - </ol> -# if i < #groups then - <h4>or</h4> + +# if item.retgroups then local groups = item.retgroups + <h4>returns:</h4> +# for i,group in ldoc.ipairs(groups) do + <ol> +# for r in group:iter() do +# local type, ctypes = item:return_type(r) +# local rt = ldoc.typename(type) +# local col = r.text and r.text ~= "" and ":" or "" + <li> +# if rt ~= "" then + ($(rt))$(col) +# end + $(M(r.text,item)) +# if ctypes then + <ul> +# for c in ctypes:iter() do + <li><span class="parameter">$(c.name)</span> + <span class="types">$(ldoc.typename(c.type))</span> + $(M(c.comment,item))</li> +# end + </ul> +# end + </li> +# end + </ol> +# if i < #groups then + <h4>or</h4> +# end +# end # end -# end -# end -# if item.usage then -# local li,il = use_li(item.usage) - <h4>usage:</h4> - <ul> -# for usage in iter(item.usage) do - $(li)<pre class="example">$(ldoc.prettify(usage))</pre>$(il) -# end - </ul> +# if item.usage then +# local li,il = use_li(item.usage) + <h4>usage:</h4> + <ul> +# for usage in iter(item.usage) do + $(li)<pre class="example">$(ldoc.prettify(usage))</pre>$(il) +# end + </ul> +# end + </div> + </li> # end - </div> - </li> + </ul> # end -</ul> # end # end ' + } else error "unknown command '#{command}'" diff --git a/extra/layout.moon b/extra/layout.moon index 70d9848..2741a70 100644 --- a/extra/layout.moon +++ b/extra/layout.moon @@ -64,8 +64,10 @@ aopts = (href, pat) -> -- layout and write a doc page -- opts: +-- - preamble -- - title --- - body +-- - style +-- - body (str or table) layout = (opts) -> import header, footer, nav, div, span, b, code, a, article from require 'extra.dom' @@ -103,7 +105,6 @@ layout = (opts) -> <title>#{title}</title> <link rel=\"stylesheet\" href=\"#{opts.style or abs 'style.css'}\"> - #{opts.css or ''} </head> <body> #{head} |
