Skip to content

Commit b199b6b

Browse files
committed
Add documentation for external libraries.
1 parent 611efc7 commit b199b6b

37 files changed

+404
-10
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ out
22
site
33
janet_modules
44
build
5-
jpm/
5+
/jpm/

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ build/bin/janet: janet/janet.c janet/janet.h janet/shell.c
2424
cd jpm && git pull origin master || true
2525
@cd jpm && $(JSETTINGS) PREFIX=$(CWD)/build/ $(CWD)/build/bin/janet bootstrap.janet
2626
@$(JSETTINGS) build/bin/jpm install mendoza
27+
@$(JSETTINGS) build/bin/jpm install spork
2728

2829
.PHONY: wasm
2930
wasm: static/js/janet.js

content/api/gen-docs.janet

+16-9
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@
7171

7272
{:tag "a" "href" (string "https://janetdocs.com/" (jdoc-escape key)) :content "Community Examples"}]}))
7373

74-
(def- all-entries
75-
(sort (pairs (table/getproto (fiber/getenv (fiber/current))))))
74+
(defn- all-entries
75+
[&opt env]
76+
(default env root-env)
77+
(sort (pairs env)))
7678

7779
(defn- get-from-prefix
7880
"Get all bindings that start with a prefix."
79-
[prefix]
80-
(seq [x :in all-entries
81+
[prefix &opt env]
82+
(seq [x :in (all-entries env)
8183
:let [[k entry] x]
8284
:when (symbol? k)
8385
:when (get entry :doc)
@@ -87,8 +89,8 @@
8789

8890
(defn- get-from-peg
8991
"Get all bindings that start with a prefix."
90-
[peg]
91-
(seq [x :in all-entries
92+
[peg &opt env]
93+
(seq [x :in (all-entries env)
9294
:let [[k entry] x]
9395
:when (symbol? k)
9496
:when (get entry :doc)
@@ -98,8 +100,8 @@
98100

99101
(defn gen-peg
100102
"Generate the document for all of the core api whose name matches the peg."
101-
[peg]
102-
(def entries (get-from-peg peg))
103+
[peg &opt env]
104+
(def entries (get-from-peg peg env))
103105
(def index
104106
(seq [[k entry] :in entries]
105107
[{:tag "a" "href" (string "#" k) :content k} " "]))
@@ -110,8 +112,13 @@
110112

111113
(defn gen-prefix
112114
"Generate the documentation for some subset of the core api."
115+
[prefix &opt env]
116+
(gen-peg (peg/compile prefix) env))
117+
118+
(defn gen-prefix-current
119+
"Generate the documentation for some module in that has been loaded"
113120
[prefix]
114-
(gen-peg (peg/compile prefix)))
121+
(gen-peg (peg/compile prefix) (curenv)))
115122

116123
(defn gen
117124
"Generate all bindings."

content/api/jpm/cc.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/cc :export true)
3+
4+
{:title "C Compiler"
5+
:nav-title "cc"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[cc/]

content/api/jpm/cgen.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/cgen :export true)
3+
4+
{:title "C Source Generation"
5+
:nav-title "cgen"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[cgen/]

content/api/jpm/cli.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/cli :export true)
3+
4+
{:title "Command Line Interface"
5+
:nav-title "cli"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[cli/]

content/api/jpm/commands.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/commands :export true)
3+
4+
{:title "Commands"
5+
:nav-title "commands"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[commands/]

content/api/jpm/config.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/config :export true)
3+
4+
{:title "Config"
5+
:nav-title "config"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[config/]

content/api/jpm/dagbuild.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/dagbuild :export true)
3+
4+
{:title "DAG Build"
5+
:nav-title "dagbuild"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[dagbuild/]

content/api/jpm/index.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm :export true)
3+
4+
{:title "JPM"
5+
:nav-title "jpm"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[jpm/]

content/api/jpm/make-config.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/make-config :export true)
3+
4+
{:title "Configuration Generation"
5+
:nav-title "make-config"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[make-config/]

content/api/jpm/pm.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/pm :export true)
3+
4+
{:title "Project Management"
5+
:nav-title "pm"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[pm/]

content/api/jpm/rules.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/rules :export true)
3+
4+
{:title "Build Rules"
5+
:nav-title "rules"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[rules/]

content/api/jpm/scaffold.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/scaffold :export true)
3+
4+
{:title "Project Scaffolding"
5+
:nav-title "scaffold"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[scaffold/]

content/api/jpm/shutil.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import jpm/shutil :export true)
3+
4+
{:title "Shell Utilities"
5+
:nav-title "shutil"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[shutil/]

content/api/spork/argparse.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/argparse :export true)
3+
4+
{:title "Argument Parsing"
5+
:nav-title "argparse"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[spork/]

content/api/spork/base64.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/base64 :export true)
3+
4+
{:title "Base64"
5+
:nav-title "base64"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[base64/]

content/api/spork/cron.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/cron :export true)
3+
4+
{:title "Cron"
5+
:nav-title "cron"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[cron/]

content/api/spork/ev-utils.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/ev-utils :export true)
3+
4+
{:title "EV Utilities"
5+
:nav-title "ev-utils"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[ev-utils/]

content/api/spork/fmt.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/fmt :export true)
3+
4+
{:title "Format"
5+
:nav-title "fmt"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[fmt/]

content/api/spork/generators.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/generators :export true)
3+
4+
{:title "Generators"
5+
:nav-title "generators"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[generators/]

content/api/spork/getline.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/getline :export true)
3+
4+
{:title "Getline"
5+
:nav-title "getline"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[getline/]

content/api/spork/http.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/http :export true)
3+
4+
{:title "HTTP"
5+
:nav-title "http"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[http/]

content/api/spork/httpf.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/httpf :export true)
3+
4+
{:title "HTTP Framework"
5+
:nav-title "httpf"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[httpf/]

content/api/spork/index.mdz

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork :export true)
3+
4+
{:title "Spork"
5+
:nav-title "spork"
6+
:template "docpage.html"}
7+
---
8+
9+
While not part of Janet's core library, Spork is an official "contributor" library as well as a collection
10+
of various useful utilties for Janet.
11+
12+
Spork can be installed with
13+
14+
@codeblock```
15+
jpm install spork
16+
```
17+
18+
## Index
19+
20+
@gen-docs/gen-prefix-current[spork/]

content/api/spork/json.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/json :export true)
3+
4+
{:title "JSON"
5+
:nav-title "json"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[json/]

content/api/spork/misc.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/misc :export true)
3+
4+
{:title "Miscellaneous Functions"
5+
:nav-title "misc"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[misc/]

content/api/spork/msg.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/msg :export true)
3+
4+
{:title "Simple Messaging Protocol"
5+
:nav-title "msg"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[msg/]

content/api/spork/netrepl.mdz

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(import ../gen-docs :as gen-docs)
2+
(import spork/netrepl :export true)
3+
4+
{:title "NetREPL"
5+
:nav-title "netrepl"
6+
:template "docpage.html"}
7+
---
8+
9+
## Index
10+
11+
@gen-docs/gen-prefix-current[netrepl/]

0 commit comments

Comments
 (0)