input

package
v0.0.0-...-3fcfa23 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package input 用于处理文件输入,过滤代码,生成 types.Doc 数据。

多行注释和单行注释在处理上会有一定区别:

  • 单行注释,风格相同且相邻的注释会被合并成一个注释块;
  • 单行注释,风格不相同且相邻的注释会被按注释风格多个注释块;
  • 多行注释,即使两个注释释块相邻也会被分成两个注释块来处理。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encodings

func Encodings() []string

Encodings 返回支持的编码方式

func Languages

func Languages() []string

Languages 返回所有支持的语言

func Parse

func Parse(options ...*Options) (*types.Doc, time.Duration)

Parse 分析源代码,获取相应的文档内容。

Types

type Options

type Options struct {
	ErrorLog *log.Logger `yaml:"-"` // 错误输出通道
	WarnLog  *log.Logger `yaml:"-"` // 警告输出通道

	StartLineNumber int      `yaml:"startLineNumber,omitempty"` // 代码的超始行号,默认为 0
	Lang            string   `yaml:"lang"`                      // 输入的目标语言
	Dir             string   `yaml:"dir"`                       // 源代码目录
	Exts            []string `yaml:"exts,omitempty"`            // 需要扫描的文件扩展名,若未指定,则使用默认值
	Recursive       bool     `yaml:"recursive"`                 // 是否查找 Dir 的子目录
	Encoding        string   `yaml:"encoding,omitempty"`        // 文件的编码
	Title           string   `yaml:"title"`                     // template title
}

Options 指定输入内容的相关信息。

func Detect

func Detect(dir string, recursive bool) (*Options, error)

Detect 检测指定目录下的内容,并为其生成一个合适的 Options 实例。

检测依据为根据扩展名来做统计,数量最大且被支持的获胜。

func (*Options) Sanitize

func (opt *Options) Sanitize() *types.OptionsError

Sanitize 检测 Options 变量是否符合要求

Directories

Path Synopsis
Package encoding 为输入的文件提供编码支持。
Package encoding 为输入的文件提供编码支持。
Package syntax 负责对标签语法的解析操作。
Package syntax 负责对标签语法的解析操作。

Jump to

Keyboard shortcuts

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