Documentation
¶
Overview ¶
Package core 提供基础的核心功能
Index ¶
- Constants
- func FullVersion() string
- func Version() string
- type Block
- type Error
- func (err *Error) AddTypes(t ...ErrorType) *Error
- func (err *Error) Error() string
- func (err *Error) Is(target error) bool
- func (err *Error) Relate(loc Location, msg string) *Error
- func (err *Error) Unwrap() error
- func (err *Error) WithField(field string) *Error
- func (err *Error) WithLocation(loc Location) *Error
- type ErrorType
- type HTTPError
- type HandlerFunc
- type Location
- func (l Location) Contains(uri URI, pos Position) bool
- func (l Location) Equal(v Location) bool
- func (l Location) IsEmpty() bool
- func (l Location) Loc() Location
- func (l Location) NewError(key message.Reference, v ...interface{}) *Error
- func (l Location) String() string
- func (l Location) WithError(err error) *Error
- type Message
- type MessageHandler
- func (h *MessageHandler) Error(err interface{})
- func (h *MessageHandler) Info(err interface{})
- func (h *MessageHandler) Locale(t MessageType, key message.Reference, val ...interface{})
- func (h *MessageHandler) Message(t MessageType, msg interface{})
- func (h *MessageHandler) Stop()
- func (h *MessageHandler) Success(err interface{})
- func (h *MessageHandler) Warning(err interface{})
- type MessageType
- type Position
- type Range
- type RelatedInformation
- type Searcher
- type URI
- func (uri URI) Append(path string) URI
- func (uri URI) Exists() (bool, error)
- func (uri URI) File() (string, error)
- func (uri URI) Parse() (schema, path string)
- func (uri URI) ReadAll(enc encoding.Encoding) ([]byte, error)
- func (uri URI) String() string
- func (uri *URI) UnmarshalJSON(v []byte) error
- func (uri URI) WriteAll(data []byte) error
Constants ¶
const ( // Name 程序的正式名称 Name = "apidoc" // RepoURL 源码仓库地址 RepoURL = "https://github.com/caixw/apidoc" // OfficialURL 官网 OfficialURL = "https://apidoc.tools" // XMLNamespace 定义 xml 命名空间的 URI XMLNamespace = "https://apidoc.tools/v6/XMLSchema" )
const ( SchemeFile = "file" SchemeHTTP = "http" SchemeHTTPS = "https" )
目前 URI 支持的协议
Variables ¶
This section is empty.
Functions ¶
func FullVersion ¶
func FullVersion() string
FullVersion 完整的版本号
会包含版本号、构建日期和最后的提交 ID,大致格式如下:
version+buildDate.commitHash
func Version ¶
func Version() string
Version 程序的版本号
遵守 https://semver.org/lang/zh-CN/ 规则。 程序不兼容或是文档格式不兼容时,需要提升主版本号。
Types ¶
type Error ¶ added in v7.2.0
type Error struct { Err error // 具体的错误信息 Location Location // 错误的详细定位 Field string // 出错的字段 Types []ErrorType // 该错误的类型 Related []RelatedInformation // 与此错误关联的一些信息 }
Error 用于描述 apidoc 中的大部分错误信息
无论是配置文件的错误,还是文档的语法错误,都将返回此错误。
func (*Error) WithLocation ¶ added in v7.2.0
WithLocation 为语法错误添加定位信息
type Location ¶
Location 用于描述一段内容的定位
兼容 LSP https://microsoft.github.io/language-server-protocol/specifications/specification-current/#location
type MessageHandler ¶
type MessageHandler struct {
// contains filtered or unexported fields
}
MessageHandler 异步的消息处理机制
包含了本地化的信息,输出时,会以指定的本地化内容输出
func NewMessageHandler ¶
func NewMessageHandler(f HandlerFunc) *MessageHandler
NewMessageHandler 声明新的 MessageHandler 实例
func (*MessageHandler) Locale ¶
func (h *MessageHandler) Locale(t MessageType, key message.Reference, val ...interface{})
Locale 发送普通的文本信息
func (*MessageHandler) Message ¶
func (h *MessageHandler) Message(t MessageType, msg interface{})
Message 发送消息
type MessageType ¶
type MessageType int8
MessageType 表示消息的类型
const ( Erro MessageType = iota Warn Info Succ )
消息的分类
func (MessageType) String ¶
func (t MessageType) String() string
type Position ¶
type Position struct { Line int `json:"line" apidoc:"-"` Character int `json:"character" apidoc:"-"` }
Position 用于描述字符在文件中的定位
兼容 LSP https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position
type Range ¶
Range 用于描述文档中的一段范围
兼容 LSP https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range
type RelatedInformation ¶ added in v7.2.0
type RelatedInformation struct { Location Location `json:"location"` Message string `json:"message"` }
RelatedInformation 错误信息的关联内容
兼容 LSP 中的 DiagnosticRelatedInformation 的相关定义
https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#diagnostic
type URI ¶
type URI string
URI 定义 URI
http://tools.ietf.org/html/rfc3986
foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment | _____________________|__ / \ / \ urn:example:animal:ferret:nose
如果是本地相对路径,也可以直接使用 `./path/file` 的形式表示, 不需要指定协议。
NOTE: 并非完整的 URI 实现,仅作为了 file:// 和 http:// 支持, 也提供对 windows 路径的支持。
func (*URI) UnmarshalJSON ¶ added in v7.2.0
UnmarshalJSON 实现对非 ascii 字符的解码
Directories
¶
Path | Synopsis |
---|---|
Package messagetest 提供测试生成 message 相关的测试工具
|
Package messagetest 提供测试生成 message 相关的测试工具 |