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

mlange-42 / modo / 13139991432

04 Feb 2025 04:20PM CUT coverage: 72.507% (-0.9%) from 73.453%
13139991432

push

github

web-flow
Automatically link source modules (#195)

97 of 113 new or added lines in 7 files covered. (85.84%)

24 existing lines in 3 files now uncovered.

1527 of 2106 relevant lines covered (72.51%)

25.54 hits per line

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

98.18
/document/paths.go
1
package document
2

3
import (
4
        "strings"
5
)
6

7
type elemPath struct {
8
        Elements  []string
9
        Kind      string
10
        IsSection bool
11
}
12

13
// Collects lookup for link target paths.
14
// Runs on the re-structured package.
15
func (proc *Processor) collectPaths() {
7✔
16
        proc.linkTargets = map[string]elemPath{}
7✔
17
        proc.collectPathsPackage(proc.ExportDocs.Decl, []string{}, []string{}, proc.addLinkTarget, false)
7✔
18
}
7✔
19

20
// Collects the paths of all (sub)-elements in the original structure.
21
func (proc *Processor) collectElementPaths() {
8✔
22
        proc.allPaths = map[string]bool{}
8✔
23
        proc.collectPathsPackage(proc.Docs.Decl, []string{}, []string{}, proc.addElementPath, true)
8✔
24
}
8✔
25

26
func (proc *Processor) collectPathsPackage(p *Package, elems []string, pathElem []string, add func([]string, []string, string, bool), isOriginal bool) {
22✔
27
        newElems := appendNew(elems, p.GetName())
22✔
28
        newPath := appendNew(pathElem, p.GetFileName())
22✔
29
        if isOriginal {
34✔
30
                p.SetLink(newElems, p.Kind)
12✔
31
        }
12✔
32
        add(newElems, newPath, "package", false)
22✔
33

22✔
34
        for _, pkg := range p.Packages {
29✔
35
                proc.collectPathsPackage(pkg, newElems, newPath, add, isOriginal)
7✔
36
        }
7✔
37
        for _, mod := range p.Modules {
48✔
38
                proc.collectPathsModule(mod, newElems, newPath, add, isOriginal)
26✔
39
        }
26✔
40

41
        for _, s := range p.Structs {
25✔
42
                proc.collectPathsStruct(s, newElems, newPath, add, isOriginal)
3✔
43
        }
3✔
44
        for _, t := range p.Traits {
24✔
45
                proc.collectPathsTrait(t, newElems, newPath, add, isOriginal)
2✔
46
        }
2✔
47
        for _, a := range p.Aliases {
24✔
48
                newElems := appendNew(newElems, a.GetName())
2✔
49
                newPath := appendNew(newPath, "#aliases")
2✔
50
                add(newElems, newPath, "package", true) // kind=package for correct link paths
2✔
51
        }
2✔
52
        for _, f := range p.Functions {
24✔
53
                if isOriginal {
2✔
NEW
54
                        f.SetLink(newElems, f.Kind)
×
NEW
55
                }
×
56
                newElems := appendNew(newElems, f.GetName())
2✔
57
                newPath := appendNew(newPath, f.GetFileName())
2✔
58
                add(newElems, newPath, "function", false)
2✔
59
        }
60
}
61

62
func (proc *Processor) collectPathsModule(m *Module, elems []string, pathElem []string, add func([]string, []string, string, bool), isOriginal bool) {
26✔
63
        newElems := appendNew(elems, m.GetName())
26✔
64
        newPath := appendNew(pathElem, m.GetFileName())
26✔
65
        m.SetLink(newElems, m.Kind)
26✔
66
        add(newElems, newPath, "module", false)
26✔
67

26✔
68
        for _, s := range m.Structs {
50✔
69
                proc.collectPathsStruct(s, newElems, newPath, add, isOriginal)
24✔
70
        }
24✔
71
        for _, t := range m.Traits {
35✔
72
                proc.collectPathsTrait(t, newElems, newPath, add, isOriginal)
9✔
73
        }
9✔
74
        for _, a := range m.Aliases {
38✔
75
                newElems := appendNew(newElems, a.GetName())
12✔
76
                newPath := appendNew(newPath, "#aliases")
12✔
77
                add(newElems, newPath, "module", true) // kind=module for correct link paths
12✔
78
        }
12✔
79
        for _, f := range m.Functions {
35✔
80
                if isOriginal {
15✔
81
                        f.SetLink(newElems, f.Kind)
6✔
82
                }
6✔
83
                newElems := appendNew(newElems, f.GetName())
9✔
84
                newPath := appendNew(newPath, f.GetFileName())
9✔
85
                add(newElems, newPath, "function", false)
9✔
86
        }
87
}
88

89
func (proc *Processor) collectPathsStruct(s *Struct, elems []string, pathElem []string, add func([]string, []string, string, bool), isOriginal bool) {
27✔
90
        newElems := appendNew(elems, s.GetName())
27✔
91
        newPath := appendNew(pathElem, s.GetFileName())
27✔
92
        if isOriginal {
44✔
93
                s.SetLink(elems, s.Kind)
17✔
94
        }
17✔
95
        add(newElems, newPath, "struct", false)
27✔
96

27✔
97
        for _, f := range s.Aliases {
41✔
98
                newElems := appendNew(newElems, f.GetName())
14✔
99
                newPath := appendNew(newPath, "#aliases")
14✔
100
                add(newElems, newPath, "member", true)
14✔
101
        }
14✔
102
        for _, f := range s.Parameters {
38✔
103
                newElems := appendNew(newElems, f.GetName())
11✔
104
                newPath := appendNew(newPath, "#parameters")
11✔
105
                add(newElems, newPath, "member", true)
11✔
106
        }
11✔
107
        for _, f := range s.Fields {
40✔
108
                newElems := appendNew(newElems, f.GetName())
13✔
109
                newPath := appendNew(newPath, "#fields")
13✔
110
                add(newElems, newPath, "member", true)
13✔
111
        }
13✔
112
        for _, f := range s.Functions {
42✔
113
                newElems := appendNew(newElems, f.GetName())
15✔
114
                newPath := appendNew(newPath, "#"+strings.ToLower(f.GetName()))
15✔
115
                add(newElems, newPath, "member", true)
15✔
116
        }
15✔
117
}
118

119
func (proc *Processor) collectPathsTrait(t *Trait, elems []string, pathElem []string, add func([]string, []string, string, bool), isOriginal bool) {
11✔
120
        newElems := appendNew(elems, t.GetName())
11✔
121
        newPath := appendNew(pathElem, t.GetFileName())
11✔
122
        if isOriginal {
17✔
123
                t.SetLink(elems, t.Kind)
6✔
124
        }
6✔
125
        add(newElems, newPath, "trait", false)
11✔
126

11✔
127
        for _, f := range t.Fields {
14✔
128
                newElems := appendNew(newElems, f.GetName())
3✔
129
                newPath := appendNew(newPath, "#fields")
3✔
130
                add(newElems, newPath, "member", true)
3✔
131
        }
3✔
132
        for _, f := range t.Functions {
18✔
133
                newElems := appendNew(newElems, f.GetName())
7✔
134
                newPath := appendNew(newPath, "#"+strings.ToLower(f.GetName()))
7✔
135
                add(newElems, newPath, "member", true)
7✔
136
        }
7✔
137
}
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