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

mlange-42 / modo / 13090989457

01 Feb 2025 05:48PM CUT coverage: 67.718% (+0.2%) from 67.539%
13090989457

Pull #177

github

web-flow
Merge 3dbd3162f into eb038c037
Pull Request #177: Move initialization logic to formatters

107 of 233 new or added lines in 4 files covered. (45.92%)

1374 of 2029 relevant lines covered (67.72%)

24.95 hits per line

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

51.02
/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

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