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

mlange-42 / modo / 13091204905

01 Feb 2025 06:16PM CUT coverage: 70.922% (+3.4%) from 67.539%
13091204905

push

github

web-flow
Move initialization logic to formatters (#177)

172 of 233 new or added lines in 4 files covered. (73.82%)

1439 of 2029 relevant lines covered (70.92%)

25.05 hits per line

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

65.31
/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/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✔
NEW
71
                return err
×
NEW
72
        }
×
73
        if err := os.WriteFile(path.Join(inDir, "_index.md"), []byte(landingPageContentPlain), 0644); err != nil {
1✔
NEW
74
                return err
×
NEW
75
        }
×
76
        if err := mkDirs(outDir); err != nil {
1✔
NEW
77
                return err
×
NEW
78
        }
×
79
        return mkDirs(testDir)
1✔
80
}
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