Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit 8d1b9a3

Browse files
committed
Add graindoc command & gen markdown
1 parent dffcadd commit 8d1b9a3

File tree

4 files changed

+125
-1
lines changed

4 files changed

+125
-1
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ test:
2727

2828
.PHONY: push
2929
push:
30-
hippofactory -s ${BINDLE_SERVER_URL} .
30+
hippofactory -s ${BINDLE_SERVER_URL} .
31+
32+
doc: lib/*.gr
33+
grain doc lib/env.gr -o lib/env.md
34+
grain doc lib/mediatype.gr -o lib/mediatype.md
35+
grain doc lib/stringutil.gr -o lib/stringutil.md

lib/env.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
### Env.**splitEnvVar**
2+
3+
```grain
4+
splitEnvVar : String -> (String, String)
5+
```
6+
7+
Split an environment variable at the first equals sign.
8+
9+
Parameters:
10+
11+
|param|type|description|
12+
|-----|----|-----------|
13+
|`item`|`String`|An environment variable pair, separated by an equals sign (=).|
14+
15+
Returns:
16+
17+
|type|description|
18+
|----|-----------|
19+
|`(String, String)`|A tuple key/value pair.|
20+
21+
### Env.**envMap**
22+
23+
```grain
24+
envMap : () -> Map.Map<a, b>
25+
```
26+
27+
Get the environment variables as a Map<String, String>
28+
29+
Returns:
30+
31+
|type|description|
32+
|----|-----------|
33+
|`Map.Map<a, b>`|A map of all environment variables.|
34+

lib/mediatype.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### Mediatype.**default_mt**
2+
3+
```grain
4+
default_mt : String
5+
```
6+
7+
### Mediatype.**guess**
8+
9+
```grain
10+
guess : String -> String
11+
```
12+
13+
Guess the media type of this file
14+
15+
Per recommendation, if no media type is found for an extension,
16+
this returns `application/octet-stream`.
17+
18+
Parameters:
19+
20+
|param|type|description|
21+
|-----|----|-----------|
22+
|`filename`|`String`|The name of the file|
23+
24+
Returns:
25+
26+
|type|description|
27+
|----|-----------|
28+
|`String`|A media type|
29+

lib/stringutil.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
### Stringutil.**reverse**
2+
3+
```grain
4+
reverse : String -> String
5+
```
6+
7+
Return a String that is the reverse of the given String.
8+
9+
Parameters:
10+
11+
|param|type|description|
12+
|-----|----|-----------|
13+
|`str`|`String`|The string to reverse.|
14+
15+
Returns:
16+
17+
|type|description|
18+
|----|-----------|
19+
|`String`|A reversed version of the given string|
20+
21+
### Stringutil.**lastIndexOf**
22+
23+
```grain
24+
lastIndexOf : (String, String) -> Option<Number>
25+
```
26+
27+
Get the index of the last appearance of needle in the haystack.
28+
29+
For a multi-character needle, this will return the end of that sequence,
30+
not the beginning (as indexOf does).
31+
32+
Parameters:
33+
34+
|param|type|description|
35+
|-----|----|-----------|
36+
|`needle`|`String`|The string to search for|
37+
|`haystack`|`String`|The string to be searched|
38+
39+
Returns:
40+
41+
|type|description|
42+
|----|-----------|
43+
|`Option<Number>`|The offset, if found, or a number|
44+
45+
### Stringutil.**afterLast**
46+
47+
```grain
48+
afterLast : (String, String) -> String
49+
```
50+
51+
### Stringutil.**beforeLast**
52+
53+
```grain
54+
beforeLast : (String, String) -> String
55+
```
56+

0 commit comments

Comments
 (0)