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

mlange-42 / modo / 12828318641

17 Jan 2025 11:37AM CUT coverage: 48.228% (+11.7%) from 36.563%
12828318641

Pull #54

github

web-flow
Merge 519b6c6c2 into 41ff6f833
Pull Request #54: More unit tests

12 of 28 new or added lines in 3 files covered. (42.86%)

108 existing lines in 3 files now uncovered.

626 of 1298 relevant lines covered (48.23%)

3.77 hits per line

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

68.42
/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 {
6✔
22
        return NewProcessorWithWriter(docs, f, t, useExports, shortLinks, func(file, text string) error {
6✔
NEW
23
                return os.WriteFile(file, []byte(text), 0666)
×
NEW
24
        })
×
25
}
26

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

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

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

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

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

65
func (proc *Processor) addLinkTarget(elPath, filePath []string, kind string, isSection bool) {
17✔
66
        proc.linkTargets[strings.Join(elPath, ".")] = elemPath{Elements: filePath, Kind: kind, IsSection: isSection}
17✔
67
}
17✔
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