Add comprehensive godoc documentation to all exported symbols

- Document all exported types, functions, methods, and constants across 52 files
- Add package-level doc comments to client, models, utils, and ynison packages
- Document HTTP method and endpoint path for each API client method
- Document model struct fields and DeJSON/DeList/ToJSON/ToMap methods
- Fix duplicate package doc comment in internal/models/base.go

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
MrixsandClaude Code committed 2026-10-18 08:57:43 +03:00
1 parent 7a68ad86cb
commit 0456ca0665
54 files changed
+1097 -652

No files matched your search

+16 -13
View File
@@ -8,35 +8,38 @@ import (
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/utils"
)
// Model is the base interface for all models
// Model is the base interface for all models.
// All model types implement this interface for JSON deserialization and serialization.
type Model interface {
// DeJSON deserializes from JSON
// DeJSON deserializes a model from JSON data.
DeJSON(data []byte, c ClientInterface) (Model, error)
// DeList deserializes a list of models
// DeList deserializes a list of models from JSON data.
DeList(data []byte, c ClientInterface) ([]Model, error)
// ToJSON serializes to JSON
// ToJSON serializes the model to JSON.
ToJSON() ([]byte, error)
// ToMap converts to map
// ToMap converts the model to a map.
ToMap() (map[string]any, error)
}
// BaseModel provides common functionality for models
// BaseModel provides common functionality for models, including a client reference.
type BaseModel struct {
Client ClientInterface `json:"-"`
}
// NewBaseModel creates a new BaseModel
// NewBaseModel creates a new BaseModel with the given client interface.
func NewBaseModel(c ClientInterface) *BaseModel {
return &BaseModel{Client: c}
}
// DeJSON implements Model.DeJSON for basic models
// DeJSON implements Model.DeJSON for basic models.
// This should be overridden by concrete types.
func (b *BaseModel) DeJSON(data []byte, c ClientInterface) (Model, error) {
// This should be overridden by concrete types
return nil, nil
}
// DeList implements Model.DeList for basic models
// DeList implements Model.DeList for basic models.
// This should be overridden by concrete types.
func (b *BaseModel) DeList(data []byte, c ClientInterface) ([]Model, error) {
var rawList []json.RawMessage
if err := json.Unmarshal(data, &rawList); err != nil {
@@ -51,12 +54,12 @@ func (b *BaseModel) DeList(data []byte, c ClientInterface) ([]Model, error) {
return result, nil
}
// ToJSON serializes the model to JSON
// ToJSON serializes the model to JSON using the default JSON backend.
func (b *BaseModel) ToJSON() ([]byte, error) {
return utils.Marshal(b)
}
// ToMap converts the model to a map
// ToMap converts the model to a map by serializing to JSON and unmarshaling into a map.
func (b *BaseModel) ToMap() (map[string]any, error) {
data, err := b.ToJSON()
if err != nil {
@@ -69,12 +72,12 @@ func (b *BaseModel) ToMap() (map[string]any, error) {
return result, nil
}
// SetClient sets the client on the model
// SetClient sets the client interface on the model.
func (b *BaseModel) SetClient(c ClientInterface) {
b.Client = c
}
// GetClient returns the client
// GetClient returns the client interface associated with the model.
func (b *BaseModel) GetClient() ClientInterface {
return b.Client
}