Skip to content
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

chore: default to main branch for docs #392

Merged
merged 2 commits into from
Oct 16, 2024
Merged

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Oct 15, 2024

forge doc outputs docs with a git commit hash in the URL, which is good, because it points to a specific version of a file. However, this makes it so that every time the docs are generated, the hash changes, so we can't reliably track if something has changed in the docs (we use this to automatically update protocol docs on the docs website).

Screenshot 2024-10-15 at 15 30 13

This PR updates the script to replace commit hash-based URLs with URLs pointing to main to ensure we can use git diff to check for changes in the docs.

Copy link
Contributor

coderabbitai bot commented Oct 15, 2024

📝 Walkthrough

Walkthrough

The generate_docs.sh script has been updated to improve the documentation generation process. Key modifications include the introduction of a find command that searches for Markdown files in the docs/src/ directory to update URLs pointing to the GitHub repository for protocol contracts, changing them to the main/v2/ branch. Additionally, a cleanup step has been added to remove backup files with a .bak extension created during the URL replacement. The core functionality for generating documentation remains unchanged.

Changes

File Change Summary
v2/scripts/generate_docs.sh Modified to add a command for updating URLs in Markdown files and a cleanup step for .bak files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script
    participant MarkdownFiles

    User->>Script: Execute generate_docs.sh
    Script->>MarkdownFiles: Find all Markdown files
    MarkdownFiles-->>Script: Return list of Markdown files
    Script->>MarkdownFiles: Update URLs to main/v2/
    Script->>Script: Remove .bak backup files
    Script-->>User: Documentation generation complete
Loading

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f7f6d9f and ee2fdaf.

