lib

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_MD_EXT       = ".md"
	DEFAULT_README       = "README.md"
	DEFAULT_MARKER_SKIP  = "<!--skip-sync-->"
	DEFAULT_MARKER_SPLIT = "<!--more-->"
	TXT_IN_SAME_DIR      = " in same directory."
	TXT_SAME_DIR         = " are same directories."
	TXT_NOT_DIR          = " is not directory."
	TXT_NOT_FILE         = " is not a regular file."
)

Variables

This section is empty.

Functions

func CheckMarker

func CheckMarker(listSkip, listSplit *FileCutterList, filename string)

func DirFileMapInit

func DirFileMapInit()

Create map[blog file full path](repository readme full path)

  • map is created if simplified blog name == simplified repository name

func MappedFileSync

func MappedFileSync()

map in format map[<readme>]=<blog>

func ReadmeBlogMapPrint

func ReadmeBlogMapPrint()

Print readme - blog mapping

Types

type FileCutter

type FileCutter struct {
	Bottom      *[]string `json:"bottom"`      // out: content after split marker
	Filename    string    `json:"filename"`    // in: filename
	NoSkip      bool      `json:"noSkip"`      // in: ignore skip-marker
	Skipped     bool      `json:"skip"`        // out: true if skip-marker found
	SkipMarker  string    `json:"skipMarker"`  // in: skip marker
	Split       bool      `json:"split"`       // out: true if split-marker is found
	SplitMarker string    `json:"splitMarker"` // in: split marker
	SplitLine   int       `json:"splitLine"`   // out: Line number split-marker is found
	Top         *[]string `json:"top"`         // out: content before split marker
}

func FileCutterNew

func FileCutterNew(filename string) *FileCutter

Create *FileCutter

  • Set markers using Flag

func (*FileCutter) Join

func (self *FileCutter) Join(bottom *FileCutter) *FileCutter

Use <bottom>.Bottom

func (*FileCutter) Read

func (self *FileCutter) Read(filename string) *FileCutter

Read file and split content

  • If <filename> empty, self.Filename will be used
  • clear self.Top, save content before split-marker to self.Top
  • clear self.Bottom, save content after split-marker to self.Bottom
  • Set self.Split = true if split-marker found, set self.SplitLn
  • Set self.Skip = true if skip-marker found, clear self.SplitLn, self.Found

func (*FileCutter) ReadBottom

func (self *FileCutter) ReadBottom(filename string) *FileCutter

Read file and split content

  • If <filename> empty, self.Filename will be used
  • clear self.Bottom, save content after split-marker to self.Bottom
  • Set self.Split = true if split-marker found, set self.SplitLn
  • Set self.Skip = true if skip-marker found, clear self.SplitLn, self.Found

func (*FileCutter) ReadContent

func (self *FileCutter) ReadContent(filename string, readTop bool, readBottom bool) *FileCutter

Read file and split content base on parameters

  • If <filename> empty, self.Filename will be used
  • If readTop, clear self.Top, save content before split-marker to self.Top
  • If readBottom, clear self.Bottom, save content after split-marker to self.Bottom
  • Set self.Split = true if split-marker found, set self.SplitLn
  • Set self.Skip = true if skip-marker found, clear self.SplitLn, self.Found

func (*FileCutter) ReadTop

func (self *FileCutter) ReadTop(filename string) *FileCutter

Read file and split content

  • If <filename> empty, self.Filename will be used
  • clear self.Top, save content before split-marker to self.Top
  • Set self.Split = true if split-marker found, set self.SplitLn
  • Set self.Skip = true if skip-marker found, clear self.SplitLn, self.Found

func (*FileCutter) Reset

func (self *FileCutter) Reset() *FileCutter

Reset all values except markers

func (*FileCutter) Save

func (self *FileCutter) Save(filename string) *FileCutter

Save split content to file

  • If <filename> empty, self.Filename will be used
  • Save self.Top, split-maker, self.Bottom
  • Not save if self.Top or self.Bottom is nil

type FileCutterList

type FileCutterList []*FileCutter

func (*FileCutterList) GetNames

func (self *FileCutterList) GetNames() *[]string

type FileMap

type FileMap map[string]string

func (*FileMap) Join

func (self *FileMap) Join(map2 *FileMap) *FileMap

If self[<name>] and map2[<name>] exist, map3[self[<name>]] = map2[<name>].

  • If an index exist in both maps, create a mapping with their values
  • Return pointer of new map3

func (*FileMap) MapDirFile

func (self *FileMap) MapDirFile(dir, filename string)

Create map[simplified dir name](file full path)

  • create mapping between simplified dir names and full path of specific file it contains

func (*FileMap) MapFile

func (self *FileMap) MapFile(dir string)

Create map[simplified file name](file full path)

  • create mapping between simplified base file names and full path of the file

type TypeConf

type TypeConf struct {
	File       string  `json:"file"`
	Blog       FileMap `json:"blog"`
	Readme     FileMap `json:"readme"`
	ReadmeBlog FileMap `json:"readmeBlog"`
}
var Conf TypeConf

func (*TypeConf) Init

func (self *TypeConf) Init()

Fill in conf struct from viper

type TypeFlag

type TypeFlag struct {
	Args          []string // Args from command line
	Debug         bool     // Enable debug output
	DefaultMdExt  string   // Default md extension
	DefaultReadme string   // Default readme filename
	DirBlog       string   // Hugo blog content dir
	DirOut        string   // Output directory
	DirSrc        string   // Parent directory of repositories(not dir repo itself)
	FileBlog      string   // Single blog file to be process
	FileOut       string   // Output file
	FileReadme    string   // Single readme to be process
	Forced        bool     // Allow overwriting original file
	MarkerSkip    string   // skip marker
	MarkerSplit   string   // split marker
	NoError       bool     // Do not print error
	NoParallel    bool     // Do not process in parallel(go routine)
	NoSkip        bool     // Flag for ignoring skip marker
	ShowFileList  bool     // Show file list in directory mode
}

Holding all flags from command line

var Flag TypeFlag

Jump to

Keyboard shortcuts

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