• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mlange-42 / modo / 12849298326

19 Jan 2025 01:48AM CUT coverage: 58.946% (-0.09%) from 59.033%
12849298326

push

github

web-flow
Print completed message with processing duration (#67)

0 of 2 new or added lines in 1 file covered. (0.0%)

794 of 1347 relevant lines covered (58.95%)

7.44 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.21
/document/processor.go
1
package document
2

3
import (
4
        "os"
5
        "strings"
6
        "text/template"
7
)
8

9
type Processor struct {
10
        Template    *template.Template
11
        Formatter   Formatter
12
        UseExports  bool
13
        ShortLinks  bool
14
        Docs        *Docs
15
        ExportDocs  *Docs
16
        linkTargets map[string]elemPath
17
        linkExports map[string]string
18
        writer      func(file, text string) error
19
}
20

21
func NewProcessor(docs *Docs, f Formatter, t *template.Template, useExports bool, shortLinks bool) *Processor {
8✔
22
        return NewProcessorWithWriter(docs, f, t, useExports, shortLinks, func(file, text string) error {
8✔
23
                return os.WriteFile(file, []byte(text), 0666)
×
24
        })
×
25
}
26

27
func NewProcessorWithWriter(docs *Docs, f Formatter, t *template.Template, useExports bool, shortLinks bool, writer func(text, file string) error) *Processor {
12✔
28
        return &Processor{
12✔
29
                Template:   t,
12✔
30
                Formatter:  f,
12✔
31
                UseExports: useExports,
12✔
32
                ShortLinks: shortLinks,
12✔
33
                Docs:       docs,
12✔
34
                writer:     writer,
12✔
35
        }
12✔
36
}
12✔
37

38
// PrepareDocs processes the API docs for subsequent rendering.
39
func (proc *Processor) PrepareDocs() error {
4✔
40
        err := proc.filterPackages()
4✔
41
        if err != nil {
4✔
42
                return err
×
43
        }
×
44
        proc.collectPaths()
4✔
45

4✔
46
        if !proc.UseExports {
7✔
47
                for k := range proc.linkTargets {
15✔
48
                        proc.linkExports[k] = k
12✔
49
                }
12✔
50
        }
51
        if err := proc.processLinksPackage(proc.Docs.Decl, []string{}); err != nil {
4✔
52
                return err
×
53
        }
×
54
        return nil
4✔
55
}
56

57
func (proc *Processor) WriteFile(file, text string) error {
15✔
58
        return proc.writer(file, text)
15✔
59
}
15✔
60

61
func (proc *Processor) addLinkExport(oldPath, newPath []string) {
27✔
62
        proc.linkExports[strings.Join(oldPath, ".")] = strings.Join(newPath, ".")
27✔
63
}
27✔
64

65
func (proc *Processor) addLinkTarget(elPath, filePath []string, kind string, isSection bool) {
32✔
66
        proc.linkTargets[strings.Join(elPath, ".")] = elemPath{Elements: filePath, Kind: kind, IsSection: isSection}
32✔
67
}
32✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc