all repos — searchix @ 702a8aacb9acd37cffef6b7f415deb72954a6f49

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

refactor: rename option fields to avoid sql database quoting

Alan Pearce
commit

702a8aacb9acd37cffef6b7f415deb72954a6f49

parent

495994761bc04fd9b46e65e389e8b2cda28f1020

M internal/components/optionDetail.gointernal/components/optionDetail.go
@@ -25,7 +25,7 @@ Dt(g.Text("Default")),
Dd( g.If(option.Default.Markdown != "", option.Default.Markdown, - Pre(Code(g.Text(option.Default.Text))), + Pre(Code(g.Text(option.Default.Plain))), ), ), })
@@ -38,7 +38,7 @@ Dt(g.Text("Example")),
Dd( g.If(option.Example.Markdown != "", option.Example.Markdown, - Pre(Code(g.Text(option.Example.Text))), + Pre(Code(g.Text(option.Example.Plain))), ), ), })
M internal/importer/options.gointernal/importer/options.go
@@ -15,7 +15,7 @@ "github.com/bcicen/jstream"
"github.com/mitchellh/mapstructure" ) -type nixValueJSON struct { +type nixDocJSON struct { Type string `mapstructure:"_type"` Text string }
@@ -27,30 +27,30 @@ }
type nixOptionJSON struct { Declarations []linkJSON - Default *nixValueJSON + Default *nixDocJSON Description string - Example *nixValueJSON + Example *nixDocJSON Loc []string ReadOnly bool RelatedPackages string Type string } -func (i *OptionIngester) convertValue(nj *nixValueJSON) *nix.Value { +func (i *OptionIngester) convertDocsValue(nj *nixDocJSON) *nix.Docs { if nj == nil { return nil } switch nj.Type { case "", "literalExpression": - return &nix.Value{ - Text: nj.Text, + return &nix.Docs{ + Plain: nj.Text, } case "literalMD": - return &nix.Value{ + return &nix.Docs{ Markdown: nix.Markdown(nj.Text), } default: - i.log.Warn("got unexpected Value type", "type", nj.Type, "text", nj.Text) + i.log.Warn("got unexpected docs type", "type", nj.Type, "text", nj.Text) return nil }
@@ -173,9 +173,9 @@ results <- nix.Option{
Name: kv.Key, Source: i.source.Key, Declarations: decs, - Default: i.convertValue(i.optJSON.Default), + Default: i.convertDocsValue(i.optJSON.Default), Description: nix.Markdown(i.optJSON.Description), - Example: i.convertValue(i.optJSON.Example), + Example: i.convertDocsValue(i.optJSON.Example), RelatedPackages: nix.Markdown(i.optJSON.RelatedPackages), Loc: i.optJSON.Loc, Type: i.optJSON.Type,
M internal/index/index_meta.gointernal/index/index_meta.go
@@ -11,7 +11,7 @@ "github.com/Southclaws/fault"
"github.com/Southclaws/fault/fmsg" ) -const CurrentSchemaVersion = 6 +const CurrentSchemaVersion = 7 type SourceMeta struct { ImportedAt time.Time
M internal/index/indexer.gointernal/index/indexer.go
@@ -123,9 +123,9 @@ nameNGramMapping.Analyzer = "c_name"
nameNGramMapping.IncludeTermVectors = true nameNGramMapping.Store = false - nixValueMapping := bleve.NewDocumentStaticMapping() - nixValueMapping.AddFieldMappingsAt("Text", textFieldMapping) - nixValueMapping.AddFieldMappingsAt("Markdown", textFieldMapping) + nixDocMapping := bleve.NewDocumentStaticMapping() + nixDocMapping.AddFieldMappingsAt("Text", textFieldMapping) + nixDocMapping.AddFieldMappingsAt("Markdown", textFieldMapping) locFieldMapping := bleve.NewKeywordFieldMapping() locFieldMapping.Analyzer = "loc"
@@ -145,8 +145,8 @@ optionMapping.AddFieldMappingsAt("Loc", locFieldMapping)
optionMapping.AddFieldMappingsAt("RelatedPackages", textFieldMapping) optionMapping.AddFieldMappingsAt("Description", descriptionFieldMapping) - optionMapping.AddSubDocumentMapping("Default", nixValueMapping) - optionMapping.AddSubDocumentMapping("Example", nixValueMapping) + optionMapping.AddSubDocumentMapping("Default", nixDocMapping) + optionMapping.AddSubDocumentMapping("Example", nixDocMapping) packageMapping := bleve.NewDocumentStaticMapping()
M internal/nix/option.gointernal/nix/option.go
@@ -11,8 +11,8 @@ )
type Markdown string -type Value struct { - Text string `json:",omitempty"` +type Docs struct { + Plain string `json:",omitempty"` Markdown Markdown `json:",omitempty"` }
@@ -25,9 +25,9 @@ type Option struct {
Name string Source string Declarations []Link - Default *Value `json:",omitempty"` + Default *Docs `json:",omitempty"` Description Markdown - Example *Value `json:",omitempty"` + Example *Docs `json:",omitempty"` Loc []string RelatedPackages Markdown `json:",omitempty"` Type string