Skip to content

Commit 9960b13

Browse files
committed
DOC: generate from json format
1 parent 6eb3bbc commit 9960b13

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

documentation/mkref.bas

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
split trim(command), " ", args
1515
tload args(0), in_str, 1
1616

17-
# cleanup the mysq json
17+
# cleanup the mysql json
1818
in_str = translate(in_str, "\'", "'")
1919
in_str = translate(in_str, "'entity_id' :", "\"entity_id\":")
2020
in_str = translate(in_str, "'body_value' :", "\"body_value\":")
@@ -35,15 +35,17 @@ func get_field(row, key)
3535
get_field = result
3636
end
3737

38-
func fix_comments(comments)
38+
func fix_comments(comments, keyword)
3939
comments = translate(comments, "p. ", "")
4040
comments = translate(comments, "bq. ", "")
4141
comments = translate(comments, "bc. ", "")
4242
comments = translate(comments, "bc.. ", "")
43-
comments = translate(comments, "\\\"", "\"")
43+
comments = translate(comments, "__", "")
44+
comments = translate(comments, "**", "")
4445
comments = translate(comments, " ", " ")
45-
comments = translate(comments, "<code>", "--Example--" + chr(10))
46-
comments = translate(comments, "</code>", chr(10) + "--End Of Example--")
46+
comments = translate(comments, "\\\"", "\"")
47+
comments = translate(comments, "<code>", "----[ " + keyword + " example. cut here ]----" + chr(10))
48+
comments = translate(comments, "</code>", chr(10) + "----[ cut here ]----")
4749
comments = translate(comments, "\\r\\n", chr(10))
4850
fix_comments = comments
4951
end
@@ -57,7 +59,10 @@ sub mk_help(byref in_map)
5759
type = get_field(row, "type=")
5860
keyword = get_field(row, "keyword=")
5961
syntax = get_field(row, "syntax=")
60-
brief = get_field(row, "brief=")
62+
brief = translate(get_field(row, "brief="), "\\\"", "\"\"")
63+
while (i + 1 < in_map_len && in_map(i).entity_id == in_map(i + 1).entity_id)
64+
i++
65+
wend
6166
? group + "," + type + "," + keyword + "," + in_map(i).entity_id + ",\"" + syntax + "\",\"" + brief + "\""
6267
next i
6368
end
@@ -67,17 +72,26 @@ sub mk_text_reference(byref in_map)
6772
local in_map_len = len(in_map) - 1
6873
local end_block = "<!-- end heading block -->"
6974

75+
7076
? "SmallBASIC Language reference"
7177
? "See: http://smallbasic.sourceforge.net/?q=node/201"
7278
?
79+
? " _____ _ _ ____ _____ _____ _____
80+
? " / ____| | | | _ \ /\ / ____|_ _/ ____|
81+
? " | (___ _ __ ___ __ _| | | |_) | / \ | (___ | || |
82+
? " \___ \| '_ ` _ \ / _` | | | _ < / /\ \ \___ \ | || |
83+
? " ____) | | | | | | (_| | | | |_) / ____ \ ____) |_| || |____
84+
? " |_____/|_| |_| |_|\__,_|_|_|____/_/ \_\_____/|_____\_____|
85+
?
7386

7487
for i = 0 to in_map_len
7588
row = in_map(i).body_value
7689
group = get_field(row, "group=")
7790
type = get_field(row, "type=")
7891
keyword = get_field(row, "keyword=")
7992
syntax = get_field(row, "syntax=")
80-
brief = get_field(row, "brief=")
93+
brief = translate(get_field(row, "brief="), "\\\"", "\"")
94+
8195
? (i+1) + ". (" + group + ") " + keyword
8296
?
8397
? syntax
@@ -86,11 +100,15 @@ sub mk_text_reference(byref in_map)
86100
?
87101
pos = instr(row, end_block) + len(end_block)
88102
if (pos < len(row)) then
89-
? fix_comments(mid(row, pos))
103+
? fix_comments(mid(row, pos), keyword)
90104
endif
91105
comments = in_map(i).comment_body_value
92106
if (comments != "NULL") then
93-
? fix_comments(comments)
107+
? fix_comments(comments, keyword)
94108
endif
109+
while (i + 1 < in_map_len && in_map(i).entity_id == in_map(i + 1).entity_id)
110+
i++
111+
? fix_comments(in_map(i).comment_body_value, keyword)
112+
wend
95113
next i
96114
end

0 commit comments

Comments
 (0)