diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000..70f1547 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,29 @@ +name: Docs + +on: + push: + branches: [main] + release: + types: [released] + pull_request: + types: [opened, synchronize] + +jobs: + docs: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Ape Docs + uses: apeworx/sphinx-ape@main + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4ec058b..a0fb12e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,34 @@ pre-commit install Committing will now automatically run the local hooks and ensure that your commit passes all lint checks. +## Running the docs locally + +First, make sure you have the docs-related tooling installed: + +```bash +pip install -e .'[doc]' +``` + +Then, run the following from the root project directory: + +```bash +sphinx-ape build . +``` + +For the best viewing experience, use a local server: + +```bash +sphinx-ape serve . +``` + +Then, open your browser to `127.0.0.1:1337` and click the `ape` directory link. + +You can also use the `--open` flag to automatically open the docs: + +```bash +sphinx-ape serve . --open +``` + ## Pull Requests Pull requests are welcomed! Please adhere to the following: diff --git a/ape_foundry/provider.py b/ape_foundry/provider.py index ae325db..9275370 100644 --- a/ape_foundry/provider.py +++ b/ape_foundry/provider.py @@ -37,7 +37,11 @@ from web3.exceptions import ContractLogicError as Web3ContractLogicError from web3.exceptions import ExtraDataLengthError from web3.gas_strategies.rpc import rpc_gas_price_strategy -from web3.middleware import geth_poa_middleware + +try: + from web3.middleware import ExtraDataToPOAMiddleware # type: ignore +except ImportError: + from web3.middleware import geth_poa_middleware as ExtraDataToPOAMiddleware # type: ignore from web3.middleware.validation import MAX_EXTRADATA_LENGTH from yarl import URL @@ -400,7 +404,7 @@ def check_poa(block_id) -> bool: # Handle if using PoA if any(map(check_poa, (0, "latest"))): - self._web3.middleware_onion.inject(geth_poa_middleware, layer=0) + self._web3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0) def _start(self): if self.is_connected: @@ -786,7 +790,9 @@ def connect(self): logger.error( f"Upstream provider '{upstream_provider.name}' missing Geth PoA middleware." ) - upstream_provider.web3.middleware_onion.inject(geth_poa_middleware, layer=0) + upstream_provider.web3.middleware_onion.inject( + ExtraDataToPOAMiddleware, layer=0 + ) upstream_genesis_block_hash = upstream_provider.get_block(0).hash else: raise FoundryProviderError(f"Unable to get genesis block: {err}.") from err diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..9181c1d --- /dev/null +++ b/docs/conf.py @@ -0,0 +1 @@ +extensions = ["sphinx_ape"] diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..b559066 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1 @@ +.. dynamic-toc-tree:: diff --git a/docs/userguides/quickstart.md b/docs/userguides/quickstart.md new file mode 100644 index 0000000..c7719d8 --- /dev/null +++ b/docs/userguides/quickstart.md @@ -0,0 +1,2 @@ +```{include} ../../README.md +``` diff --git a/setup.py b/setup.py index b25d963..139cd37 100644 --- a/setup.py +++ b/setup.py @@ -32,9 +32,7 @@ "mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml ], "doc": [ - "Sphinx>=6.1.3,<7", # Documentation generator - "sphinx_rtd_theme>=1.2.0,<2", # Readthedocs.org theme - "towncrier>=19.2.0, <20", # Generate release notes + "sphinx-ape", ], "release": [ # `release` GitHub Action job uses this "setuptools", # Installation tool @@ -76,13 +74,13 @@ url="https://github.com/ApeWorX/ape-foundry", include_package_data=True, install_requires=[ - "eth-ape>=0.8.12,<0.9", - "ethpm-types", # Use same version as eth-ape - "eth-pydantic-types", # Use same version as eth-ape - "evm-trace", # Use same version as ape - "web3", # Use same version as ape - "yarl", # Use same version as ape - "hexbytes", # Use same version as ape + "eth-ape>=0.8.21,<0.9", + "ethpm-types>=0.6.19,<0.7", + "eth_pydantic_types>=0.1.3,<0.2", + "evm-trace>=0.2.3,<0.3", + "web3>=6.20.1,<8", + "yarl>=1.9.2,<2", + "hexbytes>=0.3.1,<2", ], python_requires=">=3.9,<4", extras_require=extras_require,