|
| 1 | +name: Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths: |
| 7 | + - '**.md' |
| 8 | + - 'docs/**' |
| 9 | + - '.github/workflows/docs.yml' |
| 10 | + pull_request: |
| 11 | + branches: [ main ] |
| 12 | + paths: |
| 13 | + - '**.md' |
| 14 | + - 'docs/**' |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: write |
| 19 | + pages: write |
| 20 | + id-token: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + check-links: |
| 24 | + name: Check Documentation Links |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout code |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Check links in markdown files |
| 32 | + uses: gaurav-nelson/github-action-markdown-link-check@v1 |
| 33 | + with: |
| 34 | + use-quiet-mode: 'yes' |
| 35 | + use-verbose-mode: 'yes' |
| 36 | + config-file: '.github/markdown-link-check-config.json' |
| 37 | + folder-path: '.' |
| 38 | + file-path: './README_NEW.md, ./INSTALLATION.md, ./CONTRIBUTING.md' |
| 39 | + continue-on-error: true |
| 40 | + |
| 41 | + validate-markdown: |
| 42 | + name: Validate Markdown |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Setup Node.js |
| 50 | + uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version: '20' |
| 53 | + |
| 54 | + - name: Install markdownlint-cli |
| 55 | + run: npm install -g markdownlint-cli |
| 56 | + |
| 57 | + - name: Lint markdown files |
| 58 | + run: | |
| 59 | + markdownlint '**/*.md' --ignore node_modules --ignore .github || true |
| 60 | + continue-on-error: true |
| 61 | + |
| 62 | + spell-check: |
| 63 | + name: Spell Check |
| 64 | + runs-on: ubuntu-latest |
| 65 | + |
| 66 | + steps: |
| 67 | + - name: Checkout code |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Setup Node.js |
| 71 | + uses: actions/setup-node@v4 |
| 72 | + with: |
| 73 | + node-version: '20' |
| 74 | + |
| 75 | + - name: Install cspell |
| 76 | + run: npm install -g cspell |
| 77 | + |
| 78 | + - name: Run spell check |
| 79 | + run: | |
| 80 | + cspell "**/*.md" "**/*.py" --no-progress || true |
| 81 | + continue-on-error: true |
| 82 | + |
| 83 | + build-docs: |
| 84 | + name: Build Documentation |
| 85 | + runs-on: ubuntu-latest |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Checkout code |
| 89 | + uses: actions/checkout@v4 |
| 90 | + |
| 91 | + - name: Set up Python |
| 92 | + uses: actions/setup-python@v5 |
| 93 | + with: |
| 94 | + python-version: '3.11' |
| 95 | + |
| 96 | + - name: Install dependencies |
| 97 | + run: | |
| 98 | + python -m pip install --upgrade pip |
| 99 | + pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints |
| 100 | + pip install -r requirements.txt |
| 101 | + |
| 102 | + - name: Generate API documentation |
| 103 | + run: | |
| 104 | + mkdir -p docs/api |
| 105 | + python -m sphinx.ext.apidoc -o docs/api wifijam |
| 106 | + continue-on-error: true |
| 107 | + |
| 108 | + - name: Build documentation |
| 109 | + run: | |
| 110 | + # Create a simple index if sphinx conf doesn't exist |
| 111 | + if [ ! -f docs/conf.py ]; then |
| 112 | + echo "Documentation build skipped - no Sphinx configuration" |
| 113 | + fi |
| 114 | + continue-on-error: true |
| 115 | + |
| 116 | + check-readme: |
| 117 | + name: Check README Quality |
| 118 | + runs-on: ubuntu-latest |
| 119 | + |
| 120 | + steps: |
| 121 | + - name: Checkout code |
| 122 | + uses: actions/checkout@v4 |
| 123 | + |
| 124 | + - name: Check README exists |
| 125 | + run: | |
| 126 | + if [ ! -f README_NEW.md ]; then |
| 127 | + echo "❌ README_NEW.md not found!" |
| 128 | + exit 1 |
| 129 | + fi |
| 130 | + echo "✅ README_NEW.md exists" |
| 131 | + |
| 132 | + - name: Check README length |
| 133 | + run: | |
| 134 | + LINES=$(wc -l < README_NEW.md) |
| 135 | + echo "README has $LINES lines" |
| 136 | + if [ $LINES -lt 50 ]; then |
| 137 | + echo "⚠️ README seems too short (less than 50 lines)" |
| 138 | + else |
| 139 | + echo "✅ README has adequate length" |
| 140 | + fi |
| 141 | + |
| 142 | + - name: Check for required sections |
| 143 | + run: | |
| 144 | + echo "Checking for required sections..." |
| 145 | + |
| 146 | + check_section() { |
| 147 | + if grep -q "$1" README_NEW.md; then |
| 148 | + echo "✅ Found: $1" |
| 149 | + else |
| 150 | + echo "❌ Missing: $1" |
| 151 | + return 1 |
| 152 | + fi |
| 153 | + } |
| 154 | + |
| 155 | + check_section "Installation" || true |
| 156 | + check_section "Usage" || true |
| 157 | + check_section "Features" || true |
| 158 | + check_section "Requirements" || true |
| 159 | + check_section "License" || true |
| 160 | + |
| 161 | + - name: Check for badges |
| 162 | + run: | |
| 163 | + if grep -q "!\[.*\](https://img.shields.io" README_NEW.md; then |
| 164 | + echo "✅ README contains badges" |
| 165 | + else |
| 166 | + echo "⚠️ Consider adding status badges to README" |
| 167 | + fi |
| 168 | +
|
| 169 | + update-badges: |
| 170 | + name: Update Status Badges |
| 171 | + runs-on: ubuntu-latest |
| 172 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 173 | + needs: [check-links, validate-markdown, check-readme] |
| 174 | + |
| 175 | + steps: |
| 176 | + - name: Checkout code |
| 177 | + uses: actions/checkout@v4 |
| 178 | + with: |
| 179 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 180 | + |
| 181 | + - name: Generate badge URLs |
| 182 | + run: | |
| 183 | + echo "# Status Badges" > badges.md |
| 184 | + echo "" >> badges.md |
| 185 | + echo "[](https://github.com/${{ github.repository }}/actions/workflows/test.yml)" >> badges.md |
| 186 | + echo "[](https://github.com/${{ github.repository }}/actions/workflows/quality.yml)" >> badges.md |
| 187 | + echo "[](https://github.com/${{ github.repository }}/actions/workflows/docs.yml)" >> badges.md |
| 188 | + echo "[](https://badge.fury.io/py/wifijam)" >> badges.md |
| 189 | + echo "[](https://pypi.org/project/wifijam/)" >> badges.md |
| 190 | + echo "[](https://github.com/${{ github.repository }}/blob/main/LICENSE)" >> badges.md |
| 191 | + |
| 192 | + cat badges.md |
| 193 | +
|
| 194 | + summary: |
| 195 | + name: Documentation Summary |
| 196 | + needs: [check-links, validate-markdown, spell-check, check-readme] |
| 197 | + if: always() |
| 198 | + runs-on: ubuntu-latest |
| 199 | + |
| 200 | + steps: |
| 201 | + - name: Generate summary |
| 202 | + run: | |
| 203 | + echo "# Documentation Quality Summary" >> $GITHUB_STEP_SUMMARY |
| 204 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 205 | + echo "| Check | Status |" >> $GITHUB_STEP_SUMMARY |
| 206 | + echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY |
| 207 | + echo "| Link Check | ${{ needs.check-links.result == 'success' && '✅ Passed' || '⚠️ Warning' }} |" >> $GITHUB_STEP_SUMMARY |
| 208 | + echo "| Markdown Validation | ${{ needs.validate-markdown.result == 'success' && '✅ Passed' || '⚠️ Warning' }} |" >> $GITHUB_STEP_SUMMARY |
| 209 | + echo "| Spell Check | ${{ needs.spell-check.result == 'success' && '✅ Passed' || '⚠️ Warning' }} |" >> $GITHUB_STEP_SUMMARY |
| 210 | + echo "| README Quality | ${{ needs.check-readme.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY |
| 211 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 212 | + echo "## Next Steps" >> $GITHUB_STEP_SUMMARY |
| 213 | + echo "- Review any warnings or failures above" >> $GITHUB_STEP_SUMMARY |
| 214 | + echo "- Fix broken links if any" >> $GITHUB_STEP_SUMMARY |
| 215 | + echo "- Update documentation as needed" >> $GITHUB_STEP_SUMMARY |
| 216 | +
|
0 commit comments