lib

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PY2 is Python 2.x
	PY2 PyVer = 2
	// PY3 is Python 3.x
	PY3 PyVer = 3

	// HTMLBuilder HTML构建器
	HTMLBuilder BuilderType = "html"
	// DirHTMLBuilder 目录式HTML构建器
	DirHTMLBuilder BuilderType = "dirhtml"
	// SingleHTMLBuilder 单页HTML构建器
	SingleHTMLBuilder BuilderType = "singlehtml"
)

Variables

View Source
var (
	// GBPK 文档项目名称集合,set类型
	GBPK = "projects"
	// GBDK 所有自定义的域名集合,set类型
	GBDK = "domains"
)

数据 Key 命名: 1. 项目名称写入 GBPK,自定义域名写入 GBDK,类型均为set 2. 项目配置写入 BCK,类型为string,内容为json 3. 项目构建结果写入 BRK,类型为hash,键为branch/tag

Functions

func BCK

func BCK(projectName string) string

BCK 生成文档项目配置Key,string类型

func BRK

func BRK(projectName string) string

BRK 生成构建结果Key,hash类型

func OptionKeyMap added in v1.1.1

func OptionKeyMap(key string) string

OptionKeyMap 转换 Options 结构体字段名大小写

Types

type AccessToken added in v1.2.0

type AccessToken struct {
	Token string `json:"token"`
}

type AppWebhook added in v1.2.0

type AppWebhook struct {
	// Install / Uninstall (nonexistent app)
	// Suspend / Unsuspend (existing app)
	Action       string       `json:"action"`
	Installation Installation `json:"installation"`
	Repositories []Repository `json:"repositories"`
	// Add / Remove repo in an existing app
	Repositories_removed []Repository `json:"repositories_removed"`
	Repositories_added   []Repository `json:"repositories_added"`
}

GitHub App Post Webhook data

type BuilderType

type BuilderType string

BuilderType 构建器类型

type GHApp added in v1.2.0

type GHApp struct {
	AppId uint64
	// contains filtered or unexported fields
}

func NewGHApp added in v1.2.0

func NewGHApp(pm *ProjectManager) (gh *GHApp, err error)

func (*GHApp) BaseURL added in v1.2.0

func (gh *GHApp) BaseURL(url string)

func (*GHApp) Dispatch added in v1.2.0

func (gh *GHApp) Dispatch(w AppWebhook) (err error)

type Installation added in v1.2.0

type Installation struct {
	ID             uint64 `json:"id"`
	AppID          uint64 `json:"app_id"`
	AppName        string `json:"app_slug"`
	AccessTokenURL string `json:"access_tokens_url"`
}

Data structure after the user installs the github app

type Options

type Options struct {
	// 项目在数据库中唯一标识名
	Name string
	// git地址,可以是包含用户名密码的私有仓库
	URL URL
	// 默认显示的分支
	Latest string
	// 使用的python版本,2或3
	Version PyVer
	// 是否单一版本
	Single bool
	// 文档源文件路径
	SourceDir Path
	// 文档语言,以半角逗号分隔多种语言
	Lang string
	// 依赖包文件,以半角逗号分隔多个文件
	Requirement Path
	// 是否安装项目
	Install bool
	// pypi仓库
	Index URL
	// 是否显示导航
	ShowNav bool
	// 隐藏git
	HideGit bool
	// webhook secret
	Secret string
	// 默认域名
	DefaultDomain string
	// 自定义域名
	CustomDomain string
	// 自定义域名开启HTTPS(自动填充)
	SSL bool
	// 自定义域名的ssl公钥
	SSLPublic Path
	// 自定义域名的ssl私钥
	SSLPrivate Path
	// Sphinx构建器,支持html、dirhtml、singlehtml
	Builder BuilderType
	// git服务提供商(自动填充)
	GSP string
	// 是否为公开仓库(原type,自动填充)
	IsPublic bool
	// 构建前的钩子命令
	BeforeHook string
	// 构建成功后的钩子命令
	AfterHook string
	// 额外配置数据
	Meta map[string]string
}

Options 每个文档项目的配置项

func (Options) GetMeta added in v1.1.0

func (opt Options) GetMeta(key string) string

GetMeta 专门读取 Options 结构体 Meta 字段的值

func (Options) MustMeta added in v1.1.0

func (opt Options) MustMeta(key, defaultValue string) string

MustMeta 专门读取 Options 结构体 Meta 字段的值,可设置默认值

func (*Options) UpdateMeta added in v1.2.0

func (opt *Options) UpdateMeta(key, val string) error

UpdateMeta 专门更新 Meta 字段 (如果key以下划线开头表示系统数据)

func (Options) Writeback added in v1.2.0

func (opt Options) Writeback(pm *ProjectManager) error

