Documentation
¶
Overview ¶
Package export 将 OFD 文档导出为 ofd-creator 可读取的 manifest。
Index ¶
- func BuildManifest(input any, index int, options Options) (manifest.Manifest, error)
- func BuildManifestFromOFD(ofd *parser.OFD, index int, options Options) (manifest.Manifest, error)
- func WriteBundle(input any, outputDir string, options Options) error
- func WriteDocumentManifest(input any, index int, output io.Writer, options Options) error
- func WriteManifest(input any, output io.Writer, options Options) error
- type BundleDocument
- type BundleIndex
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildManifest ¶ added in v0.1.3
BuildManifest 将指定文档体导出为 manifest 结构,并把二进制资源交给 Options.AssetSink(或写入 AssetRoot)。用于在内存中继续合并或转换。
func BuildManifestFromOFD ¶ added in v0.1.3
BuildManifestFromOFD 与 BuildManifest 相同,但复用已打开的解析器。
func WriteBundle ¶ added in v0.1.2
WriteBundle 将 OFD 的全部文档体写入一个目录包。 每个文档体拥有独立的 manifest 和资源目录,根目录下同时写入索引文件。
func WriteDocumentManifest ¶ added in v0.1.2
WriteDocumentManifest 将指定索引的文档体写入 manifest。 index 从 0 开始;该 API 用于 OFD 包含多个文档体时选择其中一个文档。
Types ¶
type BundleDocument ¶
type BundleDocument struct {
Index int `json:"index" yaml:"index"`
ID string `json:"id" yaml:"id"`
Title string `json:"title" yaml:"title"`
Manifest string `json:"manifest" yaml:"manifest"`
AssetRoot string `json:"asset_root" yaml:"asset_root"`
Pages int `json:"pages" yaml:"pages"`
}
BundleDocument 标识导出目录包中的一个文档 manifest。
type BundleIndex ¶
type BundleIndex struct {
Version int `json:"version" yaml:"version"`
Documents []BundleDocument `json:"documents" yaml:"documents"`
}
BundleIndex 描述 WriteBundle 生成的 manifest 集合。
type Options ¶
type Options struct {
// AssetRoot 是导出二进制资源的实际目录。
AssetRoot string
// AssetPrefix 是 manifest 中相对于 manifest 文件的资源目录前缀。
AssetPrefix string
// Format 是 manifest 输出格式,可选 yaml、json 或 toml。
Format string
// JSONIndent 控制 JSON 输出是否使用 2 空格缩进。
JSONIndent bool
// AssetSink 可选,接收导出过程中产生的二进制资源(name 为资源相对路径)。
// 设置后不再写入 AssetRoot,AssetRoot 可以为空。
AssetSink func(name string, data []byte) error
}
Options 控制 OFD manifest 导出。
Click to show internal directories.
Click to hide internal directories.