Documentation ¶
Overview ¶
Package node 处理 ast 中各个节点的结构信息
struct tag
标签属性分为 4 个字段,其中前三个是必填的:
apidoc:"name,node-type,usage-key,omitempty"
name 表示当前标签的名称,或是节点表示的类型; node-type 表示当前节点的类型,可以是以下值:
- elem 表示这是一个子元素;
- attr 表示为一个 XML 属性;
- cdata 表示为 CDATA 数据;
- content 表示为普通的字符串值;
- meta 表示这个字段仅用于描述当前元素的元数据,比如元素的名称等;
usage-key 指定了当前元素的翻译项; omitempty 表示当前值为空时,是否可以忽略。
Index ¶
Constants ¶
View Source
const TagName = "apidoc"
TagName 结构体标签的名称
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node struct { Attributes []*Value // 当前标签的属性值列表 Elements []*Value // 当前标签的元素列表 CData, Content *Value // 当前标签如果没有子元素,则可能有普通的内容或是 CDATA 内容 Value Value // 当前节点本身代表的值 TypeName string // 当前节点的类型名称 }
Node 表示一个 XML 标签节点
type Value ¶
type Value struct { reflect.Value Omitempty bool Name string // 节点的名称 // 当前值可能未初始化,所以保存 usage 的值, // 等 Value 初始化之后再赋值给 Base.UsageKey Usage string }
Value 表示 XML 节点的值的反射表示方式
func ParseValue ¶
ParseValue 分析 v 并返回 *Value 实例
与 NewValue 的不同在于,ParseValue 会分析对象字段中是否带有 meta 的结构体标签, 如果有才初始化 *Value 对象,否则返回 nil。
Click to show internal directories.
Click to hide internal directories.