docs

package
v2.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathMaxLen   = 512
	BodyMaxBytes = 200 * 1024
	TagMax       = 8
	TagItemMax   = 24
	DocsPerWFMax = 500
	// DocsPerProjectMax 是项目范围列表一次最多取多少篇(设计稿 06 §3.3:每项目 2000)。
	DocsPerProjectMax = 2000
	ImportMaxFiles    = 100
	ImportMaxBytes    = 2 * 1024 * 1024
	RevisionKeep      = 50
)

Variables

This section is empty.

Functions

func AppendDecisionResultsTable

func AppendDecisionResultsTable(content string, rows []DecisionExportRow) string

AppendDecisionResultsTable 在 Markdown 末尾追加决策结果表。

func AppendToBody

func AppendToBody(body, chunk string) string

AppendToBody 在正文末尾追加内容(保证中间有空行)。

func BodyHash

func BodyHash(body string) string

BodyHash 计算正文 SHA-256 十六进制摘要。

func BuildIndexMarkdown

func BuildIndexMarkdown(workflowID string, entries []ExportEntry) string

BuildIndexMarkdown 生成 INDEX.md 内容。

func CountBlueprintGaps

func CountBlueprintGaps(items []BlueprintItem) int

CountBlueprintGaps 返回缺口数量。

func ExtractLinks(fromPath, body string) []string

ExtractLinks 从正文里取出指向其他文档的链接目标(已规范化为 .md 路径)。 识别 [path] / [[path|显示名]] / [[path#锚点]],以及 [文字](相对路径.md); 带协议的外链、纯锚点、绝对路径、Artifact 引用([[artifact:N]])都跳过。 fromPath 是当前文档路径,用来解析 ./ 和 ../ 开头的相对链接;结果去重并保持出现顺序。

func ExtractTitle

func ExtractTitle(body, fileName string) string

ExtractTitle 取第一个 H1,否则用文件名(不含 .md)。

func GetSection

func GetSection(body, section string) (string, bool)

GetSection 按标题文本或锚点取一节(从该标题到同级或更高级标题之前)。

func NormalizePath

func NormalizePath(raw string) (string, error)

NormalizePath 规范化文档路径:去首尾空白、反斜杠转正斜杠、无扩展名补 .md。 不通过校验时返回 error。

func ParentPrefix

func ParentPrefix(parent, child string) bool

ParentPrefix 若 prefix 是 parent 的前缀(按路径段),返回 true。

func PathBaseName

func PathBaseName(p string) string

PathBaseName 返回不带 .md 的文件名。

func PathDir

func PathDir(p string) string

PathDir 返回路径的目录部分(不含末尾斜杠);根文档返回 ""。

func PrependToBody

func PrependToBody(body, chunk string) string

PrependToBody 在正文开头插入内容。

func ReplaceSection

func ReplaceSection(body, section, newSection string) (string, error)

ReplaceSection 替换一节;找不到标题时返回 error。

func ScoreDocument

func ScoreDocument(q, path, title, body string, tags []string) (float64, string, string)

ScoreDocument 对单篇文档打分(q 已在调用方 trim 并小写)。

func UniqueDecisionIDs

func UniqueDecisionIDs(decisions []ParsedDecision) []string

UniqueDecisionIDs 检查文档内 decision id 是否唯一;返回重复的 id。

Types

type BlueprintItem

type BlueprintItem struct {
	Path          string `json:"path"`
	Title         string `json:"title"`
	Hint          string `json:"hint"`
	Present       bool   `json:"present"`
	SuggestedKind string `json:"suggested_kind,omitempty"`
	Template      string `json:"template,omitempty"`
}

BlueprintItem 是推荐文档结构里的一项。

func Blueprint

func Blueprint(existingPaths map[string]bool, withTemplates bool) []BlueprintItem

Blueprint 对照已有路径指出缺口。

func ProjectBlueprint

func ProjectBlueprint(existingPaths map[string]bool, modulePaths []string, withTemplates bool) []BlueprintItem

ProjectBlueprint 给出项目知识库的推荐结构与缺口(设计稿 06 §4):固定的几篇总览类文档,加上每个已建模块的总述与设计。

type DecisionCard

type DecisionCard struct {
	ID      string           `json:"id"`
	Title   string           `json:"title"`
	Body    string           `json:"body,omitempty"`
	Options []DecisionOption `json:"options"`
	Default string           `json:"default"`
	Multi   bool             `json:"multi,omitempty"`
	Note    bool             `json:"note,omitempty"`
	Risk    string           `json:"risk,omitempty"`
}

DecisionCard 是 ```decision 围栏内的结构化决策(本批只解析与展示,作答在第二波)。

type DecisionExportRow

type DecisionExportRow struct {
	ID     string
	Title  string
	Status string
	Ref    string
	Result string
}

DecisionExportRow 供导出表使用的决策结果行。

type DecisionOption

type DecisionOption struct {
	ID          string `json:"id"`
	Label       string `json:"label"`
	Detail      string `json:"detail,omitempty"`
	Recommended bool   `json:"recommended,omitempty"`
}

DecisionOption 是决策卡里的一个选项。

type ExportEntry

type ExportEntry struct {
	Path    string `json:"path"`
	Title   string `json:"title"`
	Kind    string `json:"kind"`
	Status  string `json:"status"`
	Rev     int    `json:"rev"`
	Hash    string `json:"hash"`
	Updated string `json:"updated_at"`
}

ExportEntry 是导出清单里的一篇文档。

type Heading

type Heading struct {
	Level  int    `json:"level"`
	Text   string `json:"text"`
	Anchor string `json:"anchor"`
	Line   int    `json:"line"` // 1-based
}

Heading 是正文里的一级~六级标题(围栏代码块内的 # 不算)。

func ParseHeadings

func ParseHeadings(body string) []Heading

ParseHeadings 解析 Markdown 标题并生成锚点(中文友好 slug,同名加序号)。

type ParsedDecision

type ParsedDecision struct {
	Card       DecisionCard `json:"card"`
	StartLine  int          `json:"start_line"`
	EndLine    int          `json:"end_line"`
	RawJSON    string       `json:"-"`
	Errors     []string     `json:"errors,omitempty"`
	Status     string       `json:"status"` // 本批恒为 pending
	StatusNote string       `json:"status_note,omitempty"`
}

ParsedDecision 带围栏位置与校验结果。

func ParseDecisions

func ParseDecisions(body string) []ParsedDecision

ParseDecisions 扫描正文中的 decision 围栏并校验 JSON。

type SearchHit

type SearchHit struct {
	Path    string  `json:"path"`
	Title   string  `json:"title"`
	Score   float64 `json:"score"`
	Snippet string  `json:"snippet"`
	Anchor  string  `json:"anchor,omitempty"`
}

SearchHit 是一条搜索命中。

Jump to

Keyboard shortcuts

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