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

mlange-42 / modo / 13168851212

06 Feb 2025 12:00AM CUT coverage: 72.707%. Remained the same
13168851212

push

github

web-flow
Add ease of setup to features (#209)

1649 of 2268 relevant lines covered (72.71%)

26.89 hits per line

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

64.81
/internal/format/plain.go
1
package format
2

3
import (
4
        "fmt"
5
        "os"
6
        "path"
7
        "text/template"
8

9
        "github.com/mlange-42/modo/internal/document"
10
)
11

12
const landingPageContentPlain = `# Landing page
13

14
JSON created by mojo doc should be placed next to this file.
15

16
Additional documentation files go here, too.
17
They will be processed for doc-tests and copied to folder 'site'.
18
`
19

20
type Plain struct{}
21

22
func (f *Plain) Accepts(files []string) error {
×
23
        return nil
×
24
}
×
25

26
func (f *Plain) ProcessMarkdown(element any, text string, proc *document.Processor) (string, error) {
×
27
        return text, nil
×
28
}
×
29

30
func (f *Plain) WriteAuxiliary(p *document.Package, dir string, proc *document.Processor) error {
×
31
        return nil
×
32
}
×
33

34
func (f *Plain) ToFilePath(p string, kind string) string {
6✔
35
        if kind == "package" || kind == "module" {
10✔
36
                return path.Join(p, "_index.md")
4✔
37
        }
4✔
38
        if len(p) == 0 {
2✔
39
                return p
×
40
        }
×
41
        return p + ".md"
2✔
42
}
43

44
func (f *Plain) ToLinkPath(p string, kind string) string {
3✔
45
        return f.ToFilePath(p, kind)
3✔
46
}
3✔
47

48
func (f *Plain) Input(in string, sources []document.PackageSource) string {
1✔
49
        return in
1✔
50
}
1✔
51

52
func (f *Plain) Output(out string) string {
1✔
53
        return out
1✔
54
}
1✔
55

56
func (f *Plain) GitIgnore(in, out string, sources []document.PackageSource) []string {
1✔
57
        return []string{
1✔
58
                "# files generated by 'mojo doc'",
1✔
59
                fmt.Sprintf("/%s/*.json", in),
1✔
60
                "# files generated by Modo",
1✔
61
                fmt.Sprintf("/%s/", out),
1✔
62
                "# test file generated by Modo",
1✔
63
                "/test/",
1✔
64
        }
1✔
65
}
1✔
66

67
func (f *Plain) CreateDirs(base, in, out string, sources []document.PackageSource, _ *template.Template) error {
1✔
68
        inDir, outDir := path.Join(base, in), path.Join(base, out)
1✔
69
        testDir := path.Join(base, "test")
1✔
70
        if err := mkDirs(inDir); err != nil {
1✔
71
                return err
×
72
        }
×
73
        if err := os.WriteFile(path.Join(inDir, "_index.md"), []byte(landingPageContentPlain), 0644); err != nil {
1✔
74
                return err
×
75
        }
×
76
        if err := mkDirs(outDir); err != nil {
1✔
77
                return err
×
78
        }
×
79
        return mkDirs(testDir)
1✔
80
}
81

82
func (f *Plain) Clean(out, tests string) error {
1✔
83
        if err := emptyDir(out); err != nil {
1✔
84
                return err
×
85
        }
×
86
        return emptyDir(tests)
1✔
87
}
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