(report: Report, cfg: ToolConfig)
| 897 | |
| 898 | |
| 899 | def to_markdown(report: Report, cfg: ToolConfig) -> str: |
| 900 | pol = cfg.policy |
| 901 | t = report.totals |
| 902 | lines: list[str] = [] |
| 903 | |
| 904 | lines.append("# 🌡️ DeepLabCut freshness report\n") |
| 905 | lines.append(f"Generated: {report.generated_at.isoformat()}\n") |
| 906 | lines.append(f"Schema: v{report.schema_version}\n\n") |
| 907 | |
| 908 | lines.append("## Summary\n") |
| 909 | lines.append(f"- Files scanned: **{t['files']}**\n") |
| 910 | lines.append(f"- Files with warnings: **{t['warnings']}**\n") |
| 911 | lines.append(f"- Files with scanning errors: **{t['errors']}**\n") |
| 912 | lines.append(f"- Missing metadata: **{t['missing_metadata']}**\n") |
| 913 | lines.append(f"- Missing last_verified: **{t['missing_last_verified']}**\n") |
| 914 | lines.append(f"- Content-stale (> {pol.warn_if_content_older_than_days}d): **{t['content_stale']}**\n") |
| 915 | lines.append(f"- Verification-stale (> {pol.warn_if_verified_older_than_days}d): **{t['verified_stale']}**\n\n") |
| 916 | |
| 917 | def fmt_date(d: date | None) -> str: |
| 918 | return d.isoformat() if d else "-" |
| 919 | |
| 920 | warn_recs = [r for r in report.records if r.warnings and not (r.meta and r.meta.ignore)] |
| 921 | warn_recs.sort( |
| 922 | key=lambda r: ( |
| 923 | -(r.days_since_verified or -1), |
| 924 | -(r.days_since_content_update or -1), |
| 925 | r.path, |
| 926 | ) |
| 927 | ) |
| 928 | |
| 929 | if warn_recs: |
| 930 | lines.append("## Warnings\n") |
| 931 | for r in warn_recs: |
| 932 | meta = r.meta |
| 933 | lines.append(f"- **{r.path}** ({r.kind})\n") |
| 934 | lines.append( |
| 935 | f" - last_content_updated: {fmt_date(r.last_content_updated)} " |
| 936 | f"(days: {r.days_since_content_update if r.days_since_content_update is not None else '-'})\n" |
| 937 | ) |
| 938 | if r.last_git_touched: |
| 939 | lines.append(f" - last_git_touched: {fmt_date(r.last_git_touched)}\n") |
| 940 | if meta and meta.last_metadata_updated: |
| 941 | lines.append(f" - last_metadata_updated: {fmt_date(meta.last_metadata_updated)}\n") |
| 942 | lv = meta.last_verified if meta else None |
| 943 | lines.append( |
| 944 | f" - last_verified: {fmt_date(lv)} " |
| 945 | f"(days: {r.days_since_verified if r.days_since_verified is not None else '-'})\n" |
| 946 | ) |
| 947 | if meta and meta.verified_for: |
| 948 | lines.append(f" - verified_for: {meta.verified_for}\n") |
| 949 | if meta and meta.tier: |
| 950 | lines.append(f" - tier: {meta.tier}\n") |
| 951 | lines.append(f" - warnings: {', '.join(r.warnings)}\n") |
| 952 | if r.errors: |
| 953 | lines.append(f" - errors: {', '.join(r.errors)}\n") |
| 954 | lines.append("\n") |
| 955 | |
| 956 | err_recs = [r for r in report.records if r.errors] |
no test coverage detected