2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-21 21:13:22 +00:00

Compare commits

...

3 Commits

5 changed files with 64 additions and 1417 deletions

View File

@ -299,7 +299,25 @@ start:
func main() { func main() {
fset := token.NewFileSet() fset := token.NewFileSet()
os.Mkdir("docs", 0777) os.Mkdir("docs", 0777)
os.RemoveAll("docs/api")
os.Mkdir("docs/api", 0777) os.Mkdir("docs/api", 0777)
f, err := os.Create("docs/api/_index.md")
if err != nil {
panic(err)
}
f.WriteString(`---
title: API
layout: doc
weight: -100
menu: docs
---
Welcome to the API documentation for Hilbish. This documents Lua functions
provided by Hilbish.
`)
f.Close()
os.Mkdir("emmyLuaDocs", 0777) os.Mkdir("emmyLuaDocs", 0777)
dirs := []string{"./"} dirs := []string{"./"}

View File

@ -1,7 +1,9 @@
local fs = require 'fs' local fs = require 'fs'
local emmyPattern = '^%-%-%- (.+)' local emmyPattern = '^%-%-%- (.+)'
local emmyPattern2 = '^%-%- (.+)'
local modpattern = '^%-+ @module (.+)' local modpattern = '^%-+ @module (.+)'
local pieces = {} local pieces = {}
local descriptions = {}
local files = fs.readdir 'nature' local files = fs.readdir 'nature'
for _, fname in ipairs(files) do for _, fname in ipairs(files) do
@ -15,16 +17,24 @@ for _, fname in ipairs(files) do
print(fname, mod) print(fname, mod)
pieces[mod] = {} pieces[mod] = {}
descriptions[mod] = {}
local docPiece = {} local docPiece = {}
local lines = {} local lines = {}
local lineno = 0 local lineno = 0
local doingDescription = true
for line in f:lines() do for line in f:lines() do
lineno = lineno + 1 lineno = lineno + 1
lines[lineno] = line lines[lineno] = line
if line == header then goto continue2 end if line == header then goto continue2 end
if not line:match(emmyPattern) then if line:match(emmyPattern) or line:match(emmyPattern2) then
if doingDescription then
table.insert(descriptions[mod], line:match(emmyPattern) or line:match(emmyPattern2))
end
else
doingDescription = false
if line:match '^function' then if line:match '^function' then
local pattern = (string.format('^function %s%%.', mod) .. '(%w+)') local pattern = (string.format('^function %s%%.', mod) .. '(%w+)')
local funcName = line:match(pattern) local funcName = line:match(pattern)
@ -107,7 +117,12 @@ for iface, dps in pairs(pieces) do
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+') local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
if not newOrNotNature then if not newOrNotNature then
f:write(string.format(header, 'Module', iface, 'No description.', docParent)) f:write(string.format(header, 'Module', iface, (descriptions[iface] and #descriptions[iface] > 0) and descriptions[iface][1] or 'No description.', docParent))
if descriptions[iface] and #descriptions[iface] > 0 then
table.remove(descriptions[iface], 1)
f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
f:write('## Functions\n')
end
end end
print(f) print(f)

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,18 @@
--- ---
title: Module dirs title: Module dirs
description: No description. description: internal directory management
layout: doc layout: doc
menu: menu:
docs: docs:
parent: "Nature" parent: "Nature"
--- ---
## Introduction
The dirs module defines a small set of functions to store and manage
directories.
## Functions
<hr> <hr>
<div id='setOld'> <div id='setOld'>
<h4 class='heading'> <h4 class='heading'>

View File

@ -1,12 +1,20 @@
--- ---
title: Module doc title: Module doc
description: No description. description: command-line doc rendering
layout: doc layout: doc
menu: menu:
docs: docs:
parent: "Nature" parent: "Nature"
--- ---
## Introduction
The doc module contains a small set of functions
used by the Greenhouse pager to render parts of the documentation pages.
This is only documented for the sake of it. It's only intended use
is by the Greenhouse pager.
## Functions
<hr> <hr>
<div id='renderInfoBlock'> <div id='renderInfoBlock'>
<h4 class='heading'> <h4 class='heading'>