(p *Port)
| 90 | } |
| 91 | |
| 92 | func (i *installReport) renderMarkdown(p *Port) string { |
| 93 | normalize := func(value string) string { |
| 94 | if strings.TrimSpace(value) == "" { |
| 95 | return "-" |
| 96 | } |
| 97 | return value |
| 98 | } |
| 99 | percent := func(part, total int) string { |
| 100 | if total <= 0 { |
| 101 | return "0.0%" |
| 102 | } |
| 103 | return fmt.Sprintf("%.1f%%", float64(part)*100.0/float64(total)) |
| 104 | } |
| 105 | |
| 106 | var ( |
| 107 | lines []string |
| 108 | buildtimeCount int |
| 109 | runtimeCount int |
| 110 | preinstalledCount int |
| 111 | ) |
| 112 | installedFromCount := make(map[string]int) |
| 113 | |
| 114 | orderedEntries := i.orderedEntries() |
| 115 | for _, entry := range orderedEntries { |
| 116 | if entry.DevDep || entry.HostDev { |
| 117 | buildtimeCount++ |
| 118 | } else { |
| 119 | runtimeCount++ |
| 120 | } |
| 121 | |
| 122 | if entry.InstalledFrom == "preinstalled" { |
| 123 | preinstalledCount++ |
| 124 | } |
| 125 | |
| 126 | installedFrom := normalize(entry.InstalledFrom) |
| 127 | installedFromCount[installedFrom]++ |
| 128 | } |
| 129 | freshInstallCount := len(orderedEntries) - preinstalledCount |
| 130 | |
| 131 | lines = append(lines, "# Install report") |
| 132 | lines = append(lines, "") |
| 133 | lines = append(lines, fmt.Sprintf("Generated at `%s`", time.Now().Local().Format("2006-01-02 15:04:05"))) |
| 134 | lines = append(lines, "") |
| 135 | lines = append(lines, "## Overview") |
| 136 | lines = append(lines, "") |
| 137 | lines = append(lines, fmt.Sprintf("- Total packages: `%d`", len(orderedEntries))) |
| 138 | lines = append(lines, fmt.Sprintf("- Fresh installed: `%d`", freshInstallCount)) |
| 139 | lines = append(lines, fmt.Sprintf("- Preinstalled: `%d`", preinstalledCount)) |
| 140 | lines = append(lines, fmt.Sprintf("- Buildtime dependencies: `%d`", buildtimeCount)) |
| 141 | lines = append(lines, fmt.Sprintf("- Runtime dependencies: `%d`", runtimeCount)) |
| 142 | lines = append(lines, "") |
| 143 | lines = append(lines, "### Installation source distribution") |
| 144 | lines = append(lines, "") |
| 145 | lines = append(lines, "| Installed From | Count | Percentage |") |
| 146 | lines = append(lines, "| --- | --- | --- |") |
| 147 | |
| 148 | type installedFromStat struct { |
| 149 | name string |
no test coverage detected