docs: def _make_package(binder):
      """Makes an ``.epub.Package`` from a  Binder'ish instance."""
      package_id = binder.id
      if package_id is None:
          package_id = hash(binder)
  
      package_name = "{}.opf".format(package_id)
  
      extensions = get_model_extensions(binder)
  
      template_env = jinja2.Environment(trim_blocks=True, lstrip_blocks=True)
  
      # Build the package item list.
      items = []
      # Build the binder as an item, specifically a navigation item.
      navigation_document = bytes(HTMLFormatter(binder, extensions))
      navigation_document_name = "{}{}".format(
          package_id,
          mimetypes.guess_extension('application/xhtml+xml', strict=False))
      item = Item(str(navigation_document_name),
                  io.BytesIO(navigation_document),
                  'application/xhtml+xml',
                  is_navigation=True, properties=['nav'])
      items.append(item)
      resources = {}
      # Roll through the model list again, making each one an item.
      for model in flatten_model(binder):
          for resource in getattr(model, 'resources', []):
              resources[resource.id] = resource
              with resource.open() as data:
                  item = Item(resource.id, data, resource.media_type)
              items.append(item)
  
          if isinstance(model, (Binder, TranslucentBinder,)):
              continue
          if isinstance(model, DocumentPointer):
              content = bytes(HTMLFormatter(model))
              item = Item(''.join([model.ident_hash, extensions[model.id]]),
                          io.BytesIO(content),
                          model.media_type)
              items.append(item)
              continue
          for reference in model.references:
              if reference.remote_type == INLINE_REFERENCE_TYPE:
                  # has side effects - converts ref type to INTERNAL w/
                  # appropriate uri, so need to replicate resource treatment from
                  # above
                  resource = _make_resource_from_inline(reference)
                  model.resources.append(resource)
                  resources[resource.id] = resource
                  with resource.open() as data:
                      item = Item(resource.id, data, resource.media_type)
                  items.append(item)
                  reference.bind(resource, '../resources/{}')
  
              elif reference.remote_type == INTERNAL_REFERENCE_TYPE:
                  filename = os.path.basename(reference.uri)
                  resource = resources.get(filename)
                  if resource:
                      reference.bind(resource, '../resources/{}')
  
          complete_content = bytes(HTMLFormatter(model))
          item = Item(''.join([model.ident_hash, extensions[model.id]]),
                      io.BytesIO(complete_content),
                      model.media_type)
          items.append(item)
  
      # Build the package.
      package = Package(package_name, items, binder.metadata)
      return package