docs

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractArchive

func ExtractArchive(r io.Reader, filename, destDir string) error

ExtractArchive detects the archive format from the filename and extracts to destDir.

func ExtractTextFromHTML

func ExtractTextFromHTML(filePath string) (title, text string, err error)

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

func ExtractTextFromPDF(filePath string) (title string, text string, err error)

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 IsSemver added in v0.3.0

func IsSemver(tag string) bool

IsSemver returns true if the given tag matches the semver pattern.

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.

func WriteZipFromDir added in v0.4.0

func WriteZipFromDir(w io.Writer, srcDir string) error

WriteZipFromDir walks srcDir and streams its contents as a zip archive to w. Paths inside the zip are relative to srcDir, using forward slashes. Symlinks, directories, and non-regular files are skipped.

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

type ReindexProgress struct {
	Current int
	Total   int
	Project string
	Version string
}

ReindexProgress reports reindexing progress.

type ReindexProgressFunc

type ReindexProgressFunc func(progress ReindexProgress)

ReindexProgressFunc is called for each version during reindexing.

type ReindexProject

type ReindexProject struct {
	ID   int64
	Slug string
	Name string
}

ReindexProject holds project data for reindexing.

type ReindexVersion

type ReindexVersion struct {
	ID          int64
	ProjectID   int64
	Tag         string
	StoragePath string
}

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) Close

func (si *SearchIndex) Close() error

Close closes the bleve index.

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.

type Storage

type Storage interface {
	BasePath() string
	ProjectPath(slug string) string
	VersionPath(slug, tag string) string
	EnsureProjectDir(slug string) error
	EnsureVersionDir(slug, tag string) error
	VersionExists(slug, tag string) bool
	DeleteVersion(slug, tag string) error
}

Directories

Path Synopsis
Package builtin provides embedded documentation that can be deployed as a regular project.
Package builtin provides embedded documentation that can be deployed as a regular project.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL