internal/nix/option.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | package nix
import (
"io"
"time"
"github.com/Southclaws/fault"
"github.com/yuin/goldmark"
"alin.ovh/searchix/internal/nixdocs"
)
type Markdown string
type Docs struct {
Plain string `json:",omitempty"`
Markdown Markdown `json:",omitempty"`
}
type Link struct {
Name string
URL string
}
type Option struct {
Name string `storm:"id"`
Source string
Declarations []Link
Default *Docs `json:",omitempty"`
Description Markdown
Example *Docs `json:",omitempty"`
Loc []string
Parents string
RelatedPackages Markdown `json:",omitempty"`
Type string
ImportedAt time.Time `storm:"index"`
}
func (Option) BleveType() string {
return "option"
}
func (p Option) GetName() string {
return p.Name
}
func (p Option) GetSource() string {
return p.Source
}
var md = goldmark.New(
nixdocs.WithNixDocsExtensions(),
)
// implements gomponent.Node
func (text Markdown) Render(w io.Writer) error {
return fault.Wrap(md.Convert([]byte(text), w))
}
|