doci18n

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotExist = iota
	Copied
	Overwrited
	NotUpdated
	Failed
)

Result code of copy content

View Source
const DevVersion = "Dev version"
View Source
const ExampleConfig = `` /* 275-byte string literal not displayed */

ExampleConfig is the config used within hugo-docs-i18n init.

View Source
const ReleaseVersion = "Release version"
View Source
const VersionFile = "version.json"

Variables

This section is empty.

Functions

func AddContentFile added in v0.3.0

func AddContentFile(p string, r int) error

Add CopyFile to LogJSON

func AddNotContentFile added in v0.3.0

func AddNotContentFile(p string, r int) error

func CanSetVersionInfo added in v0.3.2

func CanSetVersionInfo() bool

Can Set Version Info

func CopyContentFile

func CopyContentFile(infn, outfn string) (bool, error)

copy not-draft file from <infn> to <outfn>, with setting which draft = true for translation.

func CopyNotContentFile

func CopyNotContentFile(infn, outfn string) (bool, error)

Copy not-content file, including CSS, jpeg, etc.

func CountDraftFile

func CountDraftFile(dir string) (PathJSON, CountDraft, error)

Walk directory, while checking if the file is draft or not?

func GetCurrentString added in v0.3.0

func GetCurrentString() string

Get Now() string

func GetLogFileName added in v0.3.0

func GetLogFileName() string

Get Log file name

func GetSemver added in v0.3.1

func GetSemver() string

Load VersionInfo data from JSON

func GetVermsg added in v0.3.1

func GetVermsg() string

func GetVersionInfo added in v0.3.2

func GetVersionInfo() error

Load VersionInfo data from JSON

func IncMajor added in v0.3.1

func IncMajor() error

Inc SemVer Info

func IncMinor added in v0.3.1

func IncMinor() error

func IncPatch added in v0.3.1

func IncPatch() error

func InitLogJSON added in v0.3.0

func InitLogJSON(dt, sd, dd string)

Initialize LogJSON

func InitVersionInfo added in v0.3.2

func InitVersionInfo()

Initialize Version Info

func IsDir

func IsDir(filename string) bool

Is directory?

func IsDraftFile

func IsDraftFile(infn string) (bool, string, error)

return if the file is draft or not.

func IsEmpty

func IsEmpty(filename string) bool

File is empty?

func IsExist

func IsExist(filename string) bool

File is exist?

func IsRegularFile

func IsRegularFile(filename string) bool

Is regular file?

func LoadVersionInfo added in v0.3.1

func LoadVersionInfo() error

Load VersionInfo data from JSON

func ReadContentFile

func ReadContentFile(infn string) (pageparser.ContentFrontMatter, error)

Read content file, return FrontMatter and Content

func SafeMkdir

func SafeMkdir(path string) error

Mkdir if the directory dose not exist

func SaveConfigFile

func SaveConfigFile(outfn string) error

Save config data to YAML file

func SaveCountJSONFile

func SaveCountJSONFile(outfn string, pj PathJSON, cd CountDraft) error

Save JSON data to file

func SaveLogJSON added in v0.3.0

func SaveLogJSON(outfn string) error

Save JSON data to file

func SaveVersionInfo added in v0.3.1

func SaveVersionInfo() error

Save JSON data to file

func SetMetabuild added in v0.3.1

func SetMetabuild(m string) error

func SetPrerelease added in v0.3.1

func SetPrerelease(m string) error

func SetSemver added in v0.3.1

func SetSemver(str string) error

func SetVermsg added in v0.3.1

func SetVermsg(str string)

func WalkDir

func WalkDir(dir string) ([]string, error)

WalkDir() traverse directory tree

func WalkDir2

func WalkDir2(dir string, walkDirFunc func(path string, d fs.DirEntry) error) ([]string, error)

WalkDir2() traverse directory tree with walkDirFunc()

func WalkDir3

func WalkDir3(srcdir, dstdir string, walkDirFunc func(srcpath, dstpath string, d fs.DirEntry) error) error

WalkDir3() traverse src directory tree with walkDirFunc()

