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

+20 -21
View File
@@ -1,3 +1,4 @@
// Package client provides methods for interacting with Yandex Music API endpoints.
package client
import (
@@ -9,8 +10,7 @@ import (
"gitea.mrixs.me/Mrixs/yandex-music-api-go/internal/utils"
)
// GetTrackSupplement gets supplement for a track
// GET /tracks/{track_id}/supplement
// GetTrackSupplement gets supplement for a track (GET /tracks/{track_id}/supplement).
func (c *Client) GetTrackSupplement(ctx context.Context, trackID string) (*models.Supplement, error) {
path := fmt.Sprintf("/tracks/%s/supplement", trackID)
@@ -21,8 +21,9 @@ func (c *Client) GetTrackSupplement(ctx context.Context, trackID string) (*model
return &result, nil
}
// GetTrackLyrics gets lyrics for a track (new endpoint with signing)
// GET /tracks/{track_id}/lyrics
// GetTrackLyrics gets lyrics for a track (GET /tracks/{track_id}/lyrics).
// The format parameter specifies the lyrics format (e.g., "TEXT" or "LRC").
// The request is signed using the default signing key.
func (c *Client) GetTrackLyrics(ctx context.Context, trackID string, format string) (*models.TrackLyrics, error) {
path := fmt.Sprintf("/tracks/%s/lyrics", trackID)
@@ -42,7 +43,7 @@ func (c *Client) GetTrackLyrics(ctx context.Context, trackID string, format stri
return &result, nil
}
// GetTrackLyricsText fetches the full lyrics text from the download URL
// GetTrackLyricsText fetches the full lyrics text from the download URL provided in TrackLyrics.
func (c *Client) GetTrackLyricsText(ctx context.Context, trackLyrics *models.TrackLyrics) (string, error) {
data, err := c.request.Download(ctx, trackLyrics.DownloadURL)
if err != nil {
@@ -51,8 +52,7 @@ func (c *Client) GetTrackLyricsText(ctx context.Context, trackLyrics *models.Tra
return string(data), nil
}
// GetLyrics gets lyrics info for a track (legacy endpoint)
// GET /tracks/lyrics?track_id={track_id}
// GetLyrics gets lyrics info for a track using the legacy endpoint (GET /tracks/lyrics).
func (c *Client) GetLyrics(ctx context.Context, trackID string) (*models.LyricsInfo, error) {
params := map[string]string{
"track_id": trackID,
@@ -65,8 +65,7 @@ func (c *Client) GetLyrics(ctx context.Context, trackID string) (*models.LyricsI
return &result, nil
}
// GetVideoSupplement gets video supplement for a track (legacy endpoint)
// GET /tracks/video-supplement?track_id={track_id}
// GetVideoSupplement gets video supplement for a track using the legacy endpoint (GET /tracks/video-supplement).
func (c *Client) GetVideoSupplement(ctx context.Context, trackID string) (*models.VideoSupplement, error) {
params := map[string]string{
"track_id": trackID,
@@ -79,44 +78,43 @@ func (c *Client) GetVideoSupplement(ctx context.Context, trackID string) (*model
return &result, nil
}
// GetLyricsByTrackID is an alias for GetTrackLyrics for backward compatibility
// GET /tracks/{track_id}/lyrics
// GetLyricsByTrackID is an alias for GetTrackLyrics for backward compatibility (GET /tracks/{track_id}/lyrics).
func (c *Client) GetLyricsByTrackID(ctx context.Context, trackID string, format string) (*models.TrackLyrics, error) {
return c.GetTrackLyrics(ctx, trackID, format)
}
// LyricsFormat represents the lyrics format
// LyricsFormat represents the lyrics format.
type LyricsFormat string
const (
// LyricsFormatText is plain text format
// LyricsFormatText is plain text lyrics format.
LyricsFormatText LyricsFormat = "TEXT"
// LyricsFormatLRC is LRC format with timestamps
// LyricsFormatLRC is LRC format lyrics with timestamps.
LyricsFormatLRC LyricsFormat = "LRC"
)
// GetTrackLyricsWithOptions gets lyrics with options
// GetTrackLyricsWithOptions gets lyrics with options using a LyricsFormat value.
func (c *Client) GetTrackLyricsWithOptions(ctx context.Context, trackID string, format LyricsFormat) (*models.TrackLyrics, error) {
return c.GetTrackLyrics(ctx, trackID, string(format))
}
// SupplementOptions holds options for supplement requests
// SupplementOptions holds options for supplement requests.
type SupplementOptions struct {
TrackID string
}
// GetSupplement gets track supplement with options
// GetSupplement gets track supplement with options.
func (c *Client) GetSupplement(ctx context.Context, opts SupplementOptions) (*models.Supplement, error) {
return c.GetTrackSupplement(ctx, opts.TrackID)
}
// LyricsOptions holds options for lyrics requests
// LyricsOptions holds options for lyrics requests.
type LyricsOptions struct {
TrackID string
Format LyricsFormat
}
// GetLyricsWithOptions gets track lyrics with options
// GetLyricsWithOptions gets track lyrics with options.
func (c *Client) GetLyricsWithOptions(ctx context.Context, opts LyricsOptions) (*models.TrackLyrics, error) {
format := string(opts.Format)
if format == "" {
@@ -125,13 +123,14 @@ func (c *Client) GetLyricsWithOptions(ctx context.Context, opts LyricsOptions) (
return c.GetTrackLyrics(ctx, opts.TrackID, format)
}
// Sign represents a request signature
// Sign represents a request signature for signed API requests.
type Sign struct {
Timestamp int64
Value string
}
// GetSignRequest creates a signature for a track request (exported for external use)
// GetSignRequest creates a signature for a track request (exported for external use).
// It delegates to utils.GetSignRequest with the default signing key.
func GetSignRequest(trackID string) Sign {
h := utils.GetSignRequest(trackID, utils.DefaultSignKey)