Package internal/docs¶
Import path: go.devnw.com/canary/internal/docs
package docs // import "go.devnw.com/canary/internal/docs"
API (raw go doc)¶
package docs // import "go.devnw.com/canary/internal/docs"
FUNCTIONS
func CalculateFullHash(filePath string) (string, error)
CalculateFullHash returns full 64-character SHA256 hash. Use this for
database storage if full hash precision is needed.
func CalculateHash(filePath string) (string, error)
CalculateHash computes SHA256 hash of documentation file with line ending
normalization. Returns first 16 characters (64 bits) for abbreviated display
in CANARY tokens.
Line endings are normalized to LF (\n) before hashing to ensure
cross-platform consistency between Windows (CRLF) and Unix/Mac (LF) systems.
Example:
hash, err := docs.CalculateHash("docs/user/auth.md")
// Returns: "8f434346648f6b96" (first 16 chars of SHA256)
func CheckMultipleDocumentation(token *storage.Token) (map[string]string, error)
CheckMultipleDocumentation handles tokens with multiple DOC paths
(comma-separated). Returns a map of doc path to status for each
documentation file.
Example:
// Token with: DOC=user:docs/user.md,api:docs/api.md
results, err := docs.CheckMultipleDocumentation(token)
// Returns: {"docs/user.md": "DOC_CURRENT", "docs/api.md": "DOC_STALE"}
func CheckStaleness(token *storage.Token) (string, error)
CheckStaleness compares documentation file hash to token DOC_HASH field.
Returns one of: DOC_CURRENT, DOC_STALE, DOC_MISSING, or DOC_UNHASHED
Status meanings:
- DOC_CURRENT: File hash matches token DOC_HASH (documentation is
up-to-date)
- DOC_STALE: File hash differs from token DOC_HASH (documentation needs
updating)
- DOC_MISSING: Documentation file does not exist at specified path
- DOC_UNHASHED: Token has no DOC_HASH field (hash tracking not enabled)
Example:
status, err := docs.CheckStaleness(token)
if status == "DOC_STALE" {
fmt.Printf("Documentation for %s is outdated\n", token.ReqID)
}