productdocs

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package productdocs indexes the WeKnora documentation bundled with the server, so the built-in assistant can answer how the product works from the docs of the running version.

Index

Constants

View Source
const PublicBaseURL = "https://weknora.weixin.qq.com/docs/"

PublicBaseURL is where the documentation site serves these pages.

Variables

View Source
var Categories = []Category{
	{Dir: "01-getting-started", Label: "快速开始"},
	{Dir: "02-architecture", Label: "架构"},
	{Dir: "03-features", Label: "功能模块"},
	{Dir: "04-api", Label: "API 参考"},
	{Dir: "05-clients", Label: "客户端"},
	{Dir: "06-development", Label: "开发指南"},
	{Dir: "07-releases", Label: "版本发布"},
}

Categories are the documentation's sidebar groups, in site order. They mirror the sections list in website-docs/.vitepress/config.mts.

Functions

func Render

func Render(sections []*Section) string

Render joins sections back into Markdown with their headings.

func UnescapeAnchor

func UnescapeAnchor(anchor string) string

UnescapeAnchor decodes a percent-encoded anchor, leaving one that is not valid encoding as given.

Types

type Category

type Category struct {
	Dir   string
	Label string
}

Category is one sidebar group.

type Doc

type Doc struct {
	Path     string // "03-features/14-wiki", the page's path under the site
	Category string // Sidebar group, e.g. "功能模块"
	Title    string
	Sections []*Section // In page order; the first is the text before any "##"
}

Doc is one documentation page.

func (*Doc) Span

func (d *Doc) Span(anchor string) ([]*Section, bool)

Span returns the section at anchor followed by its subsections; "" is the whole page.

func (*Doc) URL

func (d *Doc) URL() string

URL is the page's public address.

type Hit

type Hit struct {
	Section *Section
	Score   float64
	Snippet string
}

Hit is one search result.

type Library

type Library struct {
	// contains filtered or unexported fields
}

Library is a loaded, searchable set of pages.

func Default

func Default() (*Library, error)

Default returns the library built from the pages embedded in the binary. As with Load, a non-nil library may come with an error naming the pages left out.

func Load

func Load(fsys fs.FS) (*Library, error)

Load parses every category's pages in fsys. A page that cannot be read or parsed is left out and reported in the error, alongside a library of the remaining pages, so one broken page does not take the others with it.

func (*Library) Doc

func (l *Library) Doc(ref string) (*Doc, string, bool)

Doc resolves a page by its path, file name or public URL.

func (*Library) Docs

func (l *Library) Docs(category string) []*Doc

Docs lists the pages of category (a Dir or Label), or all pages when empty.

func (*Library) Search

func (l *Library) Search(query, category string, limit int) []Hit

Search ranks sections for query, optionally within one category.

type Section

type Section struct {
	Doc     *Doc
	Anchor  string // "" for the page's lead section
	Heading string
	Level   int      // 1 for the lead section, then 2 to maxSectionLevel
	Parents []string // Headings of the enclosing sections, outermost first
	Content string   // Cleaned Markdown shown to the model
	// contains filtered or unexported fields
}

Section is the text under one heading of level 2 to maxSectionLevel, up to the next such heading.

func (*Section) Trail

func (s *Section) Trail() string

Trail is the heading path shown in search results.

func (*Section) URL

func (s *Section) URL() string

URL is the section's public address.

Jump to

Keyboard shortcuts

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