Skip to content

Commit 646e2d4

Browse files
committed
Documentation
1 parent 24c31ce commit 646e2d4

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

library/library.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package library is responsible for orchestrating actions related to
2+
// providing a navigable representation of the audio library.
13
package library
24

35
import (
@@ -16,6 +18,8 @@ import (
1618
"github.com/pkg/errors"
1719
)
1820

21+
const rootAlbumTitle = "Eggplant"
22+
1923
type AlbumId string
2024

2125
func (id AlbumId) String() string {
@@ -55,8 +59,6 @@ type Album struct {
5559
Tracks []Track `json:"tracks,omitempty"`
5660
}
5761

58-
const rootAlbumTitle = "Eggplant"
59-
6062
type track struct {
6163
title string
6264
path string
@@ -66,7 +68,7 @@ type track struct {
6668
func newTrack(title string, path string) (track, error) {
6769
fileId, err := newFileId(path)
6870
if err != nil {
69-
return track{}, errors.Wrap(err, "could not create file id")
71+
return track{}, errors.Wrap(err, "could not create a file id")
7072
}
7173
t := track{
7274
title: title,
@@ -92,6 +94,8 @@ func newAlbum(title string) *album {
9294
}
9395
}
9496

97+
// Library receives scanner updates, dispatches them to appropriate stores and
98+
// builds a navigable representation of the music collection.
9599
type Library struct {
96100
root *album
97101
trackStore *store.TrackStore
@@ -100,6 +104,7 @@ type Library struct {
100104
log logging.Logger
101105
}
102106

107+
// New creates a library which receives updates from the specified channel.
103108
func New(ch <-chan scanner.Album, thumbnailStore *store.Store, trackStore *store.TrackStore) (*Library, error) {
104109
l := &Library{
105110
log: logging.New("library"),
@@ -112,13 +117,15 @@ func New(ch <-chan scanner.Album, thumbnailStore *store.Store, trackStore *store
112117

113118
}
114119

120+
// Browse lists the specified album. Provide a zero-length slice to list the
121+
// root album.
115122
func (l *Library) Browse(ids []AlbumId) (Album, error) {
116123
l.mutex.Lock()
117124
defer l.mutex.Unlock()
118125

119126
album, err := l.getAlbum(ids)
120127
if err != nil {
121-
return Album{}, errors.Wrap(err, "failed to get directory")
128+
return Album{}, errors.Wrap(err, "failed to get an album")
122129
}
123130

124131
parents, err := l.getParents(ids)

logging/logging.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package logging provides a layer of abstraction around external loggers.
12
package logging
23

34
import (

server/server.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package server exposes an HTTP API and serves the static files.
12
package server
23

34
import (

store/store.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package store is responsible for conversion and storage of tracks and
2+
// thumbnails.
13
package store
24

35
import (

0 commit comments

Comments
 (0)