Documentation
¶
Overview ¶
Package fielddocs 从 manifest 的 schema 源码中提取字段说明,供 ofd-creator schema 生成字段参考文档,也供生成器产出 fielddocs.go。
说明文本只存在于 Go 源码的文档注释里,构建产物读不到源码,因此由 gen-fielddocs 在构建期提取成代码。提取以 Manifest 为根递归,只覆盖 manifest 的输入结构,BuildOptions 这类辅助类型不会混入。
manifest 的字段路径构成一棵树,而结构体构成一张 DAG:复合对象可以嵌套复合 对象,同一个 Item 会在几十条路径下出现。按路径逐个展开会让字段数组合爆炸, 因此这里按结构体组织,每个结构体只在首次到达处展开一次,并在 TypeDoc.Path 记录到达它的示例路径。
Index ¶
Constants ¶
View Source
const RootStruct = "Manifest"
RootStruct 是 manifest schema 的根结构体名。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct {
// Name 是相对所属结构体的键名,也是 manifest 里的字段名。
Name string
// Type 是该字段的 Go 类型,数组和指针保留书写形式。
Type string
// Doc 是去掉字段名前缀后的说明文本。
Doc string
// Optional 表示该字段的 json tag 带 omitempty,未设置时为零值即不输出。
Optional bool
}
Field 是一条 manifest 字段的参考信息。
type Schema ¶
type Schema struct {
// Root 是根结构体名。
Root string
// Types 是全部结构体说明。
Types []TypeDoc
// Recursive 列出被多处引用的结构体名,它们只展开一次。
Recursive []string
}
Schema 是提取出的 manifest 结构体集合,按首次到达顺序排列。
type TypeDoc ¶
type TypeDoc struct {
// Name 是 Go 结构体名,例如 Item。
Name string
// Doc 是结构体自身的说明。
Doc string
// Path 是从 manifest 根首次到达该结构体的路径,根结构体为空串,例如
// pages[].items[].fill_color.radial。字段的完整路径是在本路径后追加字段名,
// 结构体字段还要追加 "[]"(如 pages[].items[])。
Path string
// Fields 是该结构体的直接字段。
Fields []Field
}
TypeDoc 是 manifest 里一个结构体的字段说明。
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
gen-fielddocs
command
gen-fielddocs 读取 internal/manifest/manifest.go 的字段注释,生成 internal/manifest/fielddocs.go。
|
gen-fielddocs 读取 internal/manifest/manifest.go 的字段注释,生成 internal/manifest/fielddocs.go。 |
Click to show internal directories.
Click to hide internal directories.