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

docs: overhaul docs #350

Merged
merged 6 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: docs
on:
push:

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
env:
PUBLISH: ${{ contains(fromJSON('["master", "main"]'), github.ref_name) && 'true' || 'false' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
cache: 'pip'
- uses: actions/cache@v4
with:
key: ${{ github.ref }} # cache by branch
path: .cache
- run: pip install -r requirements.txt

- run: mkdocs build
if: env.PUBLISH == 'false'

- uses: actions/upload-artifact@v4
if: env.PUBLISH == 'false'
with:
name: site
path: site

- run: mkdocs gh-deploy --force
if: env.PUBLISH == 'true'
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ build:
# rust: "1.64"
# golang: "1.19"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Build documentation in the docs/ directory with mkdocs
mkdocs:
configuration: mkdocs.yml

# Explicitly set the version of Python and its requirements
python:
Expand Down
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

Empty file.
29 changes: 29 additions & 0 deletions docs/api/cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Cache

## `set_cache_dir`

!!! function "`boa.interpret.set_cache_dir()`"
<a href="https://github.com/vyperlang/titanoboa/blob/v0.2.4/boa/interpret.py#L53-L59" class="source-code-link" target="_blank" rel="noopener"></a>

**Description**

Set the cache directory for the Vyper compilation results.
By default, this is set to `~/.cache/titanoboa`.
In case the directory is `None`, the cache will be disabled.

---

**Parameters**

- `cache_dir`: The directory to store the cache files.

---

## `disable_cache`

!!! function "`boa.interpret.disable_cache()`"
<a href="https://github.com/vyperlang/titanoboa/blob/v0.2.4/boa/interpret.py#L62-L63" class="source-code-link" target="_blank" rel="noopener"></a>

**Description**

Set the cache directory for the Vyper compilation results.
30 changes: 30 additions & 0 deletions docs/api/common_classes/_BaseEVMContract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# `_BaseEVMContract`

### Description

The `_BaseEVMContract` class provides the base functionality for EVM contracts. It includes methods for handling contract deployment, execution, and interaction.

### Methods

- [stack_trace](stack_trace.md)
- [call_trace](call_trace.md)
- [handle_error](handle_error.md)

### Properties

- [address](address.md)

### Examples

```python
>>> import boa
>>> src = """
... @external
... def main():
... pass
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> type(contract)
<class 'boa.vyper.contract.VyperContract'>
```
26 changes: 26 additions & 0 deletions docs/api/common_classes/_BaseVyperContract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# `_BaseVyperContract`

### Description

The `_BaseVyperContract` class extends `_BaseEVMContract` and provides additional functionality specific to Vyper contracts. It includes methods for handling Vyper-specific features such as ABI encoding/decoding, event handling, and more.

### Methods

- [deployer](deployer.md)
- [abi](abi.md)
- [_constants](_constants.md)

### Examples

```python
>>> import boa
>>> src = """
... @external
... def main():
... pass
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> type(contract)
<class 'boa.vyper.contract.VyperContract'>
```
27 changes: 27 additions & 0 deletions docs/api/common_classes/_constants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# `_constants`

### Property

```python
@property
_constants: ConstantsModel
```

### Description

Provides access to the constants defined in the Vyper contract.

- Returns: A `ConstantsModel` instance.

### Examples

```python
>>> import boa
>>> src = """
... x: constant(uint256) = 123
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> contract._constants.x
123
```
30 changes: 30 additions & 0 deletions docs/api/common_classes/abi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# `abi`

### Property

```python
@property
abi: dict
```

### Description

Returns the ABI (Application Binary Interface) of the Vyper contract.

- Returns: A dictionary representing the ABI of the contract.

### Examples

```python
>>> import boa
>>> src = """
... @external
... def main():
... pass
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> contract_abi = contract.abi
>>> type(contract_abi)
<class 'dict'>
```
Empty file.
33 changes: 33 additions & 0 deletions docs/api/common_classes/call_trace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# `call_trace`

<!-- TODO: Format this with !!!function syntax -->

### Signature

```python
call_trace() -> TraceFrame
```

### Description

Returns the call trace of the computation.

- Returns: A `TraceFrame` instance.

### Examples

!!! python

```python
>>> import boa
>>> src = """
... @external
... def main():
... pass
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> contract.main()
>>> contract.call_trace()
<TraceFrame ...>
```
Empty file.
1 change: 1 addition & 0 deletions docs/api/common_classes/handle_error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO
33 changes: 33 additions & 0 deletions docs/api/common_classes/stack_trace.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# `stack_trace`

### Signature

```python
stack_trace(computation: ComputationAPI) -> StackTrace
```

### Description

Returns the stack trace of the computation.

- `computation`: The computation to get the stack trace for.
- Returns: A `StackTrace` instance.

### Examples

```python
>>> import boa
>>> src = """
... @external
... def main():
... assert False, "error"
... """
>>> deployer = boa.loads_partial(src, name="Foo")
>>> contract = deployer.deploy()
>>> try:
... contract.main()
... except:
... pass
>>> contract.stack_trace(contract._computation)
<StackTrace ...>
```
5 changes: 5 additions & 0 deletions docs/api/env/browser_env.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# BrowserEnv

Inherits: [`NetworkEnv`](network_env.md)

<!-- TODO: Document BrowserEnv API -->
Loading
Loading