sentence

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: BSD-3-Clause Imports: 4 Imported by: 9

Documentation

Overview

Package sentence provides functions for creating formatted sentences.

Index

Constants

This section is empty.

Variables

View Source
var ProperNouns = map[string]struct{}{}

ProperNouns is a set-style map that contains all of the proper nouns that will not be lowercased (such as Google or Thompson). Proper nouns should be specified in their CamelCase form (Google, Thompson, etc). Proper nouns should be added to this map through AddProperNouns. By default, this map contains nothing.

Functions

func AddProperNouns

func AddProperNouns(nouns ...string)

AddProperNouns adds the given proper nouns (such as Google or Thompson) to ProperNouns. It is the way that end-user code should specify proper nouns. Proper nouns will not be lowercased when converting to sentence case. Proper nouns should be specified in their CamelCase form (Google, Thompson, etc).

func Case

func Case(s string) string

Case returns the sentence case version of the given string. It handles proper nouns through ProperNouns, abbreviations, and "I".

An example of a string in sentence case is:

This is a string in sentence case that I wrote in the USA with the help of Google

func Doc added in v0.1.8

func Doc(doc, name, label string) string

Doc formats the given Go documentation string for an identifier with the given CamelCase name and intended label. It replaces the name with the label and cleans up trailing punctuation.

func List

func List(items ...string) string

List returns a formatted version of the given list of items following these rules:

  • nil => ""
  • "Go" => "Go"
  • "Go", "Python" => "Go and Python"
  • "Go", "Python", "JavaScript" => "Go, Python, and JavaScript"
  • "Go", "Python", "JavaScript", "C" => "Go, Python, JavaScript, and C"

Types

This section is empty.

Jump to

Keyboard shortcuts

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