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

mlange-42 / modo / 12828585719

17 Jan 2025 11:57AM CUT coverage: 47.571% (+11.0%) from 36.563%
12828585719

Pull #54

github

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

21 of 36 new or added lines in 3 files covered. (58.33%)

13 existing lines in 2 files now uncovered.

617 of 1297 relevant lines covered (47.57%)

3.96 hits per line

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

76.32
/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 {
7✔
22
        return NewProcessorWithWriter(docs, f, t, useExports, shortLinks, func(file, text string) error {
7✔
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 {
8✔
28
        return &Processor{
8✔
29
                Template:   t,
8✔
30
                Formatter:  f,
8✔
31
                UseExports: useExports,
8✔
32
                ShortLinks: shortLinks,
8✔
33
                Docs:       docs,
8✔
34
                writer:     writer,
8✔
35
        }
8✔
36
}
8✔
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

57
func (proc *Processor) WriteFile(file, text string) error {
6✔
58
        return proc.writer(file, text)
6✔
59
}
6✔
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