Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kimtore committed May 13, 2017
1 parent b92f62a commit 2ed03d1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/api.go
@@ -1,3 +1,4 @@
// Package api provides data model interfaces.
package api

import (
Expand Down
4 changes: 4 additions & 0 deletions commands/command.go
@@ -1,5 +1,9 @@
// Package commands contains all functionality that is triggered by the user,
// either through keyboard bindings or the command-line interface. New commands
// such as 'sort', 'add', etc. must be implemented here.
package commands

// Command must be implemented by all commands.
type Command interface {
// Parse the next input token
Execute(class int, s string) error
Expand Down
6 changes: 6 additions & 0 deletions console/console.go
@@ -1,3 +1,4 @@
// Package console provides logging functions.
package console

import (
Expand All @@ -10,6 +11,7 @@ var logFile *os.File

var start = time.Now()

// Open opens a log file for writing.
func Open(logfile string) (err error) {
logFile, err = os.Create(logfile)
if err != nil {
Expand All @@ -18,10 +20,14 @@ func Open(logfile string) (err error) {
return
}

// Close closes an open log file.
func Close() {
logFile.Close()
}

// Log writes a log line to the log file.
// A timestamp and a newline is automatically added.
// If the log file isn't open, nothing is done.
func Log(format string, args ...interface{}) {
if logFile == nil {
return
Expand Down
8 changes: 7 additions & 1 deletion index/filters/unicodestrip/unicodestrip.go
@@ -1,3 +1,4 @@
// Package unicodestrip provides a Bleve keyword filter which decomposes unicode strings.
package unicodestrip

import (
Expand All @@ -18,18 +19,22 @@ const Name = "strip_unicode"
type StripUnicodeFilter struct {
}

// New returns a new instance of StripUnicodeFilter.
func New() (*StripUnicodeFilter, error) {
return &StripUnicodeFilter{}, nil
}

// Constructor provides a constructor for Bleve.
func Constructor(config map[string]interface{}, cache *registry.Cache) (analysis.TokenFilter, error) {
return New()
}

// isMn returns true if the provided rune is a unicode non-spacing mark.
func isMn(r rune) bool {
return unicode.Is(unicode.Mn, r) // Mn: nonspacing marks
return unicode.Is(unicode.Mn, r)
}

// Filter removes non-spacing marks from text in a token stream.
func (s *StripUnicodeFilter) Filter(input analysis.TokenStream) analysis.TokenStream {
chain := transform.Chain(norm.NFKD, transform.RemoveFunc(isMn), norm.NFC)
for _, token := range input {
Expand All @@ -38,6 +43,7 @@ func (s *StripUnicodeFilter) Filter(input analysis.TokenStream) analysis.TokenSt
return input
}

// init registers this plugin with Bleve.
func init() {
registry.RegisterTokenFilter(Name, Constructor)
}

0 comments on commit 2ed03d1

Please sign in to comment.