This commit is contained in:
Tomas Dvorak
2026-02-24 10:33:59 +01:00
parent 409acd2e08
commit 898a3c303f
1374 changed files with 290409 additions and 29187 deletions
+27 -12
View File
@@ -155,16 +155,18 @@ func (s *TSDocsScraper) interfaceToDocument(iface *tsdocs.Interface, module *tsd
metadata := map[string]interface{}{
"module": module.Name,
"name": iface.Name,
"doc_url": iface.DocURL,
"doc_url": coalesceDocURL(iface.DocURL, module.DocURL),
}
docURL := coalesceDocURL(iface.DocURL, module.DocURL)
return &Document{
ID: generateDocID(iface.DocURL),
ID: generateDocID(docURL),
Source: sourceName,
Type: "ts-interface",
Title: iface.Name,
Content: content.String(),
URL: iface.DocURL,
URL: docURL,
Metadata: metadata,
Hash: s.generateHash(content.String()),
Timestamp: time.Now(),
@@ -185,16 +187,18 @@ func (s *TSDocsScraper) functionToDocument(fn *tsdocs.Function, module *tsdocs.M
"module": module.Name,
"name": fn.Name,
"return_type": fn.ReturnType,
"doc_url": fn.DocURL,
"doc_url": coalesceDocURL(fn.DocURL, module.DocURL),
}
docURL := coalesceDocURL(fn.DocURL, module.DocURL)
return &Document{
ID: generateDocID(fn.DocURL),
ID: generateDocID(docURL),
Source: sourceName,
Type: "ts-function",
Title: fn.Name,
Content: content.String(),
URL: fn.DocURL,
URL: docURL,
Metadata: metadata,
Hash: s.generateHash(content.String()),
Timestamp: time.Now(),
@@ -217,16 +221,18 @@ func (s *TSDocsScraper) classToDocument(class *tsdocs.Class, module *tsdocs.Modu
metadata := map[string]interface{}{
"module": module.Name,
"name": class.Name,
"doc_url": class.DocURL,
"doc_url": coalesceDocURL(class.DocURL, module.DocURL),
}
docURL := coalesceDocURL(class.DocURL, module.DocURL)
return &Document{
ID: generateDocID(class.DocURL),
ID: generateDocID(docURL),
Source: sourceName,
Type: "ts-class",
Title: class.Name,
Content: content.String(),
URL: class.DocURL,
URL: docURL,
Metadata: metadata,
Hash: s.generateHash(content.String()),
Timestamp: time.Now(),
@@ -244,18 +250,27 @@ func (s *TSDocsScraper) typeAliasToDocument(ta *tsdocs.TypeAlias, module *tsdocs
metadata := map[string]interface{}{
"module": module.Name,
"name": ta.Name,
"doc_url": ta.DocURL,
"doc_url": coalesceDocURL(ta.DocURL, module.DocURL),
}
docURL := coalesceDocURL(ta.DocURL, module.DocURL)
return &Document{
ID: generateDocID(ta.DocURL),
ID: generateDocID(docURL),
Source: sourceName,
Type: "ts-type",
Title: ta.Name,
Content: content.String(),
URL: ta.DocURL,
URL: docURL,
Metadata: metadata,
Hash: s.generateHash(content.String()),
Timestamp: time.Now(),
}
}
func coalesceDocURL(primary, fallback string) string {
if strings.TrimSpace(primary) != "" {
return primary
}
return fallback
}