code: def _add_data_types_and_routes_to_api(self, namespace, desc):
          
  
          env = self._get_or_create_env(namespace.name)
  
          for item in desc:
              if isinstance(item, AstTypeDef):
                  api_type = self._create_type(env, item)
                  namespace.add_data_type(api_type)
                  self._check_canonical_name_available(item, namespace.name)
              elif isinstance(item, AstStructPatch) or isinstance(item, AstUnionPatch):
                  # Handle patches later.
                  base_name = self._get_base_name(item.name, namespace.name)
                  self._patch_data_by_canonical_name[base_name] = (item, namespace)
              elif isinstance(item, AstRouteDef):
                  route = self._create_route(env, item)
                  namespace.add_route(route)
                  self._check_canonical_name_available(item, namespace.name, allow_duplicate=True)
              elif isinstance(item, AstImport):
                  # Handle imports later.
                  pass
              elif isinstance(item, AstAlias):
                  alias = self._create_alias(env, item)
                  namespace.add_alias(alias)
                  self._check_canonical_name_available(item, namespace.name)
              elif isinstance(item, AstAnnotationDef):
                  annotation = self._create_annotation(env, item)
                  namespace.add_annotation(annotation)
                  self._check_canonical_name_available(item, namespace.name)
              elif isinstance(item, AstAnnotationTypeDef):
                  annotation_type = self._create_annotation_type(env, item)
                  namespace.add_annotation_type(annotation_type)
                  self._check_canonical_name_available(item, namespace.name)
              else:
                  raise AssertionError('Unknown AST node type %r' %
                                       item.__class__.__name__)
docs: From the raw output of the parser, create forward references for each
          user-defined type (struct, union, route, and alias).
  
          Args:
              namespace (stone.api.Namespace): Namespace for definitions.
              desc (List[stone.stone.parser._Element]): All AST nodes in a spec
                  file in the order they were defined. Should not include a
                  namespace declaration.