-
Notifications
You must be signed in to change notification settings - Fork 9
fix: update docgen templates and automate API reference generation #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
stevep0z
wants to merge
11
commits into
main
Choose a base branch
from
fix/docgen-template-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
124946f
fix: update docgen templates with strict reference matching and outpu…
stevep0z 34b09b7
docs: regenerate API reference for contracts 5.x and community-contracts
stevep0z cd2d32e
feat: collapsible inherited functions in API reference TOC sections
stevep0z c14adac
feat: add template injection to generate-api-docs.js
stevep0z 5ac92e2
docs: regenerate all API references using updated script
stevep0z 3fb6a62
feat: add receiver workflows for contracts and confidential-contracts
stevep0z 388812e
feat: add link validation to community-contracts receiver workflow
stevep0z 814a708
chore: add temp-* to gitignore for generate-api-docs cleanup
stevep0z bf31e1b
feat: add --pre-generated flag for non-Solidity source repos
stevep0z 6692a23
docs: update README with API reference generation workflow
stevep0z 80a979a
fix: address security scan findings in workflows and scripts
stevep0z File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
165 changes: 165 additions & 0 deletions
165
.github/workflows/generate-api-docs-confidential-contracts.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,165 @@ | ||
| # Docs Repository Receiver - Non-Versioned Paths | ||
| # Receives trigger from openzeppelin-confidential-contracts and generates API docs | ||
|
|
||
| name: Generate API Docs - Confidential Contracts | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag_name: | ||
| description: 'Tag name or commit SHA to generate docs from' | ||
| required: true | ||
| type: string | ||
| default: 'v0.4.0' | ||
| trigger_type: | ||
| description: 'Trigger type (tag or commit)' | ||
| required: false | ||
| type: string | ||
| default: 'tag' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| env: | ||
| SOURCE_REPO: 'OpenZeppelin/openzeppelin-confidential-contracts' | ||
| SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-confidential-contracts.git' | ||
| BASE_OUTPUT_PATH: 'content/confidential-contracts' | ||
| USE_VERSIONED_PATHS: 'false' | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Log trigger information | ||
| run: | | ||
| echo "🚀 API Documentation Generation Triggered" | ||
| echo "📦 Repository: ${{ env.SOURCE_REPO }}" | ||
| echo "🏷️ Tag/Ref: ${{ inputs.tag_name }}" | ||
| echo "📋 Trigger type: ${{ inputs.trigger_type }}" | ||
|
|
||
| - name: Checkout docs repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.17.1 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Determine output directory | ||
| id: config | ||
| run: | | ||
| TAG_NAME="${{ inputs.tag_name }}" | ||
| TRIGGER_TYPE="${{ inputs.trigger_type }}" | ||
| BASE_PATH="${{ env.BASE_OUTPUT_PATH }}" | ||
| USE_VERSIONED="${{ env.USE_VERSIONED_PATHS }}" | ||
|
|
||
| if [[ "$USE_VERSIONED" == "false" ]]; then | ||
| OUTPUT_DIR="${BASE_PATH}/api" | ||
| echo "📁 Using non-versioned path" | ||
| elif [[ "$TRIGGER_TYPE" == "commit" ]]; then | ||
| OUTPUT_DIR="${BASE_PATH}/latest/api" | ||
| echo "🔄 Using latest path for commit-based trigger" | ||
| else | ||
| if [[ "$TAG_NAME" =~ v([0-9]+) ]]; then | ||
| MAJOR_VERSION="${BASH_REMATCH[1]}" | ||
| OUTPUT_DIR="${BASE_PATH}/${MAJOR_VERSION}.x/api" | ||
| echo "📊 Detected version: ${MAJOR_VERSION}.x" | ||
| else | ||
| OUTPUT_DIR="${BASE_PATH}/latest/api" | ||
| echo "⚠️ Non-standard tag format, using latest" | ||
| fi | ||
| fi | ||
|
|
||
| echo "📂 Output directory: $OUTPUT_DIR" | ||
| echo "output-dir=$OUTPUT_DIR" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Generate API Documentation | ||
| run: | | ||
| echo "🔄 Generating API documentation..." | ||
|
|
||
| node scripts/generate-api-docs.js \ | ||
| --repo "${{ env.SOURCE_REPO_URL }}" \ | ||
| --branch "${{ inputs.tag_name }}" \ | ||
| --api-output "${{ steps.config.outputs.output-dir }}" | ||
|
|
||
| - name: Validate generated documentation | ||
| run: | | ||
| pnpm run postinstall | ||
| pnpm run lint:links | ||
|
|
||
| - name: Create Pull Request for documentation changes | ||
| id: create_pr | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| git config --local user.email "docs-automation@openzeppelin.com" | ||
| git config --local user.name "OpenZeppelin Docs Bot" | ||
|
|
||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "📝 Creating branch and committing documentation changes..." | ||
|
|
||
| BRANCH_NAME="docs/api-update-${{ env.SOURCE_REPO }}-${{ inputs.tag_name }}" | ||
| BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//-/g' | sed 's/OpenZeppelin-//g') | ||
|
|
||
| git checkout -b "$BRANCH_NAME" | ||
| git add . | ||
| git commit -m "Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }} | ||
|
|
||
| - Repository: ${{ env.SOURCE_REPO }} | ||
| - Ref: ${{ inputs.tag_name }} | ||
| - Trigger: ${{ inputs.trigger_type }} | ||
| - Output: ${{ steps.config.outputs.output-dir }} | ||
| - Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC') | ||
|
|
||
| Auto-generated via workflow_dispatch" | ||
|
|
||
| git push origin "$BRANCH_NAME" | ||
|
|
||
| gh pr create --title "[CI] Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }}" \ | ||
| --body "## API Documentation Update | ||
|
|
||
| This Pull Request updates the API documentation. | ||
|
|
||
| ### Source Information | ||
| - **Repository:** ${{ env.SOURCE_REPO }} | ||
| - **Reference:** ${{ inputs.tag_name }} | ||
| - **Trigger Type:** ${{ inputs.trigger_type }} | ||
| - **Output Directory:** ${{ steps.config.outputs.output-dir }} | ||
| - **Timestamp:** $(date -u '+%Y-%m-%d %H:%M:%S UTC') | ||
|
|
||
| Auto-generated via workflow_dispatch" \ | ||
| --base main \ | ||
| --head "$BRANCH_NAME" || echo "⚠️ Pull Request creation failed" | ||
|
|
||
| echo "✅ Pull Request created successfully" | ||
| echo "pr-created=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "ℹ️ No changes detected - documentation is up to date" | ||
| echo "pr-created=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create job summary | ||
| run: | | ||
| echo "## 📚 API Documentation Generation Complete" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Source Information" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Repository:** ${{ env.SOURCE_REPO }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Reference:** ${{ inputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Trigger Type:** ${{ inputs.trigger_type }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Output" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Directory:** ${{ steps.config.outputs.output-dir }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Status:** ✅ Complete" >> $GITHUB_STEP_SUMMARY | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # Docs Repository Receiver - Versioned Paths | ||
| # Receives trigger from openzeppelin-contracts and generates API docs | ||
|
|
||
| name: Generate API Docs - Contracts | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag_name: | ||
| description: 'Tag name or commit SHA to generate docs from' | ||
| required: true | ||
| type: string | ||
| default: 'v5.6.1' | ||
| trigger_type: | ||
| description: 'Trigger type (tag or commit)' | ||
| required: false | ||
| type: string | ||
| default: 'tag' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| env: | ||
| SOURCE_REPO: 'OpenZeppelin/openzeppelin-contracts' | ||
| SOURCE_REPO_URL: 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' | ||
| BASE_OUTPUT_PATH: 'content/contracts' | ||
| USE_VERSIONED_PATHS: 'true' | ||
|
|
||
| jobs: | ||
| generate-docs: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Log trigger information | ||
| run: | | ||
| echo "🚀 API Documentation Generation Triggered" | ||
| echo "📦 Repository: ${{ env.SOURCE_REPO }}" | ||
| echo "🏷️ Tag/Ref: ${{ inputs.tag_name }}" | ||
| echo "📋 Trigger type: ${{ inputs.trigger_type }}" | ||
|
|
||
| - name: Checkout docs repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.17.1 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Determine output directory | ||
| id: config | ||
| run: | | ||
| TAG_NAME="${{ inputs.tag_name }}" | ||
| TRIGGER_TYPE="${{ inputs.trigger_type }}" | ||
| BASE_PATH="${{ env.BASE_OUTPUT_PATH }}" | ||
| USE_VERSIONED="${{ env.USE_VERSIONED_PATHS }}" | ||
|
|
||
| if [[ "$USE_VERSIONED" == "false" ]]; then | ||
| OUTPUT_DIR="${BASE_PATH}/api" | ||
| echo "📁 Using non-versioned path" | ||
| elif [[ "$TRIGGER_TYPE" == "commit" ]]; then | ||
| OUTPUT_DIR="${BASE_PATH}/latest/api" | ||
| echo "🔄 Using latest path for commit-based trigger" | ||
| else | ||
| # Extract major version from tag (v5.6.1 -> 5, v5.6.0 -> 5) | ||
| if [[ "$TAG_NAME" =~ v([0-9]+) ]]; then | ||
| MAJOR_VERSION="${BASH_REMATCH[1]}" | ||
| OUTPUT_DIR="${BASE_PATH}/${MAJOR_VERSION}.x/api" | ||
| echo "📊 Detected version: ${MAJOR_VERSION}.x" | ||
| else | ||
| OUTPUT_DIR="${BASE_PATH}/latest/api" | ||
| echo "⚠️ Non-standard tag format, using latest" | ||
| fi | ||
| fi | ||
|
|
||
| echo "📂 Output directory: $OUTPUT_DIR" | ||
| echo "output-dir=$OUTPUT_DIR" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Generate API Documentation | ||
| run: | | ||
| echo "🔄 Generating API documentation..." | ||
|
|
||
| node scripts/generate-api-docs.js \ | ||
| --repo "${{ env.SOURCE_REPO_URL }}" \ | ||
| --branch "${{ inputs.tag_name }}" \ | ||
| --api-output "${{ steps.config.outputs.output-dir }}" | ||
|
|
||
| - name: Validate generated documentation | ||
| run: | | ||
| pnpm run postinstall | ||
| pnpm run lint:links | ||
|
|
||
| - name: Create Pull Request for documentation changes | ||
| id: create_pr | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| git config --local user.email "docs-automation@openzeppelin.com" | ||
| git config --local user.name "OpenZeppelin Docs Bot" | ||
|
|
||
| if [ -n "$(git status --porcelain)" ]; then | ||
| echo "📝 Creating branch and committing documentation changes..." | ||
|
|
||
| BRANCH_NAME="docs/api-update-${{ env.SOURCE_REPO }}-${{ inputs.tag_name }}" | ||
| BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//-/g' | sed 's/OpenZeppelin-//g') | ||
|
|
||
| git checkout -b "$BRANCH_NAME" | ||
| git add . | ||
| git commit -m "Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }} | ||
|
|
||
| - Repository: ${{ env.SOURCE_REPO }} | ||
| - Ref: ${{ inputs.tag_name }} | ||
| - Trigger: ${{ inputs.trigger_type }} | ||
| - Output: ${{ steps.config.outputs.output-dir }} | ||
| - Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC') | ||
|
|
||
| Auto-generated via workflow_dispatch" | ||
|
|
||
| git push origin "$BRANCH_NAME" | ||
|
|
||
| gh pr create --title "[CI] Update API docs for ${{ env.SOURCE_REPO }} ${{ inputs.tag_name }}" \ | ||
| --body "## API Documentation Update | ||
|
|
||
| This Pull Request updates the API documentation. | ||
|
|
||
| ### Source Information | ||
| - **Repository:** ${{ env.SOURCE_REPO }} | ||
| - **Reference:** ${{ inputs.tag_name }} | ||
| - **Trigger Type:** ${{ inputs.trigger_type }} | ||
| - **Output Directory:** ${{ steps.config.outputs.output-dir }} | ||
| - **Timestamp:** $(date -u '+%Y-%m-%d %H:%M:%S UTC') | ||
|
|
||
| Auto-generated via workflow_dispatch" \ | ||
| --base main \ | ||
| --head "$BRANCH_NAME" || echo "⚠️ Pull Request creation failed" | ||
|
|
||
| echo "✅ Pull Request created successfully" | ||
| echo "pr-created=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "ℹ️ No changes detected - documentation is up to date" | ||
| echo "pr-created=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Create job summary | ||
| run: | | ||
| echo "## 📚 API Documentation Generation Complete" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Source Information" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Repository:** ${{ env.SOURCE_REPO }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Reference:** ${{ inputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Trigger Type:** ${{ inputs.trigger_type }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "### Output" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Directory:** ${{ steps.config.outputs.output-dir }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "- **Status:** ✅ Complete" >> $GITHUB_STEP_SUMMARY | ||
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
|
||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.