Writeback 配置写入数据库

type OptionsWithResult

type OptionsWithResult struct {
	Options
	Buildset []Result
}

OptionsWithResult 嵌套了 Options 和 Result 两种结构

type Path

type Path = string

Path 文件或目录路径

type ProjectManager

type ProjectManager struct {
	// contains filtered or unexported fields
}

ProjectManager 项目管理器

func New

func New(path string) (pm *ProjectManager, err error)

New 新建项目管理器示例,path是rtfd配置文件

func (*ProjectManager) BuildRecord

func (pm *ProjectManager) BuildRecord(name string, branchOrTag string, result Result) error

BuildRecord 记录构建结果

func (*ProjectManager) CFG

func (pm *ProjectManager) CFG() *conf.Config

CFG 即config实例

func (*ProjectManager) Create

func (pm *ProjectManager) Create(name string, opt Options) error

Create 新建一个文档项目(唯一入口,必须通过GenerateOption方法生成选项)

func (*ProjectManager) DB

func (pm *ProjectManager) DB() *db.DB

DB 即db实例

func (*ProjectManager) GenerateOption

func (pm *ProjectManager) GenerateOption(name, url string) (opt Options, err error)

GenerateOption 创建一个通用的默认选项(不作参数的系统级别检测)

func (*ProjectManager) GetBuildset added in v1.3.2

func (pm *ProjectManager) GetBuildset(name, branch string) (builder Result, err error)

GetBuildset 获取某个构建结果

func (*ProjectManager) GetName

func (pm *ProjectManager) GetName(name string) (opt Options, err error)

GetName 查询名为 name 的文档项目数据(解析后)

func (*ProjectManager) GetNameOption

func (pm *ProjectManager) GetNameOption(name, key string) (val string, err error)

GetNameOption 获取文档项目某项配置值

func (*ProjectManager) GetNameWithBuildset added in v1.3.2

func (pm *ProjectManager) GetNameWithBuildset(name string) (ropt OptionsWithResult, err error)

GetNameWithBuildset 获取文档项目配置及其构建集详细数据

func (*ProjectManager) GetSourceName

func (pm *ProjectManager) GetSourceName(name string) (value []byte, err error)

GetSourceName 查询名为 name 的文档项目数据存储原数据(不经过解析,即JSON格式)

func (*ProjectManager) HasCustomDomain

func (pm *ProjectManager) HasCustomDomain(domain string) bool

HasCustomDomain 判断是否已有自定义域名

func (*ProjectManager) HasName

func (pm *ProjectManager) HasName(name string) bool

HasName 是否存在名为 name 的文档项目

func (*ProjectManager) ListBuildset added in v1.3.2

func (pm *ProjectManager) ListBuildset(name string) (builders []Result, err error)

ListBuildset 获取所有构建集

func (*ProjectManager) ListFullProject

func (pm *ProjectManager) ListFullProject() (members []Options, err error)

ListFullProject 获取所有项目及其配置选项

func (*ProjectManager) ListProject

func (pm *ProjectManager) ListProject() (members []string, err error)

ListProject 获取所有项目

func (*ProjectManager) Remove

func (pm *ProjectManager) Remove(name string) error

Remove 删除一个文档项目及其数据

func (*ProjectManager) SetOption

func (pm *ProjectManager) SetOption(opt *Options, key string, value interface{})

SetOption 按照 Options 参数更新key

func (*ProjectManager) Update

func (pm *ProjectManager) Update(opt *Options, rule map[string]interface{}) (ok []string, fail []string, err error)

Update 更新文档项目配置

type PyVer

type PyVer uint8

PyVer Python版本

type Repository added in v1.2.0

type Repository struct {
	Name     string `json:"name"`
	FullName string `json:"full_name"`
	ID       uint64 `json:"id"`
}

Repo name & id

type Result

type Result struct {
	// 触发构建的分支或标签
	Branch string
	// 构建结果 passing表示true 其他表示false
	Status bool
	// 发起构建的来源
	Sender vars.Sender
	// 构建完成时间(结束时)
	Btime string
	// 构建总花费时间(单位秒)
	Usedtime int
}

Result 构建结果

type URL

type URL = string

URL 包含协议头的地址

type UserWebhook added in v1.2.0

type UserWebhook struct {
	Type   string            `json:"type"`
	ID     uint64            `json:"id"`
	Name   string            `json:"name"`
	Active bool              `json:"active"`
	Events []string          `json:"events"`
	Config UserWebhookConfig `json:"config"`
}

type UserWebhookConfig added in v1.2.0

type UserWebhookConfig struct {
	URL         string `json:"url"`
	ContentType string `json:"content_type"`
	Secret      string `json:"secret"`
}

Jump to

Keyboard shortcuts

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