-
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (84 loc) · 3.08 KB
/
Copy pathdocs.yml
File metadata and controls
100 lines (84 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Check Documentation
on:
pull_request:
paths:
- 'lib/**/*.dart'
- 'README.md'
workflow_dispatch:
jobs:
doc-check:
name: Documentation Check
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.27.0'
channel: 'stable'
cache: true
- name: Get dependencies
run: flutter pub get
- name: Generate documentation
run: |
dart doc --output docs/api
echo "Documentation generated successfully!"
- name: Check for undocumented public APIs
run: |
echo "## 📚 Documentation Coverage" > doc_report.md
echo "" >> doc_report.md
# Check for missing documentation
flutter analyze --no-fatal-infos 2>&1 | grep -i "document" > doc_warnings.txt || true
if [ -s doc_warnings.txt ]; then
echo "⚠️ **Found undocumented APIs:**" >> doc_report.md
echo "\`\`\`" >> doc_report.md
cat doc_warnings.txt >> doc_report.md
echo "\`\`\`" >> doc_report.md
else
echo "✅ **All public APIs are documented!**" >> doc_report.md
fi
echo "" >> doc_report.md
echo "---" >> doc_report.md
echo "*Tip: Add documentation comments to all public classes, methods, and functions.*" >> doc_report.md
- name: Comment PR with documentation report
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('doc_report.md', 'utf8');
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📚 Documentation Coverage')
);
const commentBody = `${report}\n\n---\n*Updated: ${new Date().toUTCString()}*`;
if (botComment) {
await github.rest.issues.updateComment({
comment_id: botComment.id,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
}
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: api-documentation
path: docs/api
retention-days: 30