MCPcopy Index your code
hub / github.com/plotly/dash / generate_class_string

Function generate_class_string

dash/development/_r_components_generation.py:179–241  ·  view source on GitHub ↗
(name, props, project_shortname, prefix)

Source from the content-addressed store, hash-verified

177
178# pylint: disable=R0914
179def generate_class_string(name, props, project_shortname, prefix):
180 # Here we convert from snake case to camel case
181 package_name = snake_case_to_camel_case(project_shortname)
182
183 # Ensure props are ordered with children first
184 props = reorder_props(props=props)
185
186 prop_keys = list(props.keys())
187
188 wildcards = ""
189 wildcard_declaration = ""
190 wildcard_names = ""
191 default_paramtext = ""
192 default_argtext = ""
193 accepted_wildcards = ""
194
195 if any(key.endswith("-*") for key in prop_keys):
196 accepted_wildcards = get_wildcards_r(prop_keys)
197 wildcards = ", ..."
198 wildcard_declaration = wildcard_template.format(
199 accepted_wildcards.replace("-*", "")
200 )
201 wildcard_names = ", wildcard_names"
202
203 # Produce a string with all property names other than WCs
204 prop_names = ", ".join(
205 "'{}'".format(p) for p in prop_keys if "*" not in p and p not in ["setProps"]
206 )
207
208 # Filter props to remove those we don't want to expose
209 for item in prop_keys[:]:
210 if item.endswith("-*") or item == "setProps":
211 prop_keys.remove(item)
212 elif item in r_keywords:
213 prop_keys.remove(item)
214 warnings.warn(
215 (
216 'WARNING: prop "{}" in component "{}" is an R keyword'
217 " - REMOVED FROM THE R COMPONENT"
218 ).format(item, name),
219 stacklevel=2,
220 )
221
222 default_argtext += ", ".join("{}=NULL".format(p) for p in prop_keys)
223
224 # pylint: disable=C0301
225 default_paramtext += ", ".join(
226 "{0}={0}".format(p) if p != "children" else "{}=children".format(p)
227 for p in prop_keys
228 )
229
230 return r_component_string.format(
231 funcname=format_fn_name(prefix, name),
232 name=name,
233 default_argtext=default_argtext,
234 wildcards=wildcards,
235 wildcard_declaration=wildcard_declaration,
236 default_paramtext=default_paramtext,

Callers 1

write_class_fileFunction · 0.70

Calls 7

snake_case_to_camel_caseFunction · 0.85
reorder_propsFunction · 0.85
get_wildcards_rFunction · 0.85
keysMethod · 0.80
format_fn_nameFunction · 0.70
formatMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…