MCPcopy Index your code
hub / github.com/plotly/plotly.py / perform_codegen

Function perform_codegen

codegen/__init__.py:111–330  ·  view source on GitHub ↗

Generate code (and possibly reformat).

(outdir, noformat=False)

Source from the content-addressed store, hash-verified

109
110
111def perform_codegen(outdir, noformat=False):
112 """Generate code (and possibly reformat)."""
113
114 # Get paths
115 validators_dir, graph_objs_dir, graph_objects_path = make_paths(outdir)
116
117 # Delete prior codegen output
118 if opath.exists(validators_dir):
119 shutil.rmtree(validators_dir)
120 if opath.exists(graph_objs_dir):
121 shutil.rmtree(graph_objs_dir)
122
123 # Load plotly schema
124 project_root = opath.dirname(outdir)
125 plot_schema_path = opath.join(
126 project_root, "codegen", "resources", "plot-schema.json"
127 )
128
129 with open(plot_schema_path, "r") as f:
130 plotly_schema = json.load(f)
131
132 # Preprocess Schema
133 preprocess_schema(plotly_schema)
134
135 # Build node lists
136
137 # TraceNode
138 base_traces_node = TraceNode(plotly_schema)
139 all_trace_nodes = PlotlyNode.get_all_datatype_nodes(plotly_schema, TraceNode)
140
141 # LayoutNode
142 compound_layout_nodes = PlotlyNode.get_all_compound_datatype_nodes(
143 plotly_schema, LayoutNode
144 )
145 layout_node = compound_layout_nodes[0]
146 all_layout_nodes = PlotlyNode.get_all_datatype_nodes(plotly_schema, LayoutNode)
147
148 subplot_nodes = [
149 node
150 for node in layout_node.child_compound_datatypes
151 if node.node_data.get("_isSubplotObj", False)
152 ]
153
154 layout_array_nodes = [
155 node
156 for node in layout_node.child_compound_datatypes
157 if node.is_array_element and node.has_child("xref") and node.has_child("yref")
158 ]
159
160 # FrameNode
161 compound_frame_nodes = PlotlyNode.get_all_compound_datatype_nodes(
162 plotly_schema, FrameNode
163 )
164 frame_node = compound_frame_nodes[0]
165 all_frame_nodes = PlotlyNode.get_all_datatype_nodes(plotly_schema, FrameNode)
166
167 # All nodes
168 all_datatype_nodes = all_trace_nodes + all_layout_nodes + all_frame_nodes

Callers 4

update_plotlyjsFunction · 0.90
update_plotlyjs_devFunction · 0.90
mainFunction · 0.90
__init__.pyFile · 0.85

Calls 15

TraceNodeClass · 0.90
get_validator_paramsFunction · 0.90
write_validator_jsonFunction · 0.90
write_datatype_pyFunction · 0.90
write_figure_classesFunction · 0.90
write_init_pyFunction · 0.90
build_from_imports_pyFunction · 0.90
make_pathsFunction · 0.85

Tested by

no test coverage detected