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

mlange-42 / modo / 12831974413

17 Jan 2025 03:26PM CUT coverage: 57.927%. Remained the same
12831974413

push

github

web-flow
Update CHANGELOG for v0.6.0 release (#57)

749 of 1293 relevant lines covered (57.93%)

6.98 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 {
7✔
22
        return NewProcessorWithWriter(docs, f, t, useExports, shortLinks, func(file, text string) error {
7✔
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 {
11✔
28
        return &Processor{
11✔
29
                Template:   t,
11✔
30
                Formatter:  f,
11✔
31
                UseExports: useExports,
11✔
32
                ShortLinks: shortLinks,
11✔
33
                Docs:       docs,
11✔
34
                writer:     writer,
11✔
35
        }
11✔
36
}
11✔
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) {
17✔
62
        proc.linkExports[strings.Join(oldPath, ".")] = strings.Join(newPath, ".")
17✔
63
}
17✔
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