Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions internal/app/godoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func ReadGoDocPaged(

// If no documentation found, try to parse the README section
if !matched {
_, parsedDoc = parseReadme(doc)
matched, parsedDoc = parseReadme(doc)
}

// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask pkg.go.dev markup drift.
if !matched || strings.TrimSpace(parsedDoc) == "" {
return "", 0, false, ErrNotFound
}

document = parsedDoc
Expand Down Expand Up @@ -178,7 +184,13 @@ func SearchWithinGoDoc(

// If no documentation found, try to parse the README section
if !matched {
_, parsedDoc = parseReadme(doc)
matched, parsedDoc = parseReadme(doc)
}

// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask pkg.go.dev markup drift.
if !matched || strings.TrimSpace(parsedDoc) == "" {
return nil, ErrNotFound
}

document = parsedDoc
Expand Down
16 changes: 14 additions & 2 deletions internal/app/pydoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func ReadPyDocPaged(
return "", 0, false, errors.Wrap(err, "failed to parse HTML")
}

_, document = parsePyDocPage(doc)
matched, parsed := parsePyDocPage(doc)
// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask docs.python.org markup drift.
if !matched || strings.TrimSpace(parsed) == "" {
return "", 0, false, ErrNotFound
}
document = parsed

docCache.Set(cacheKey, document, cache.DefaultExpiration)
}
Expand Down Expand Up @@ -161,7 +167,13 @@ func SearchWithinPyDoc(
return nil, errors.Wrap(err, "failed to parse HTML")
}

_, document = parsePyDocPage(doc)
matched, parsed := parsePyDocPage(doc)
// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask docs.python.org markup drift.
if !matched || strings.TrimSpace(parsed) == "" {
return nil, ErrNotFound
}
document = parsed

docCache.Set(cacheKey, document, cache.DefaultExpiration)
}
Expand Down
16 changes: 14 additions & 2 deletions internal/app/rustdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ func ReadRustDocPaged(
return "", 0, false, errors.Wrap(err, "failed to parse HTML")
}

_, document = parseDocsRsDocument(doc)
matched, parsed := parseDocsRsDocument(doc)
// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask docs.rs markup drift.
if !matched || strings.TrimSpace(parsed) == "" {
return "", 0, false, ErrNotFound
}
document = parsed

docCache.Set(cacheKey, document, cache.DefaultExpiration)
}
Expand Down Expand Up @@ -129,7 +135,13 @@ func SearchWithinRustDoc(
return nil, errors.Wrap(err, "failed to parse HTML")
}

_, document = parseDocsRsDocument(doc)
matched, parsed := parseDocsRsDocument(doc)
// Nothing parsed: treat as not found instead of caching and returning
// an empty document, which would mask docs.rs markup drift.
if !matched || strings.TrimSpace(parsed) == "" {
return nil, ErrNotFound
}
document = parsed

docCache.Set(cacheKey, document, cache.DefaultExpiration)
}
Expand Down
Loading