// Document tries to match a file as document type
770070
func Document(buf []byte) (types.Type, error) {
	return doMatchMap(buf, matchers.Document)
}
502577
func File(
	path string,
	includePatterns []string,
	excludePatterns []string,
) (string, error) {
	if excluded, err := MatchAny(path, excludePatterns); err != nil {
		return "", err
	} else if excluded {
		return "", nil
	}
	if included, err := MatchAny(path, includePatterns); err != nil {
		return "", err
	} else if included {
		return path, nil
	}
	return "", nil
}
139792
func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool {
	token := peek_token(parser)
	if token == nil {
		return false
	}
	if token.typ == yaml_VERSION_DIRECTIVE_TOKEN ||
		token.typ == yaml_TAG_DIRECTIVE_TOKEN ||
		token.typ == yaml_DOCUMENT_START_TOKEN ||
		token.typ == yaml_DOCUMENT_END_TOKEN ||
		token.typ == yaml_STREAM_END_TOKEN {
		parser.state = parser.states[len(parser.states)-1]
		parser.states = parser.states[:len(parser.states)-1]
		return yaml_parser_process_empty_scalar(parser, event,
			token.start_mark)
	}
	return yaml_parser_parse_node(parser, event, true, false)
}
949223
func (t *Template) file(fileName string) ([]byte, error) {
	tmplBytes, err := t.AssetFunc(fileName)
	if err != nil {
		return nil, err
	}
	return tmplBytes, nil
}
758920
func (h *handler) fetchDocumentFunc(blobs []blob.Ref,
	searchFunc func([]blob.Ref) (*search.SearchResult, error)) (*document, error) {
	res, err := searchFunc(blobs)
	if err != nil {
		return nil, err
	}
	if len(res.Blobs) < 1 {
		return nil, os.ErrNotExist
	}
	if res.Describe == nil || len(res.Describe.Meta) == 0 {
		return nil, errors.New("document permanode was not described")
	}
	for _, des := range res.Describe.Meta {
		if des.Permanode == nil {
			continue
		}
		doc, err := h.describeDocument(des)
		if err != nil {
			return nil, fmt.Errorf("error describing document %v: %v", des.BlobRef, err)
		}
		return doc, nil
	}
	return nil, os.ErrNotExist
}
542273
func (p *parserMixin) File() (target **os.File) {
	target = new(*os.File)
	p.FileVar(target)
	return
}
614341
func (list *DocumentList) Find(id string) *Document {
	for _, item := range list.Data {
		if item.ID == id {
			return item
		}
	}

	return nil
}
1062202
func (d *Document) String() string {
	json, _ := json.MarshalIndent(d, "", "    ")
	return string(json)
}
715964
func (t *docMatchTree) matches(cp *contentProvider, cost int, known map[matchTree]bool) (bool, bool) {
	return len(t.current) > 0, true
}
523171
func (t *TypeInfo) Doc() *ast.CommentGroup {
	if t.TypeSpec.Doc != nil {
		return t.TypeSpec.Doc
	}
	if t.GenDecl.Doc != nil {
		return t.GenDecl.Doc
	}
	return nil
}
996391
func (q *PercolatorQuery) DocumentType(typ string) *PercolatorQuery {
	q.documentType = typ
	return q
}
667510
func Doc(raw string) string {
	skipFirstLine := false
	if len(raw) > 0 && raw[0] == '\n' {
		raw = raw[1:]
	} else {
		skipFirstLine = true
	}

	lines := strings.Split(raw, "\n")

	minIndentSize := getMinIndent(lines, skipFirstLine)
	lines = removeIndentation(lines, minIndentSize, skipFirstLine)

	return strings.Join(lines, "\n")
}
721829
func (d *Document) Assess() *Assessment {
	a := Assessment{
		FleschKincaid: d.FleschKincaid(), ReadingEase: d.FleschReadingEase(),
		GunningFog: d.GunningFog(), SMOG: d.SMOG(), DaleChall: d.DaleChall(),
		AutomatedReadability: d.AutomatedReadability(), ColemanLiau: d.ColemanLiau()}

	gradeScores := []float64{
		a.FleschKincaid, a.AutomatedReadability, a.GunningFog, a.SMOG,
		a.ColemanLiau}

	mean, merr := stats.Mean(gradeScores)
	stdDev, serr := stats.StandardDeviation(gradeScores)
	if merr != nil || serr != nil {
		a.MeanGradeLevel = 0.0
		a.StdDevGradeLevel = 0.0
	} else {
		a.MeanGradeLevel = mean
		a.StdDevGradeLevel = stdDev
	}

	return &a
}
313060
func (r *RandomGenerator) File() string {
	return fmt.Sprintf("%sjpg", r.faker.Sentence(1, false))
}
979310
func match(r io.Reader) (io.Reader, types.Type, error) {
	buffer := make([]byte, 512)

	n, err := r.Read(buffer)
	if err != nil && err != io.EOF {
		return nil, types.Unknown, err
	}

	r = io.MultiReader(bytes.NewBuffer(buffer[:n]), r)

	typ, err := filetype.Match(buffer)

	return r, typ, err
}
503258
func (g *GlobPath) MatchString(path string) bool {
	if !g.HasSuperMeta {
		res, _ := filepath.Match(g.path, path)
		return res
	}
	return g.g.Match(path)
}
622036
func DetectFileType(r io.Reader) (FileType, error) {
	var b bytes.Buffer
	n, err := io.CopyN(&b, r, readLen)
	if err != nil && err != io.EOF {
		return TypeUnknown, err
	}
	bs := b.Bytes()
	switch {
	case bytes.HasPrefix(bs, hdrGzip):
		return TypeGzip, nil
	case bytes.HasPrefix(bs, hdrBzip2):
		return TypeBzip2, nil
	case bytes.HasPrefix(bs, hdrXz):
		return TypeXz, nil
	case n > int64(tarEnd) && bytes.Equal(bs[tarOffset:tarEnd], sigTar):
		return TypeTar, nil
	case http.DetectContentType(bs) == textMime:
		return TypeText, nil
	default:
		return TypeUnknown, nil
	}
}