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

Function generate_class_string

dash/development/_jl_components_generation.py:446–497  ·  view source on GitHub ↗
(name, props, description, project_shortname, prefix)

Source from the content-addressed store, hash-verified

444
445
446def generate_class_string(name, props, description, project_shortname, prefix):
447 # Ensure props are ordered with children first
448 filtered_props = reorder_props(filter_props(props))
449
450 prop_keys = list(filtered_props.keys())
451
452 docstring = (
453 create_docstring_jl(
454 component_name=name, props=filtered_props, description=description
455 )
456 .replace("\r\n", "\n")
457 .replace("$", "\\$")
458 )
459
460 wclist = get_wildcards_jl(props)
461 default_paramtext = ""
462
463 # Filter props to remove those we don't want to expose
464 for item in prop_keys[:]:
465 if item.endswith("-*") or item == "setProps":
466 prop_keys.remove(item)
467 elif item in julia_keywords:
468 prop_keys.remove(item)
469 warnings.warn(
470 (
471 'WARNING: prop "{}" in component "{}" is a Julia keyword'
472 " - REMOVED FROM THE JULIA COMPONENT"
473 ).format(item, name),
474 stacklevel=2,
475 )
476
477 default_paramtext += ", ".join(":{}".format(p) for p in prop_keys)
478
479 has_children = "children" in prop_keys
480 funcname = format_fn_name(prefix, name)
481 children_signatures = (
482 jl_children_signatures.format(funcname=funcname) if has_children else ""
483 )
484 children_definitions = (
485 jl_children_definitions.format(funcname=funcname) if has_children else ""
486 )
487 return jl_component_string.format(
488 funcname=format_fn_name(prefix, name),
489 docstring=docstring,
490 component_props=default_paramtext,
491 wildcard_symbols=stringify_wildcards(wclist, no_symbol=False),
492 wildcard_names=stringify_wildcards(wclist, no_symbol=True),
493 element_name=name,
494 module_name=project_shortname,
495 children_signatures=children_signatures,
496 children_definitions=children_definitions,
497 )
498
499
500def generate_struct_file(name, props, description, project_shortname, prefix):

Callers 1

generate_struct_fileFunction · 0.70

Calls 9

reorder_propsFunction · 0.85
create_docstring_jlFunction · 0.85
get_wildcards_jlFunction · 0.85
stringify_wildcardsFunction · 0.85
keysMethod · 0.80
filter_propsFunction · 0.70
format_fn_nameFunction · 0.70
removeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…