all repos — searchix @ c72f8dc787379f6544739c5c57a8241a14f6d2a0

Search engine for NixOS, nix-darwin, home-manager and NUR users

style: rename Option.Option to Option.Name
Alan Pearce alan@alanpearce.eu
Thu, 09 May 2024 19:12:52 +0200
commit

c72f8dc787379f6544739c5c57a8241a14f6d2a0

parent

3b379a13710cae2adc56131af1069e6fb92976b8

M frontend/templates/blocks/options.gotmplfrontend/templates/blocks/options.gotmpl
@@ -4,9 +4,9 @@ {{- if gt .Results.Total 0 }}     <section id="results">
       {{- range .Results.Hits }}
         {{- with .Data }}
-          <details id="{{ .Option }}">
+          <details id="{{ .Name }}">
             <summary>
-              {{ .Option }}
+              {{ .Name }}
             </summary>
             <p>
               {{ markdown .Description }}
M internal/importer/ingest.gointernal/importer/ingest.go
@@ -220,7 +220,7 @@ } 
 			// slog.Debug("sending option", "name", kv.Key)
 			results <- &options.NixOption{
-				Option:          kv.Key,
+				Name:            kv.Key,
 				Source:          strings.ToLower(i.source.Name),
 				Declarations:    decs,
 				Default:         convertNixValue(i.optJSON.Default),
M internal/options/option.gointernal/options/option.go
@@ -13,7 +13,7 @@ URL  string }
 
 type NixOption struct {
-	Option string
+	Name   string
 	Source string
 
 	Declarations    []Link
M internal/search/indexer.gointernal/search/indexer.go
@@ -122,7 +122,7 @@ locFieldMapping.Store = false 
 	optionMapping := bleve.NewDocumentStaticMapping()
 
-	optionMapping.AddFieldMappingsAt("Option", keywordFieldMapping)
+	optionMapping.AddFieldMappingsAt("Name", keywordFieldMapping)
 	optionMapping.AddFieldMappingsAt("Source", keywordFieldMapping)
 	optionMapping.AddFieldMappingsAt("Loc", locFieldMapping)
 	optionMapping.AddFieldMappingsAt("RelatedPackages", textFieldMapping)
@@ -165,10 +165,10 @@ break outer 			default:
 			}
 
-			doc := document.NewDocument(opt.Source + "/" + opt.Option)
+			doc := document.NewDocument(opt.Source + "/" + opt.Name)
 			err = i.indexMapping.MapDocument(doc, opt)
 			if err != nil {
-				errs <- errors.WithMessagef(err, "could not map document for option: %s", opt.Option)
+				errs <- errors.WithMessagef(err, "could not map document for option: %s", opt.Name)
 
 				continue
 			}
@@ -184,11 +184,11 @@ } 			field := document.NewTextFieldWithIndexingOptions("_data", nil, data.Bytes(), index.StoreField)
 			newDoc := doc.AddField(field)
 
-			// slog.Debug("adding option to index", "name", opt.Option)
+			// slog.Debug("adding option to index", "name", opt.Name)
 			err = batch.IndexAdvanced(newDoc)
 
 			if err != nil {
-				errs <- errors.WithMessagef(err, "could not index option %s", opt.Option)
+				errs <- errors.WithMessagef(err, "could not index option %s", opt.Name)
 
 				continue
 			}