docs: def generate_build_file(startpath, outfilename=DEFAULT_BUILDFILE):
      """
      Generate a build file (yaml) based on the contents of a
      directory tree.
      """
      buildfilepath = os.path.join(startpath, outfilename)
      if os.path.exists(buildfilepath):
          raise BuildException("Build file %s already exists." % buildfilepath)
  
      contents = generate_contents(startpath, outfilename)
  
      with open(buildfilepath, 'w') as outfile:
          yaml.dump(contents, outfile, default_flow_style=False)
      return buildfilepath