code: func (g *Generator) generateHrefs() (err error) {
  	var (
  		hrefFile string
  		resWr    *ResourcesWriter
  	)
  	{
  		hrefFile = filepath.Join(g.OutDir, "hrefs.go")
  		resWr, err = NewResourcesWriter(hrefFile)
  		if err != nil {
  			return
  		}
  	}
  	defer func() {
  		resWr.Close()
  		if err == nil {
  			err = resWr.FormatCode()
  		}
  	}()
  	title := fmt.Sprintf("%s: Application Resource Href Factories", g.API.Context())
  	imports := []*codegen.ImportSpec{
  		codegen.SimpleImport("fmt"),
  		codegen.SimpleImport("strings"),
  	}
  	if err = resWr.WriteHeader(title, g.Target, imports); err != nil {
  		return err
  	}
  	g.genfiles = append(g.genfiles, hrefFile)
  	err = g.API.IterateResources(func(r *design.ResourceDefinition) error {
  		m := g.API.MediaTypeWithIdentifier(r.MediaType)
  		var identifier string
  		if m != nil {
  			identifier = m.Identifier
  		} else {
  			identifier = "text/plain"
  		}
  		data := ResourceData{
  			Name:              codegen.Goify(r.Name, true),
  			Identifier:        identifier,
  			Description:       r.Description,
  			Type:              m,
  			CanonicalTemplate: codegen.CanonicalTemplate(r),
  			CanonicalParams:   codegen.CanonicalParams(r),
  		}
  		return resWr.Execute(&data)
  	})
  	return
  }
docs: // generateHrefs iterates through the API resources and generates the href factory methods.