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

mlange-42 / modo / 12858570884

20 Jan 2025 12:26AM CUT coverage: 56.633% (-0.8%) from 57.418%
12858570884

push

github

web-flow
Re-export aliases, fix cross-refs to package and module aliases (#73)

* allow re-exports of aliases, render package aliases
* print summary and description for aliases and parameters
* fix formatting of hugo links for aliases

8 of 34 new or added lines in 7 files covered. (23.53%)

2 existing lines in 2 files now uncovered.

841 of 1485 relevant lines covered (56.63%)

8.1 hits per line

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

89.58
/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() {
5✔
16
        proc.linkTargets = map[string]elemPath{}
5✔
17
        proc.collectPathsPackage(proc.ExportDocs.Decl, []string{}, []string{}, proc.addLinkTarget)
5✔
18
}
5✔
19

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

26
func (proc *Processor) collectPathsPackage(p *Package, elems []string, pathElem []string, add func([]string, []string, string, bool)) {
14✔
27
        newElems := appendNew(elems, p.GetName())
14✔
28
        newPath := appendNew(pathElem, p.GetFileName())
14✔
29
        add(newElems, newPath, "package", false)
14✔
30

14✔
31
        for _, pkg := range p.Packages {
17✔
32
                proc.collectPathsPackage(pkg, newElems, newPath, add)
3✔
33
        }
3✔
34
        for _, mod := range p.Modules {
30✔
35
                proc.collectPathsModule(mod, newElems, newPath, add)
16✔
36
        }
16✔
37

38
        for _, s := range p.Structs {
15✔
39
                proc.collectPathsStruct(s, newElems, newPath, add)
1✔
40
        }
1✔
41
        for _, t := range p.Traits {
14✔
42
                proc.collectPathsTrait(t, newElems, newPath, add)
×
43
        }
×
44
        for _, a := range p.Aliases {
14✔
NEW
45
                newElems := appendNew(newElems, a.GetName())
×
NEW
46
                newPath := appendNew(newPath, "#aliases")
×
NEW
47
                add(newElems, newPath, "package", true) // kind=package for correct link paths
×
NEW
48
        }
×
49
        for _, f := range p.Functions {
14✔
50
                newElems := appendNew(newElems, f.GetName())
×
51
                newPath := appendNew(newPath, f.GetFileName())
×
52
                add(newElems, newPath, "function", false)
×
53
        }
×
54
}
55

56
func (proc *Processor) collectPathsModule(m *Module, elems []string, pathElem []string, add func([]string, []string, string, bool)) {
16✔
57
        newElems := appendNew(elems, m.GetName())
16✔
58
        newPath := appendNew(pathElem, m.GetFileName())
16✔
59
        add(newElems, newPath, "module", false)
16✔
60

16✔
61
        for _, s := range m.Structs {
30✔
62
                proc.collectPathsStruct(s, newElems, newPath, add)
14✔
63
        }
14✔
64
        for _, t := range m.Traits {
23✔
65
                proc.collectPathsTrait(t, newElems, newPath, add)
7✔
66
        }
7✔
67
        for _, a := range m.Aliases {
18✔
68
                newElems := appendNew(newElems, a.GetName())
2✔
69
                newPath := appendNew(newPath, "#aliases")
2✔
70
                add(newElems, newPath, "module", true) // kind=module for correct link paths
2✔
71
        }
2✔
72
        for _, f := range m.Functions {
23✔
73
                newElems := appendNew(newElems, f.GetName())
7✔
74
                newPath := appendNew(newPath, f.GetFileName())
7✔
75
                add(newElems, newPath, "function", false)
7✔
76
        }
7✔
77
}
78

79
func (proc *Processor) collectPathsStruct(s *Struct, elems []string, pathElem []string, add func([]string, []string, string, bool)) {
15✔
80
        newElems := appendNew(elems, s.GetName())
15✔
81
        newPath := appendNew(pathElem, s.GetFileName())
15✔
82
        add(newElems, newPath, "struct", false)
15✔
83

15✔
84
        for _, f := range s.Aliases {
17✔
85
                newElems := appendNew(newElems, f.GetName())
2✔
86
                newPath := appendNew(newPath, "#aliases")
2✔
87
                add(newElems, newPath, "member", true)
2✔
88
        }
2✔
89
        for _, f := range s.Parameters {
18✔
90
                newElems := appendNew(newElems, f.GetName())
3✔
91
                newPath := appendNew(newPath, "#parameters")
3✔
92
                add(newElems, newPath, "member", true)
3✔
93
        }
3✔
94
        for _, f := range s.Fields {
20✔
95
                newElems := appendNew(newElems, f.GetName())
5✔
96
                newPath := appendNew(newPath, "#fields")
5✔
97
                add(newElems, newPath, "member", true)
5✔
98
        }
5✔
99
        for _, f := range s.Functions {
18✔
100
                newElems := appendNew(newElems, f.GetName())
3✔
101
                newPath := appendNew(newPath, "#"+strings.ToLower(f.GetName()))
3✔
102
                add(newElems, newPath, "member", true)
3✔
103
        }
3✔
104
}
105

106
func (proc *Processor) collectPathsTrait(t *Trait, elems []string, pathElem []string, add func([]string, []string, string, bool)) {
7✔
107
        newElems := appendNew(elems, t.GetName())
7✔
108
        newPath := appendNew(pathElem, t.GetFileName())
7✔
109
        add(newElems, newPath, "trait", false)
7✔
110

7✔
111
        for _, f := range t.Fields {
10✔
112
                newElems := appendNew(newElems, f.GetName())
3✔
113
                newPath := appendNew(newPath, "#fields")
3✔
114
                add(newElems, newPath, "member", true)
3✔
115
        }
3✔
116
        for _, f := range t.Functions {
10✔
117
                newElems := appendNew(newElems, f.GetName())
3✔
118
                newPath := appendNew(newPath, "#"+strings.ToLower(f.GetName()))
3✔
119
                add(newElems, newPath, "member", true)
3✔
120
        }
3✔
121
}
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