Generate AI Documentation #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate AI Documentation | |
| # This workflow generates the documentation from the foundry template using repomix and wavs-wasi-utils from the crate docs. llms.txt and other files are generated by a different component. | |
| on: | |
| schedule: | |
| - cron: '0 0 */2 * *' # Runs every 2 days at midnight UTC | |
| push: | |
| branches: | |
| - main | |
| - repomix | |
| workflow_dispatch: # Allows manual triggering | |
| jobs: | |
| generate-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.DOCS_PAT }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install Repomix | |
| run: npm install -g repomix | |
| - name: Generate WAVS Foundry Template Documentation | |
| run: | | |
| repomix --remote Lay3rLabs/wavs-foundry-template -o public/wavs-foundry-template.md --style markdown | |
| # Add source URL at the top of the file | |
| echo -e "Source: https://github.com/Lay3rLabs/wavs-foundry-template\n\n$(cat public/wavs-foundry-template.md)" > public/wavs-foundry-template.md | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Install rustdoc-md | |
| run: cargo install rustdoc-md | |
| - name: Generate Rust Crate Documentation | |
| run: | | |
| # Clone the wavs-wasi repo using the token | |
| git clone https://${{ secrets.DOCS_PAT }}@github.com/Lay3rLabs/wavs-wasi.git | |
| cd wavs-wasi | |
| # Generate rustdoc JSON for wavs-wasi-utils | |
| echo "Generating rustdoc JSON for wavs-wasi-utils..." | |
| cd packages/wavs-wasi-utils | |
| # Generate documentation with JSON output | |
| RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="-Z unstable-options --output-format json" cargo doc --document-private-items --no-deps --target-dir target | |
| # List contents of target/doc to debug | |
| echo "Contents of target/doc:" | |
| ls -la target/doc/ | |
| # Convert to Markdown | |
| if [ -f "target/doc/wavs_wasi_utils.json" ]; then | |
| echo "Found JSON file, converting to Markdown..." | |
| rustdoc-md --path target/doc/wavs_wasi_utils.json --output ../../../public/wavs-wasi-utils.md | |
| # Add source URL at the top of the file | |
| echo -e "Source: https://docs.rs/wavs-wasi-utils/latest/wavs_wasi_utils/\n\n$(cat ../../../public/wavs-wasi-utils.md)" > ../../../public/wavs-wasi-utils.md | |
| else | |
| echo "wavs_wasi_utils.json not found in target/doc/" | |
| echo "Contents of target/:" | |
| ls -R target/ | |
| exit 1 | |
| fi | |
| # Clean up wavs-wasi | |
| cd ../../.. | |
| rm -rf wavs-wasi | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add public/wavs-wasi-utils.md public/wavs-foundry-template.md | |
| git commit -m "Update documentation" || exit 0 | |
| git push |