code: func IndexDirectory(dir, baseURL string) (*IndexFile, error) {
  	archives, err := filepath.Glob(filepath.Join(dir, "*.tgz"))
  	if err != nil {
  		return nil, err
  	}
  	moreArchives, err := filepath.Glob(filepath.Join(dir, "**/*.tgz"))
  	if err != nil {
  		return nil, err
  	}
  	archives = append(archives, moreArchives...)
  
  	index := NewIndexFile()
  	for _, arch := range archives {
  		fname, err := filepath.Rel(dir, arch)
  		if err != nil {
  			return index, err
  		}
  
  		var parentDir string
  		parentDir, fname = filepath.Split(fname)
  		// filepath.Split appends an extra slash to the end of parentDir. We want to strip that out.
  		parentDir = strings.TrimSuffix(parentDir, string(os.PathSeparator))
  		parentURL, err := urlutil.URLJoin(baseURL, parentDir)
  		if err != nil {
  			parentURL = path.Join(baseURL, parentDir)
  		}
  
  		c, err := chartutil.Load(arch)
  		if err != nil {
  			// Assume this is not a chart.
  			continue
  		}
  		hash, err := provenance.DigestFile(arch)
  		if err != nil {
  			return index, err
  		}
  		index.Add(c.Metadata, fname, parentURL, hash)
  	}
  	return index, nil
  }
docs: // IndexDirectory reads a (flat) directory and generates an index.
  //
  // It indexes only charts that have been packaged (*.tgz).
  //
  // The index returned will be in an unsorted state