def parse_data_types_and_routes_from_doc_ref(<EOL>api,<EOL>doc,<EOL>namespace_context,<EOL>ignore_missing_entries=False<EOL>):
assert doc is not None<EOL>data_types = set()<EOL>routes = defaultdict(set)<EOL>for match in doc_ref_re.finditer(doc):<EOL><INDENT>try:<EOL><INDENT>tag = match.group('<STR_LIT>')<EOL>val = match.group('<STR_LIT>')<EOL>supplied_namespace = api.namespaces[namespace_context]<EOL>if tag == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:.>' in val:<EOL><INDENT>type_name, __ = val.split('<STR_LIT:.>', <NUM_LIT:1>)<EOL>doc_type = supplied_namespace.data_type_by_name[type_name]<EOL>data_types.add(doc_type)<EOL><DEDENT>else:<EOL><INDENT>pass  <EOL><DEDENT><DEDENT>elif tag == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:.>' in val:<EOL><INDENT>namespace_name, val = val.split('<STR_LIT:.>', <NUM_LIT:1>)<EOL>namespace = api.namespaces[namespace_name]<EOL><DEDENT>else:<EOL><INDENT>namespace = supplied_namespace<EOL><DEDENT>try:<EOL><INDENT>route_name, version = parse_route_name_and_version(val)<EOL><DEDENT>except ValueError as ex:<EOL><INDENT>raise KeyError(str(ex))<EOL><DEDENT>route = namespace.routes_by_name[route_name].at_version[version]<EOL>routes[namespace.name].add(route)<EOL><DEDENT>elif tag == '<STR_LIT:type>':<EOL><INDENT>if '<STR_LIT:.>' in val:<EOL><INDENT>namespace_name, val = val.split('<STR_LIT:.>', <NUM_LIT:1>)<EOL>doc_type = api.namespaces[namespace_name].data_type_by_name[val]<EOL>data_types.add(doc_type)<EOL><DEDENT>else:<EOL><INDENT>doc_type = supplied_namespace.data_type_by_name[val]<EOL>data_types.add(doc_type)<EOL><DEDENT><DEDENT><DEDENT>except KeyError:<EOL><INDENT>if not ignore_missing_entries:<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>return data_types, routes<EOL>
Given a documentation string, parse it and return all references to other
data types and routes.

Args:
- api: The API containing this doc ref.
- doc: The documentation string to parse.
- namespace_context: The namespace name relative to this documentation.
- ignore_missing_entries: If set, this will skip references to nonexistent data types instead
                          of raising an exception.

Returns:
- a tuple of referenced data types and routes