varName

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2019 License: MIT Imports: 5 Imported by: 1

README ΒΆ

Qri GoDoc License Codecov CI Go Report Card

varName 🐫🍒🐍

Provides utility for converting lengthy titles into condensed but still recognizable variable names

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

This section is empty.

Functions ΒΆ

func CreateVarNameFromParams ΒΆ

func CreateVarNameFromParams(p *NameParams) string

CreateVarNameFromParams takes a lengthy title string and attempts to generate a condensed but still recognizable variable name

func CreateVarNameFromString ΒΆ

func CreateVarNameFromString(s string) string

CreateVarNameFromString does the same as CreateVarNameFromParams but uses a set of default settings and only reuires a string as an input

func MakeNameUnique ΒΆ

func MakeNameUnique(name string, existing *map[string]bool) string

MakeNameUnique takes a name, evaluates it against a set of existing names and returns a unique name by appending an underscore and number to the end Each time the function generates a new name, the name is added to the existing map

Types ΒΆ

type NameCase ΒΆ

type NameCase int

NameCase refers to one of a set of casing schemes such as camel, snake, kebab

const (
	// Camel refers to camel case; eg. somethingCamelCased
	Camel NameCase = iota
	// Snake refers to snake case; eg. something_snake_cased
	Snake
	// Kebab refers to kebab case; eg. something-kebab-cased
	Kebab
)

type NameParams ΒΆ

type NameParams struct {
	InputName string
	// dictionary of strings to filter out
	SkipWords *map[string]bool
	// dictioanry of strings to be substitute
	Substitutions *map[string]string
	// delimiter to use as word boundary
	Delim string
	// maximum lenth used
	MaxLen int
	// the if you want to override the replacement values with "", set to true
	RemoveOnly bool
	// if we should not allow words to occur repeated times, set to true
	NoRepeats bool
	// a choice of Left, Right, or Edge specifies which region of the input to prioritize
	Alignment TextAlignment
	// a choice of Camel, Snake, or Kebab to determine the name-casing
	NameCasing NameCase
}

NameParams is a convenience parameter struct made for CreateVarNameFromParams

func NewNameParams ΒΆ

func NewNameParams(name string) *NameParams

NewNameParams creates a pointer to a new NameParams struct and populates it with a set of default options

type TextAlignment ΒΆ

type TextAlignment int

TextAlignment refers to which section of text we want to prioritize

const (
	// Left keeps left-most text and truncates anything after a specified limit is exceeded
	Left TextAlignment = iota
	// Right keeps right-most text and truncates anything after a specified limit is exceeded
	Right
	// Edge keeps outer text and truncates any interior text after a specified limit is exceeded
	Edge
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL