Skip to content

Commit

Permalink
Added documentation to all exported functions/structs
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Borders committed Nov 7, 2018
1 parent b576b92 commit bfdcabe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bible.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
)

// Bible contains the old testament and new testament
type Bible struct {
OldTestament Testament
NewTestament Testament
Expand All @@ -17,6 +18,7 @@ const bibleTar = "bible.tar.gz"
const oldTestamentFilename = "old_testament.json"
const newTestamentFilename = "new_testament.json"

// NewBible creates a new bible instance
func NewBible() *Bible {
bible := &Bible{}

Expand Down
4 changes: 4 additions & 0 deletions book.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package vulgata

// Book represents a single book in a testament of the bible
type Book struct {
Title string `json:"title"`
BookNumber uint8 `json:"bookNumber"`
Chapters []Chapter `json:"Chapters"`
}

// Chapter represents a single chapter in a book of the bible
type Chapter struct {
ChapterNumber uint8 `json:"chapterNumber"`
Verses []Verse `json:"verses"`
}

// Verse represents a single verse in a chapter of the bible,
// with both English and Latin texts
type Verse struct {
VerseNumber uint8 `json:"verseNumber"`
Text string `json:"text"`
Expand Down
5 changes: 5 additions & 0 deletions testament.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package vulgata

import "errors"

// Testament consists of a list of books, old vs. new
type Testament struct {
Books []Book
}

// GetBookNames creates a list of all book titles for the testament
func (t *Testament) GetBookNames() []string {
var n []string

Expand All @@ -16,6 +18,7 @@ func (t *Testament) GetBookNames() []string {
return n
}

// GetBook obtains a book within the testament by its number
func (t *Testament) GetBook(bookNumber int) (*Book, error) {
idx := bookNumber - 1
if idx < 0 || idx >= len(t.Books) {
Expand All @@ -25,6 +28,7 @@ func (t *Testament) GetBook(bookNumber int) (*Book, error) {
return &t.Books[idx], nil
}

// GetChapter obtains a chapter within the provided book by its number
func (t *Testament) GetChapter(bookNumber int, chapterNumber int) (*Chapter, error) {
b, err := t.GetBook(bookNumber)
if err != nil {
Expand All @@ -39,6 +43,7 @@ func (t *Testament) GetChapter(bookNumber int, chapterNumber int) (*Chapter, err
return &b.Chapters[idx], nil
}

// GetVerse obtains a verse within the provided book/chapter by its number
func (t *Testament) GetVerse(bookNumber int, chapterNumber int, verseNumber int) (*Verse, error) {
c, err := t.GetChapter(bookNumber, chapterNumber)
if err != nil {
Expand Down

0 comments on commit bfdcabe

Please sign in to comment.