Types

type CopyFile added in v0.3.0

type CopyFile struct {
	Path   string `json:"path"`
	Result int    `json:"result"`
}

Hugo file (path/value pair) data

type CountDraft

type CountDraft struct {
	Draft    int     `json:"draft"`
	NotDraft int     `json:"notdraft"`
	Total    int     `json:"total"`
	Ratio    float32 `json:"ratio"`
}

Count Not-Draft(translated)/Draft(not-translated) file

func (*CountDraft) Add

func (cd *CountDraft) Add(b bool)

func (*CountDraft) Sum

func (cd *CountDraft) Sum() int

type DraftJSON

type DraftJSON struct {
	Count CountDraft `json:"count"`
	Paths PathJSON   `json:"paths"`
}

DraftJSON

type FileJSON added in v0.3.0

type FileJSON struct {
	ContentFiles    []CopyFile `json:"contentfiles"`
	NotContentFiles []CopyFile `json:"notcontentfiles"`
}

type LogJSON added in v0.3.0

type LogJSON struct {
	Header SummaryJSON `json:"header"`
	Paths  FileJSON    `json:"paths"`
}

LogJSON

func GetLogJSON added in v0.3.0

func GetLogJSON() *LogJSON

func NewLogJSON added in v0.3.0

func NewLogJSON(dt, sd, dd string) *LogJSON

Constructor of LogJSON

func (*LogJSON) AddContentFile added in v0.3.0

func (lg *LogJSON) AddContentFile(p string, r int)

Add CopyFile to LogJSON

func (*LogJSON) AddNotContentFile added in v0.3.0

func (lg *LogJSON) AddNotContentFile(p string, r int)

func (*LogJSON) SaveLogJSON added in v0.3.0

func (lg *LogJSON) SaveLogJSON(outfn string) error

Save JSON data to file

type PathJSON

type PathJSON struct {
	Files []PathPair `json:"files"`
}

func CopyContentDir

func CopyContentDir(srcdir, dstdir, outfn string) (PathJSON, error)

Walk directory, while copying the draft file to

type PathPair

type PathPair struct {
	Path  string `json:"path"`
	Title string `json:"title"`
	Draft bool   `json:"draft"`
}

Hugo file (path/value pair) data

type Semver added in v0.2.0

type Semver struct {
	Major      int
	Minor      int
	Patch      int
	Prerelease string
	Metabuild  string
}

Data Semser

func NewSemver added in v0.2.0

func NewSemver() *Semver

Constructor of Semver

func (*Semver) ForceValue added in v0.2.0

func (sv *Semver) ForceValue(str string) error

Force to set the value to struct Semver with SemVer format

func (*Semver) IncMajor added in v0.2.0

func (sv *Semver) IncMajor()

Increment Semver.Major + 1

func (*Semver) IncMinor added in v0.2.0

func (sv *Semver) IncMinor()

Increment Semver.Minor + 1

func (*Semver) IncPatch added in v0.2.0

func (sv *Semver) IncPatch()

Increment Semver.Patch + 1

func (*Semver) SetMetabuild added in v0.2.0

func (sv *Semver) SetMetabuild(m string)

Set string to Semver.Metabuild

func (*Semver) SetPrerelease added in v0.2.0

func (sv *Semver) SetPrerelease(m string)

Set string to Semver.Prerelease

func (*Semver) SetValue added in v0.2.0

func (sv *Semver) SetValue(ma, mi, pa int, pr, mb string)

Force to set the value of Semver

func (*Semver) String added in v0.2.0

func (sv *Semver) String() string

Transform string value to struct Semver

type SummaryJSON added in v0.3.0

type SummaryJSON struct {
	Date   string `json:"date"`
	SrcDir string `json:"srcdir"`
	DstDir string `json:"dstdir"`
}

Summary

type VersionInfo added in v0.3.1

type VersionInfo struct {
	SemVer string `json:"semver"`
	VerMsg string `json:"vermsg"`
}

VersionInfo data

var GlobalVersionInfo VersionInfo

Global variables

Jump to

Keyboard shortcuts

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