Documentation
¶
Index ¶
- func ExtractArchive(r io.Reader, filename, destDir string) error
- func ExtractTextFromHTML(filePath string) (title, text string, err error)
- func ExtractTextFromPDF(filePath string) (title string, text string, err error)
- func InjectOverlay(w http.ResponseWriter, r *http.Request, overlayHTML string, ...)
- func IsSemver(tag string) bool
- func ServeDoc(w http.ResponseWriter, r *http.Request, storagePath, filePath string)
- func SortVersionTags(tags []string)
- func WriteZipFromDir(w io.Writer, srcDir string) error
- type FilesystemStorage
- func (s *FilesystemStorage) BasePath() string
- func (s *FilesystemStorage) DeleteVersion(slug, tag string) error
- func (s *FilesystemStorage) EnsureProjectDir(slug string) error
- func (s *FilesystemStorage) EnsureVersionDir(slug, tag string) error
- func (s *FilesystemStorage) ProjectPath(slug string) string
- func (s *FilesystemStorage) VersionExists(slug, tag string) bool
- func (s *FilesystemStorage) VersionPath(slug, tag string) string
- type ReindexProgress
- type ReindexProgressFunc
- type ReindexProject
- type ReindexVersion
- type SearchIndex
- func (si *SearchIndex) Close() error
- func (si *SearchIndex) DeleteVersion(projectID, versionID int64) error
- func (si *SearchIndex) IndexVersion(projectID, versionID int64, ...) error
- func (si *SearchIndex) ReindexAll(projects []ReindexProject, versions []ReindexVersion) error
- func (si *SearchIndex) ReindexAllWithProgress(projects []ReindexProject, versions []ReindexVersion, ...) error
- func (si *SearchIndex) Search(sq SearchQuery, latestVersionTags map[string]string) (*SearchResults, error)
- type SearchQuery
- type SearchResult
- type SearchResults
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractArchive ¶
ExtractArchive detects the archive format from the filename and extracts to destDir.
func ExtractTextFromHTML ¶
ExtractTextFromHTML reads an HTML file and returns the page title and plain text content. It skips script, style, and nav elements.
func ExtractTextFromPDF ¶ added in v0.5.0
ExtractTextFromPDF extracts text from a PDF file for search indexing. Tries pdftotext (poppler-utils) first for best quality, falls back to ledongthuc/pdf (pure Go) if pdftotext is not installed.
func InjectOverlay ¶
func InjectOverlay(w http.ResponseWriter, r *http.Request, overlayHTML string, serve func(http.ResponseWriter, *http.Request))
InjectOverlay wraps an http.ResponseWriter to inject overlay HTML before </body> in HTML responses. Non-HTML responses are passed through unchanged.
func ServeDoc ¶
func ServeDoc(w http.ResponseWriter, r *http.Request, storagePath, filePath string)
ServeDoc serves a documentation file from the storage path. If the path points to a directory, it serves index.html from that directory.
func SortVersionTags ¶
func SortVersionTags(tags []string)
SortVersionTags sorts version tags in descending semver order. Tags that match semver come first; non-semver tags are sorted lexicographically at the end.
Types ¶
type FilesystemStorage ¶
type FilesystemStorage struct {
// contains filtered or unexported fields
}
func NewFilesystemStorage ¶
func NewFilesystemStorage(basePath string) *FilesystemStorage
func (*FilesystemStorage) BasePath ¶
func (s *FilesystemStorage) BasePath() string
func (*FilesystemStorage) DeleteVersion ¶
func (s *FilesystemStorage) DeleteVersion(slug, tag string) error
func (*FilesystemStorage) EnsureProjectDir ¶
func (s *FilesystemStorage) EnsureProjectDir(slug string) error
func (*FilesystemStorage) EnsureVersionDir ¶
func (s *FilesystemStorage) EnsureVersionDir(slug, tag string) error
func (*FilesystemStorage) ProjectPath ¶
func (s *FilesystemStorage) ProjectPath(slug string) string
func (*FilesystemStorage) VersionExists ¶
func (s *FilesystemStorage) VersionExists(slug, tag string) bool
func (*FilesystemStorage) VersionPath ¶
func (s *FilesystemStorage) VersionPath(slug, tag string) string
type ReindexProgress ¶
ReindexProgress reports reindexing progress.
type ReindexProgressFunc ¶
type ReindexProgressFunc func(progress ReindexProgress)
ReindexProgressFunc is called for each version during reindexing.
type ReindexProject ¶
ReindexProject holds project data for reindexing.
type ReindexVersion ¶
ReindexVersion holds version data for reindexing.
type SearchIndex ¶
type SearchIndex struct {
// contains filtered or unexported fields
}
SearchIndex wraps a bleve index for full-text search of documentation content.
func NewSearchIndex ¶
func NewSearchIndex(basePath string) (*SearchIndex, error)
NewSearchIndex opens or creates a bleve index at the given path.
func (*SearchIndex) DeleteVersion ¶
func (si *SearchIndex) DeleteVersion(projectID, versionID int64) error
DeleteVersion removes all indexed documents for a given version.
func (*SearchIndex) IndexVersion ¶
func (si *SearchIndex) IndexVersion(projectID, versionID int64, projectSlug, projectName, versionTag, storagePath string) error
IndexVersion walks HTML files in a version's storage path and indexes them.
func (*SearchIndex) ReindexAll ¶
func (si *SearchIndex) ReindexAll(projects []ReindexProject, versions []ReindexVersion) error
ReindexAll rebuilds the entire search index from scratch.
func (*SearchIndex) ReindexAllWithProgress ¶
func (si *SearchIndex) ReindexAllWithProgress(projects []ReindexProject, versions []ReindexVersion, progressFn ReindexProgressFunc) error
ReindexAllWithProgress rebuilds the index with progress reporting.
func (*SearchIndex) Search ¶
func (si *SearchIndex) Search(sq SearchQuery, latestVersionTags map[string]string) (*SearchResults, error)
Search performs a full-text search across indexed documentation.
type SearchQuery ¶
type SearchQuery struct {
Query string
ProjectSlug string // empty = all projects
VersionTag string // empty = latest only (unless AllVersions)
AllVersions bool
Limit int
Offset int
}
SearchQuery describes a full-text search request.
type SearchResult ¶
type SearchResult struct {
ProjectSlug string `json:"project_slug"`
ProjectName string `json:"project_name"`
VersionTag string `json:"version_tag"`
FilePath string `json:"file_path"`
PageTitle string `json:"page_title"`
Snippet string `json:"snippet"`
URL string `json:"url"`
}
SearchResult is a single search hit.
type SearchResults ¶
type SearchResults struct {
Results []SearchResult `json:"results"`
Total uint64 `json:"total"`
}
SearchResults contains paged search results.