- Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathmake_ref_pages.py
71 lines (59 loc) · 2.23 KB
/
make_ref_pages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
importjson
schema=json.load(open("plotschema.json"))
forupperlangin ["Python", "JavaScript", "MATLAB", "R", "Julia", "F#"]:
lang=upperlang.lower()
lang="fsharp"iflang=="f#"elselang
lang="csharp"iflang=="c#"elselang
langcode="plotly_js"iflang=="javascript"elselang
forattrin [
"xaxis", "yaxis", "coloraxis", "scene", "polar", "ternary", "smith", "geo", "mapbox",
"sliders", "updatemenus", "annotations", "shapes", "images","selections", "global"
]:
fullattr="layout"+ ("."+attrifattr!="global"else"")
extra=""ifattr!="global"else"""
{%- for trace in site.data.plotschema.traces -%}
{% if trace[1].layoutAttributes %}
{% assign attribute=trace[1].layoutAttributes %}
{% include posts/reference-block.html parentlink="layout" block="layout" parentpath="layout" %}
{% endif %}
{%- endfor -%}
"""
withopen(f"../_posts/reference_pages/{lang}/2020-07-20-{attr}.html" , 'w') asf:
f.write(
f"""---
permalink: /{lang}/reference/{fullattr.replace(".", "/")}/
layout: langindex
page_type: reference
language: {langcode}
name: {fullattr}
description: Figure attribute reference for Plotly's {upperlang} open-source graphing library.
---
<h2>{upperlang} Figure Reference: <code>{fullattr}</code></h2>
<div class="row">
<div class="eight columns" style="max-width: 900px;">
{{% assign attribute=site.data.plotschema.layout.layoutAttributes %}}
{{% include posts/reference-block.html parentlink="layout" block="layout" parentpath="layout" mustmatch="{attr}" %}}
{extra}
</div>
</div>
"""
)
fortraceinschema["traces"]:
withopen(f"../_posts/reference_pages/{lang}/2020-07-20-{trace}.html" , 'w') asf:
f.write(
f"""---
permalink: /{lang}/reference/{trace}/
layout: langindex
page_type: reference
language: {langcode}
name: {trace} Traces
description: Figure attribute reference for Plotly's {upperlang} open-source graphing library.
---
<h2>{upperlang} Figure Reference: <code>{trace}</code> Traces</h2>
<div class="row">
<div class="eight columns" style="max-width: 900px;">
{{% include posts/reference-trace.html trace_name="{trace}" trace_data=site.data.plotschema.traces.{trace} %}}
</div>
</div>
"""
)