Skip to content

help/__init__

Full documentation pages are generated for docstring reference only and may contain symbols imported from other modules. Imported symbols are not distinguished from locally defined symbols and will appear in any module that they are imported into. For better information on where symbols should be imported from, review the sourcecode on the github.

FoSpy.json.help

generate_map_guide

generate_map_guide(
    cls=Synthesis, include_optional=False, parent_str=""
)
Source code in FoSpy/json/help/__init__.py
def generate_map_guide(cls=Synthesis, include_optional=False, parent_str=""):
    from ...blocks import ListBlock, SingleBlock

    opt_set = cls.build_validators() if include_optional else cls.build_req_validators()
    opt_set.pop("ext", None)

    guide = {}

    for key, validator in opt_set.items():
        current_key = parent_str + key
        if isinstance(validator, type):
            if issubclass(validator, SingleBlock):
                guide_dct = generate_map_guide(validator, include_optional=include_optional, parent_str=current_key+".")
                guide[key] = guide_dct
                continue
            elif issubclass(validator, ListBlock):
                reqCls = validator._reqCls
                example = [generate_map_guide(reqCls, include_optional=include_optional, parent_str=current_key+f"[{i}].") for i in range(2)]
                guide[key] = example
                continue
            elif issubclass(validator, list):
                example = [current_key+f"[{i}]" for i in range(2)]
                guide[key] = example
                continue

        guide[key] = current_key

    return guide