(self, data, options=None, **kwargs)
Return instance of class based on Go data

        Data keys handled here:

            _type
                Set the object class

            consts, types, vars, funcs, methods
                Recurse into :py:meth:`create_class` to create child object
                instances

        :param data: dictionary data from godocjson output
Return instance of class based on Go data
Return instance of class based on Go data
def create_class(self, data, options=None, **kwargs):
        """Return instance of class based on Go data

        Data keys handled here:

            _type
                Set the object class

            consts, types, vars, funcs, methods
                Recurse into :py:meth:`create_class` to create child object
                instances

        :param data: dictionary data from godocjson output
        """
        _type = kwargs.get("_type")
        obj_map = dict((cls.type, cls) for cls in ALL_CLASSES)
        try:
            # Contextual type data from children recursion
            if _type:
                LOGGER.debug("Forcing Go Type %s" % _type)
                cls = obj_map[_type]
            else:
                cls = obj_map[data["type"]]
        except KeyError:
            # this warning intentionally has no (sub-)type
            LOGGER.warning("Unknown type: %s" % data)
        else:
            if cls.inverted_names and "names" in data:
                # Handle types that have reversed names parameter
                for name in data["names"]:
                    data_inv = {}
                    data_inv.update(data)
                    data_inv["name"] = name
                    if "names" in data_inv:
                        del data_inv["names"]
                    for obj in self.create_class(data_inv):
                        yield obj
            else:
                # Recurse for children
                obj = cls(data, jinja_env=self.jinja_env, app=self.app)
                for child_type in ["consts", "types", "vars", "funcs", "methods"]:
                    for child_data in data.get(child_type, []):
                        obj.children += list(
                            self.create_class(
                                child_data,
                                _type=child_type.replace("consts", "const")
                                .replace("types", "type")
                                .replace("vars", "variable")
                                .replace("funcs", "func")
                                .replace("methods", "method"),
                            )
                        )
                yield obj
def create_class ( self , data , options = None , * * kwargs ) : _type = kwargs . get ( "_type" ) obj_map = dict ( ( cls . type , cls ) for cls in ALL_CLASSES ) try : # Contextual type data from children recursion if _type : LOGGER . debug ( "Forcing Go Type %s" % _type ) cls = obj_map [ _type ] else : cls = obj_map [ data [ "type" ] ] except KeyError : # this warning intentionally has no (sub-)type LOGGER . warning ( "Unknown type: %s" % data ) else : if cls . inverted_names and "names" in data : # Handle types that have reversed names parameter for name in data [ "names" ] : data_inv = { } data_inv . update ( data ) data_inv [ "name" ] = name if "names" in data_inv : del data_inv [ "names" ] for obj in self . create_class ( data_inv ) : yield obj else : # Recurse for children obj = cls ( data , jinja_env = self . jinja_env , app = self . app ) for child_type in [ "consts" , "types" , "vars" , "funcs" , "methods" ] : for child_data in data . get ( child_type , [ ] ) : obj . children += list ( self . create_class ( child_data , _type = child_type . replace ( "consts" , "const" ) . replace ( "types" , "type" ) . replace ( "vars" , "variable" ) . replace ( "funcs" , "func" ) . replace ( "methods" , "method" ) , ) ) yield obj