docs add lazy load to the iframes of the examples
This commit is contained in:
@@ -22,21 +22,6 @@ def process_index_rst(path):
|
|||||||
|
|
||||||
return(d)
|
return(d)
|
||||||
|
|
||||||
|
|
||||||
filelist = []
|
|
||||||
for root, dirs, files in os.walk(path):
|
|
||||||
for f in files:
|
|
||||||
#append the file name to the list
|
|
||||||
filelist.append(os.path.join(root,f))
|
|
||||||
|
|
||||||
filelist = [ fi for fi in filelist if fi.endswith("index.rst") ]
|
|
||||||
|
|
||||||
d_all = {}
|
|
||||||
#print all the file names
|
|
||||||
for fn in filelist:
|
|
||||||
d_act = process_index_rst(fn)
|
|
||||||
d_all.update(d_act)
|
|
||||||
|
|
||||||
h1= {
|
h1= {
|
||||||
"get_started":"Get started",
|
"get_started":"Get started",
|
||||||
"styles":"Styles",
|
"styles":"Styles",
|
||||||
@@ -88,16 +73,31 @@ layouts = {
|
|||||||
|
|
||||||
fout = open("examples.md", "w")
|
fout = open("examples.md", "w")
|
||||||
|
|
||||||
def print_item(path, lvl):
|
def print_item(path, lvl, d):
|
||||||
for k in d_all:
|
for k in d:
|
||||||
v = d_all[k]
|
v = d[k]
|
||||||
b = os.path.basename(k)
|
b = os.path.basename(k)
|
||||||
if k.startswith(path + "/lv_example_"):
|
if k.startswith(path + "/lv_example_"):
|
||||||
fout.write("#"*lvl + " " + v + "\n")
|
fout.write("#"*lvl + " " + v + "\n")
|
||||||
fout.write('<iframe class="lv-example" src="_static/built_lv_examples?example=' + b +'&w=320&h=240"></iframe>\n')
|
fout.write('<iframe loading="lazy" class="lv-example" src="_static/built_lv_examples?example=' + b +'&w=320&h=240"></iframe>\n')
|
||||||
fout.write("\n")
|
fout.write("\n")
|
||||||
|
|
||||||
def exec():
|
def exec():
|
||||||
|
|
||||||
|
filelist = []
|
||||||
|
for root, dirs, files in os.walk(path):
|
||||||
|
for f in files:
|
||||||
|
#append the file name to the list
|
||||||
|
filelist.append(os.path.join(root,f))
|
||||||
|
|
||||||
|
filelist = [ fi for fi in filelist if fi.endswith("index.rst") ]
|
||||||
|
|
||||||
|
d_all = {}
|
||||||
|
#print all the file names
|
||||||
|
for fn in filelist:
|
||||||
|
d_act = process_index_rst(fn)
|
||||||
|
d_all.update(d_act)
|
||||||
|
|
||||||
fout.write("```eval_rst\n")
|
fout.write("```eval_rst\n")
|
||||||
fout.write(".. include:: /header.rst\n")
|
fout.write(".. include:: /header.rst\n")
|
||||||
fout.write(":github_url: |github_link_base|/examples.md\n")
|
fout.write(":github_url: |github_link_base|/examples.md\n")
|
||||||
@@ -111,13 +111,13 @@ def exec():
|
|||||||
if h == "widgets":
|
if h == "widgets":
|
||||||
for w in widgets:
|
for w in widgets:
|
||||||
fout.write("### " + widgets[w] + "\n")
|
fout.write("### " + widgets[w] + "\n")
|
||||||
print_item(h + "/" + w, 4)
|
print_item(h + "/" + w, 4, d_all)
|
||||||
elif h == "layouts":
|
elif h == "layouts":
|
||||||
for l in layouts:
|
for l in layouts:
|
||||||
fout.write("### " + layouts[l] + "\n")
|
fout.write("### " + layouts[l] + "\n")
|
||||||
print_item(h + "/" + l, 4)
|
print_item(h + "/" + l, 4, d_all)
|
||||||
else:
|
else:
|
||||||
print_item(h, 3)
|
print_item(h, 3, d_all)
|
||||||
|
|
||||||
fout.write("")
|
fout.write("")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user