⛔ Files ignored due to path filters (36)
  • v2/docs/src/contracts/Revert.sol/interface.Revertable.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/Revert.sol/struct.RevertContext.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/Revert.sol/struct.RevertOptions.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/ERC20Custody.sol/contract.ERC20Custody.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/GatewayEVM.sol/contract.GatewayEVM.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/ZetaConnectorBase.sol/abstract.ZetaConnectorBase.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/ZetaConnectorNative.sol/contract.ZetaConnectorNative.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/ZetaConnectorNonNative.sol/contract.ZetaConnectorNonNative.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20Custody.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyErrors.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IERC20Custody.sol/interface.IERC20CustodyEvents.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.Callable.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVM.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMErrors.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/interface.IGatewayEVMEvents.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IGatewayEVM.sol/struct.MessageContext.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IZetaConnector.sol/interface.IZetaConnectorEvents.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/evm/interfaces/IZetaNonEthNew.sol/interface.IZetaNonEthNew.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/GatewayZEVM.sol/contract.GatewayZEVM.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/SystemContract.sol/contract.SystemContract.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/SystemContract.sol/interface.SystemContractErrors.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/ZRC20.sol/contract.ZRC20.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/ZRC20.sol/interface.ZRC20Errors.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVM.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMErrors.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/interface.IGatewayZEVMEvents.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IGatewayZEVM.sol/struct.CallOptions.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/ISystem.sol/interface.ISystem.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IWZETA.sol/interface.IWETH9.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/enum.CoinType.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.IZRC20Metadata.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/IZRC20.sol/interface.ZRC20Events.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.UniversalContract.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/interface.zContract.md is excluded by !v2/docs/**
  • v2/docs/src/contracts/zevm/interfaces/UniversalContract.sol/struct.zContext.md is excluded by !v2/docs/**
📒 Files selected for processing (1)
  • v2/scripts/generate_docs.sh (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
v2/scripts/generate_docs.sh (1)

15-17: LGTM! Consider adding error handling and selective URL updates.

The changes align well with the PR objective to default to the main branch for docs. The URL update and cleanup process are implemented correctly. However, consider the following suggestions:

  1. Add error handling and reporting for both commands. This will help identify issues if the commands fail.

  2. Consider the possibility that not all URLs should be updated to 'main/v2/'. You might want to implement a more selective approach or add a comment explaining why all URLs are being updated.

Here's a suggested improvement with error handling:

-find docs/src/ -type f -name "*.md" -exec sed -i.bak -E 's|(https://github.com/zeta-chain/protocol-contracts/blob/)[^/]+/|\1main/v2/|g' {} +
+if ! find docs/src/ -type f -name "*.md" -exec sed -i.bak -E 's|(https://github.com/zeta-chain/protocol-contracts/blob/)[^/]+/|\1main/v2/|g' {} +; then
+    echo "Error: Failed to update URLs in Markdown files" >&2
+    exit 1
+fi

-find docs/src/ -type f -name "*.bak" -exec rm {} +
+if ! find docs/src/ -type f -name "*.bak" -exec rm {} +; then
+    echo "Error: Failed to remove backup files" >&2
+    exit 1
+fi

Let's verify the impact of these changes on the entire documentation process:

✅ Verification successful

Verified! All Markdown files have their URLs correctly updated to 'main/v2/', and no backup (.bak) files remain. The index.md file exists and is in the expected state.

  • No URLs outside of main/v2/ were found in the Markdown files.
  • Backup files have been successfully removed.
  • v2/docs/src/index.md is present and properly initialized.
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of URL changes on the documentation

# Test 1: Check if any URLs were not updated
echo "Checking for any remaining non-main/v2 URLs:"
rg -i 'https://github.com/zeta-chain/protocol-contracts/blob/(?!main/v2)' docs/src/

# Test 2: Ensure no .bak files remain
echo "Checking for any remaining .bak files:"
find docs/src/ -name "*.bak"

# Test 3: Verify the structure of the docs/src directory
echo "Listing the structure of the docs/src directory:"
tree docs/src/ -L 2

# Test 4: Check if index.md was properly generated
echo "Checking if index.md exists and its first few lines:"
head -n 5 docs/src/index.md

Length of output: 1076


Script:

#!/bin/bash
# Description: Locate all Markdown files in the repository

echo "Finding all Markdown files (.md) in the repository:"
fd -e md

Length of output: 9066


Script:

#!/bin/bash
# Description: Check for any URLs not pointing to 'main/v2/' in Markdown files

echo "Checking for URLs that do not point to 'main/v2/':"
fd -e md -x rg -i 'https://github.com/zeta-chain/protocol-contracts/blob/(?!main/v2)/' {}

Length of output: 41358


Script:

#!/bin/bash
# Description: Verify the existence and content of index.md

echo "Verifying the existence of index.md:"
fd -e md -x ls {} | grep 'index.md'

echo "Displaying the first 5 lines of index.md if it exists:"
head -n 5 $(fd -e md | grep 'index.md') 2>/dev/null || echo "index.md does not exist."

Length of output: 404


Script:

#!/bin/bash
# Description: Locate all Markdown files in the v2/docs/src/ directory

echo "Finding all Markdown files (.md) in v2/docs/src/:"
fd -e md v2/docs/src/

Length of output: 486


Script:

#!/bin/bash
# Description: Extract URLs from Markdown files and identify those not pointing to 'main/v2/'

echo "Extracting URLs that do not point to 'main/v2/':"
fd -e md v2/docs/src/ -x grep -o 'https://github.com/zeta-chain/protocol-contracts/blob/[^)\s]+' {} | grep -v 'https://github.com/zeta-chain/protocol-contracts/blob/main/v2/'

Length of output: 643


Script:

#!/bin/bash
# Description: Verify the creation and removal of .bak files

echo "Checking for any remaining .bak files in v2/docs/src/:"
find v2/docs/src/ -type f -name "*.bak"

Length of output: 160


Script:

#!/bin/bash
# Description: Verify the integrity of index.md

echo "Verifying the first 5 lines of v2/docs/src/index.md:"
head -n 5 v2/docs/src/index.md

Length of output: 227


Script:

#!/bin/bash
# Description: Locate all Markdown files in the v2/docs/src/ directory using correct fd syntax

echo "Finding all Markdown files (.md) in v2/docs/src/:"
fd -e md . v2/docs/src/

Length of output: 3130


Script:

#!/bin/bash
# Description: Extract URLs from Markdown files and identify those not pointing to 'main/v2/' without using look-around

echo "Extracting URLs that do not point to 'main/v2/':"
fd -e md . v2/docs/src/ -x grep -o 'https://github.com/zeta-chain/protocol-contracts/blob/[a-zA-Z0-9_/.-]\+' {} | grep -v 'https://github.com/zeta-chain/protocol-contracts/blob/main/v2/'

Length of output: 301


Script:

#!/bin/bash
# Description: Verify the creation and removal of .bak files in v2/docs/src/

echo "Checking for any remaining .bak files in v2/docs/src/:"
find v2/docs/src/ -type f -name "*.bak"

Length of output: 160


Script:

#!/bin/bash
# Description: Verify the integrity of index.md

echo "Verifying the first 5 lines of v2/docs/src/index.md:"
head -n 5 v2/docs/src/index.md

Length of output: 227


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.95%. Comparing base (f29829e) to head (0c01f2e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #392   +/-   ##
=======================================
  Coverage   84.95%   84.95%           
=======================================
  Files           8        8           
  Lines         412      412           
  Branches      138      138           
=======================================
  Hits          350      350           
  Misses         62       62           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@GMaiolo GMaiolo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@lumtis lumtis merged commit a675f8a into main Oct 16, 2024
11 checks passed
@lumtis lumtis deleted the yarn-docs-default-to-main branch October 16, 2024 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants