Skip to content

Commit a7789b9

Browse files
committed
Updated main.md.mako
1 parent 873f8ec commit a7789b9

File tree

1 file changed

+43
-52
lines changed

1 file changed

+43
-52
lines changed

docs/main.md.mako

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
## _*_ coding: utf-8 _*_
2+
---
3+
template: no_toc.html
4+
---
25
<!--Automatically generated using JSON Spec Engine-->
36
<%def name="render_pointer(pointer_name, prefix)">
47
${make_rules(rs=ijson.rules_from_pointer(pointer_name), prefix=prefix)}
58
</%def>
6-
##
7-
##
9+
## ============================================================================
810
<%def name="make_rules(rs, prefix)">
911
<%
1012
if len(rs) > 0:
@@ -13,54 +15,74 @@ if len(rs) > 0:
1315
tmp = rs[0]['pointer'].replace('/*','')
1416
rs[0]['pointer_last'] = tmp.rsplit('/', 1)[-1]
1517
%>
16-
##
1718
% if len(rs) == 1: ## single rules for a pointer use a cell
18-
${make_rule(r=rs[0], prefix=prefix)}
19-
% endif
20-
##
21-
% if len(rs) > 1: ## multiple rules use a collapsible block
22-
${prefix}${"!!!" if len(prefix) == 0 else "???"} summary "`${rs[0]['pointer']}`"
19+
${make_rule(r=rs[0], prefix=prefix, tag="!!! json-spec" if len(prefix) == 0 else "??? json-spec")}
20+
% elif len(rs) > 1: ## multiple rules use a collapsible block
21+
${prefix}??? json-spec "`${rs[0]['pointer']}`"
2322
${prefix} ```
2423
${prefix} ${rs[0]['pointer']}
2524
${prefix} ```
25+
## ${prefix} ${"##"} Description
26+
## ${prefix} ${rs[0]['doc']}
2627
% for rule in rs:
27-
${make_rule(r=rule, prefix=prefix + " ")}
28+
${make_rule(r=rule, prefix=prefix + " ", tag="===")}
2829
% endfor
2930
% endif
3031
</%def>
31-
##
32-
##
33-
<%def name="make_rule(r, prefix)">
32+
## ============================================================================
33+
<%def name="make_rule(r, prefix, tag)">
3434
<%
3535
if not 'doc' in r:
36-
r['doc'] = '<span class="todo">FIXME:</span> Missing documentation in the specification'
37-
if r["doc"] == "TODO":
38-
r["doc"] = '<span class="todo">TODO</span>'
36+
r['doc'] = 'FIXME: Missing documentation in the specification.'
3937
r['pointer_last'] = r['pointer'].rsplit('/', 1)[-1]
4038
if r['pointer_last'] == '*':
4139
tmp = r['pointer'].replace('/*','')
4240
r['pointer_last'] = tmp.rsplit('/', 1)[-1]
4341
r['pointer_short'] = r['pointer']
4442
%>
4543
## ----------------------------------------------------------------------------
46-
% if r['type'] == "object": ## Object
47-
${prefix}${"!!!" if len(prefix) == 0 else "???"} summary "${r.get("type_name", f"`{r['pointer_short']}` (`{r['type']}`)")}"
44+
% if r['type'] == "list": ## List
45+
${prefix}${tag} "${r.get("type_name", f"`{r['pointer_short']}` (`{r['type']}`)")}"
46+
% if tag != "===":
4847
${prefix} ```
4948
${prefix} ${r['pointer']}
5049
${prefix} ```
50+
%endif
5151
${prefix} ${"##"} Description
5252
${prefix} ${r['doc']}
53-
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
53+
${render_pointer(
54+
pointer_name = (r['pointer']+'*') if r['pointer'] == '/' else (r['pointer']+'/'+'*'),
55+
prefix = prefix + " ")}
56+
## ----------------------------------------------------------------------------
57+
% else:
58+
${prefix}${tag} "${r.get("type_name", f"`{r['pointer_short']}` (`{r['type']}`)")}"
59+
% if tag != "===":
60+
${prefix} ```
61+
${prefix} ${r['pointer']}
62+
${prefix} ```
63+
%endif
5464
% if "type_name" in r:
5565
${prefix}
5666
${prefix} **Type**: ${r["type_name"]}
5767
% endif
58-
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
68+
${prefix} ${"##"} Description
69+
${prefix} ${r['doc']}
5970
% if "default" in r:
6071
${prefix}
61-
${prefix} **Default**: ${repr(r["default"])}
72+
${prefix} **Default**: `${repr(r["default"])}`
73+
% endif
74+
% if "min" in r or "max" in r:
75+
${prefix}
76+
${prefix} **Range:** `[${r.get("min", "-inf")}, ${r.get("max", "inf")}]`
77+
% endif
78+
% if "extensions" in r:
79+
${prefix}
80+
${prefix} **Extensions:** `${r["extensions"]}`
81+
% endif
82+
% if "options" in r:
83+
${prefix}
84+
${prefix} **Options:** `${r["options"]}`
6285
% endif
63-
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6486
% if 'required' in r:
6587
${prefix} ${"##"} Required
6688
% for fname in r['required']:
@@ -69,7 +91,6 @@ ${render_pointer(
6991
prefix = prefix + " ")}
7092
% endfor
7193
% endif
72-
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7394
% if 'optional' in r:
7495
${prefix} ${"##"} Optional
7596
% for fname in r['optional']:
@@ -78,36 +99,6 @@ ${render_pointer(
7899
prefix = prefix + " ")}
79100
% endfor
80101
% endif
81-
## ----------------------------------------------------------------------------
82-
% elif r['type'] == "list": ## List
83-
${render_pointer(
84-
pointer_name = (r['pointer']+'*') if r['pointer'] == '/' else (r['pointer']+'/'+'*'),
85-
prefix = prefix)}
86-
## ----------------------------------------------------------------------------
87-
% else:
88-
${prefix}${"!!!" if len(prefix) == 0 else "???"} summary "`${r['pointer_short']}` (`${r["type"]}`)"
89-
${prefix} ```
90-
${prefix} ${r['pointer']}
91-
${prefix} ```
92-
${prefix} ${"##"} Description
93-
${prefix} ${r['doc']}
94-
## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
95-
% if "min" in r or "max" in r:
96-
${prefix}
97-
${prefix} **Range:** `(${r.get("min", "-inf")}, ${r.get("max", "inf")})`
98-
% endif
99-
% if "default" in r:
100-
${prefix}
101-
${prefix} **Default**: `${repr(r["default"])}`
102-
% endif
103-
% if "extensions" in r:
104-
${prefix}
105-
${prefix} **Extensions:** `${r["extensions"]}`
106-
% endif
107-
% if "options" in r:
108-
${prefix}
109-
${prefix} **Options:** `${r["options"]}`
110-
% endif
111102
% endif
112103
</%def>
113104
${render_pointer(pointer_name='/', prefix='')}

0 commit comments

Comments
 (0)