1+ ## _*_ coding: utf-8 _*_
2+ <!DOCTYPE HTML>
3+
4+ <
link rel =
" stylesheet" href =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/css/bootstrap.min.css" integrity =
" sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin =
" anonymous" >
5+ <script src =" https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity =" sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin =" anonymous" ></script >
6+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/umd/popper.min.js" integrity =
" sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin =
" anonymous" ></
script >
7+ <
script src =
" https://cdn.jsdelivr.net/npm/[email protected] /dist/js/bootstrap.min.js" integrity =
" sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin =
" anonymous" ></
script >
8+
9+ <%def name = "render_pointer(pointer_name ) ">
10+ ${ make_rules(rs = ijson.rules_from_pointer(pointer_name))}
11+ </%def >
12+
13+ <%def name = "make_rules(rs ) ">
14+ <% # # get a unique id
15+ attributes[' count' ] = attributes[' count' ] + 1
16+ local_count = attributes[' count' ]
17+ %>
18+ % if len (rs) == 1 : # # single rules for a pointer use a cell
19+ ${ make_rule(r = rs[0 ])}
20+ % endif
21+ % if len (rs) > 1 : # # multiple rules use a collapsible block
22+ <div id =" accordion${local_count}" >
23+ <div class =" card" >
24+ <div class =" card-header" id =" heading${local_count}" >
25+ <h5 class =" mb-0" >
26+ <button class =" btn btn-link" data-toggle =" collapse" data-target =" #collapse${local_count}" aria-expanded =" true" aria-controls =" collapse${local_count}" >
27+ ${ rs[0 ][' pointer' ]}
28+ </button >
29+ </h5 >
30+ </div >
31+ <div id =" collapse${local_count}" class =" collapse show" aria-labelledby =" heading${local_count}" data-parent =" #accordion${local_count}" >
32+ % for r in rs:
33+ ${ make_rule(r = rs[0 ])}
34+ % endfor
35+ </div >
36+ </div >
37+ </div >
38+ % endif
39+ </%def >
40+
41+ <%def name = "make_rule(r ) ">
42+ <%
43+ attributes[' count' ] = attributes[' count' ] + 1
44+ local_count = attributes[' count' ]
45+ %>
46+ % if r[' type' ] == " object" : # # Object
47+ <div id =" accordion${local_count}" >
48+ <div class =" card" >
49+ <div class =" card-header" id =" heading${local_count}" >
50+ <h5 class =" mb-0" >
51+ <button class =" btn btn-link" data-toggle =" collapse" data-target =" #collapse${local_count}" aria-expanded =" true" aria-controls =" collapse${local_count}" >
52+ ${ r[' pointer' ]} , Object
53+ </button >
54+ </h5 >
55+ </div >
56+ <div id =" collapse${local_count}" class =" collapse hide" aria-labelledby =" heading${local_count}" data-parent =" #accordion${local_count}" >
57+
58+ % if ' required' in r:
59+ <div class =" container" >
60+ <div class =" row" >
61+ <div class =" auto" >
62+ Required
63+ </div >
64+ <div class =" col-sm" >
65+ % for fname in r[' required' ]:
66+ ${ render_pointer(pointer_name = (r[' pointer' ]+ fname) if r[' pointer' ] == ' /' else (r[' pointer' ]+ ' /' + fname))}
67+ % endfor
68+ </div >
69+ </div >
70+ </div >
71+ % endif
72+ % if ' optional' in r:
73+ <div class =" container" >
74+ <div class =" row" >
75+ <div class =" auto" >
76+ Optional
77+ </div >
78+ <div class =" col-sm" >
79+ % for fname in r[' optional' ]:
80+ ${ render_pointer(pointer_name = (r[' pointer' ]+ fname) if r[' pointer' ] == ' /' else (r[' pointer' ]+ ' /' + fname))}
81+ % endfor
82+ </div >
83+ </div >
84+ </div >
85+ % endif
86+
87+ </div >
88+ </div >
89+ </div >
90+ % endif
91+ % if r[' type' ] == " list" : # # List
92+ ${ render_pointer(pointer_name = (r[' pointer' ]+ ' *' ) if r[' pointer' ] == ' /' else (r[' pointer' ]+ ' /' + ' *' ))}
93+ % endif
94+ </%def >
95+
96+ <html >
97+ <body >
98+ ${ render_pointer(pointer_name = ' /' )}
99+ </body >
100+ </html >
0 commit comments