-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Zellic/devdocs-wip
Create user guide and code, documentation site and improve code docs
- Loading branch information
Showing
20 changed files
with
1,474 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,38 @@ | ||
name: gendocs | ||
|
||
on: [push, workflow_dispatch] | ||
|
||
jobs: | ||
gendocs: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
deployments: write | ||
name: Deploy to Cloudflare Pages | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
- name: Set up Python 3.11 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.11" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
pip install sphinx furo sphinx-autoapi sphinx_autodoc_typehints | ||
- name: Sphinx build | ||
run: | | ||
sphinx-build -M html docs/source docs/build | ||
- name: Publish | ||
uses: cloudflare/pages-action@1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: aa2caed8dec0b29b442a9f250bd48ba6 | ||
projectName: docs | ||
directory: docs/build/html | ||
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | ||
wranglerVersion: '3' |
This file contains 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,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.https://www.sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains 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,44 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# For the full list of built-in configuration values, see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Project information ----------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information | ||
|
||
project = 'SOLP' | ||
copyright = '2024, Zellic' | ||
author = 'Zellic' | ||
release = '0.1.16' | ||
|
||
# -- General configuration --------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration | ||
|
||
extensions = [ | ||
'sphinx.ext.autosectionlabel', | ||
'sphinx.ext.autodoc', | ||
'sphinx_autodoc_typehints', | ||
'sphinx.ext.autosummary', | ||
'autoapi.extension' | ||
] | ||
|
||
# Make sure the target is unique | ||
autosectionlabel_prefix_document = True | ||
|
||
autoapi_dirs = ['../../src'] | ||
autoapi_keep_files = True | ||
autoapi_ignore = ['*/grammar/*'] | ||
|
||
templates_path = ['_templates'] | ||
exclude_patterns = [] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output | ||
|
||
html_theme = 'furo' | ||
html_static_path = ['_static'] | ||
|
||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath('../../src')) |
This file contains 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,115 @@ | ||
pragma solidity 0.8.22; | ||
|
||
function selfdestruct(address addr) public { | ||
|
||
} | ||
|
||
function revert(/*error, reason*/) { | ||
// A direct revert can be triggered using the | ||
// revert statement and the revert function. | ||
} | ||
|
||
function assert(bool condition) { | ||
|
||
} | ||
|
||
function require(bool condition /*reason*/) { | ||
// The convenience functions can be used to check for conditions | ||
// and throw an exception if the condition is not met. | ||
} | ||
|
||
struct msg { | ||
uint256 value; | ||
uint256 gas; | ||
address sender; | ||
bytes data; | ||
bytes4 sig; | ||
} | ||
|
||
struct block { | ||
uint256 basefee; | ||
uint256 chainid; | ||
address payable conbase; | ||
uint256 difficulty; | ||
uint256 gaslimit; | ||
uint256 number; | ||
uint256 timestamp; | ||
} | ||
|
||
struct tx { | ||
uint256 gasprice; | ||
address origin; | ||
} | ||
|
||
contract _address { | ||
// balance of the Address in Wei | ||
uint256 balance; | ||
// code at the Address (can be empty) | ||
bytes code; | ||
// the codehash of the Address | ||
bytes32 codehash; | ||
|
||
function call(bytes memory payload) public returns (bool, bytes memory) { | ||
// issue low-level CALL with the given payload, returns | ||
// success condition and return data, forwards all available gas, adjustable | ||
} | ||
|
||
function delegatecall(bytes memory payload) public returns (bool, bytes memory) { | ||
// issue low-level DELEGATECALL with the given payload, returns | ||
// success condition and return data, forwards all available gas, adjustable | ||
} | ||
|
||
function staticcall(bytes memory payload) public returns (bool, bytes memory) { | ||
// issue low-level STATICCALL with the given payload, returns | ||
// success condition and return data, forwards all available gas, adjustable | ||
} | ||
} | ||
|
||
contract _address_payable is _address { | ||
function transfer(uint256 amount) public { | ||
// send given amount of Wei to Address, reverts on failure, | ||
// forwards 2300 gas stipend, not adjustable | ||
} | ||
|
||
function send(uint256 amount) public returns (bool) { | ||
// send given amount of Wei to Address, returns false on | ||
// failure, forwards 2300 gas stipend, not adjustable | ||
} | ||
} | ||
|
||
library abi { | ||
function encode(/*varargs*/) public returns (bytes memory) { | ||
// ABI encodes the arguments to bytes. Any number of arguments can be provided. | ||
} | ||
|
||
function encodePacked(/*varargs*/) public returns (bytes memory) { | ||
// ABI encodes the arguments to bytes. Any number of arguments can be | ||
// provided. The packed encoding only encodes the raw data, not the | ||
// lengths of strings and arrays. For example, when encoding string only | ||
// the string bytes will be encoded, not the length. It is not possible | ||
// to decode packed encoding. | ||
} | ||
|
||
function encodeWithSelector(bytes4 selector /*, varargs*/) public returns (bytes memory) { | ||
// ABI encodes the arguments with the function selector, which is known as the discriminator | ||
// on Solana. After the selector, any number of arguments can be provided. | ||
} | ||
|
||
function encodeWithSignature(string memory signature /*, varargs*/) public returns (bytes memory) { | ||
// ABI encodes the arguments with the hash of the signature. After the signature, | ||
// any number of arguments can be provided. | ||
} | ||
|
||
function encodeCall(/*function pointer, tuple of arguments*/) public returns (bytes memory) { | ||
// ABI encodes the function call to the function which should be specified | ||
// as ContractName.FunctionName. The arguments are cast and checked against | ||
// the function specified as the first argument. The arguments must be in a | ||
// tuple, e.g. (a, b, c). If there is a single argument no tuple is required. | ||
} | ||
|
||
function decode(bytes memory encodedData /*(types)*/) public /*returns (args)*/ { | ||
// This function decodes the first argument and returns the decoded fields. | ||
// type-list is a comma-separated list of types. If multiple values are | ||
// decoded, then a destructure statement must be used. | ||
} | ||
} |
This file contains 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,45 @@ | ||
Client Setup | ||
=============== | ||
|
||
.. note:: | ||
Before installing SOLP, follow the instructions in the :doc:`prereq` document. | ||
|
||
Who Is This Document For? | ||
^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
This is for people who want to use SOLP in their own projects. | ||
|
||
Set Up a Virtual Environment (Optional) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
It's always recommended to set up a virtual environment (venv) instead of installing the package in the global pip cache. | ||
|
||
Create a venv called ``venv``. | ||
|
||
.. code-block:: bash | ||
python -m venv venv | ||
Then activate the venv. | ||
|
||
Unix: | ||
|
||
.. code-block:: bash | ||
./venv/Scripts/activate | ||
Windows: | ||
|
||
.. code-block:: powershell | ||
.\venv\Scripts\activate | ||
Installing | ||
^^^^^^^^^^ | ||
|
||
Finally, install the SOLP python package, | ||
|
||
.. code-block:: bash | ||
pip install <solp> | ||
where ``<solp>`` is a path to a clone of the repository or ``git+https://github.com/Zellic/solidity-parser.git``. |
This file contains 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,13 @@ | ||
Getting Started | ||
=============== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
prereq | ||
clients | ||
quickstart | ||
twoASTs | ||
sourcecode | ||
scopes | ||
vfshooks |
This file contains 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,40 @@ | ||
Prerequisites | ||
============= | ||
|
||
Software Requirements | ||
--------------------- | ||
|
||
Python 3.11+ | ||
~~~~~~~~~~~~~ | ||
|
||
To run this software, you need Python version 3.11 or higher installed on your system. If you haven't installed Python | ||
yet, you can download it from the official Python website: | ||
|
||
https://www.python.org/downloads/ | ||
|
||
Java 8+ (for ANTLR grammar stub generation) | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
For generating ANTLR grammar stubs, you need Java version 8 or higher installed on your system. There are multiple | ||
implementations available, but we recommend this one: | ||
|
||
https://adoptopenjdk.net/releases.html | ||
|
||
After installing Java, make sure to set the ``JAVA_HOME`` environment variable to the JDK installation directory and | ||
``PATH`` to the ``bin`` directory of the JDK installation. | ||
|
||
Once you have both Python and Java installed, you can proceed with the installation of the software. | ||
|
||
Resolving Conflicts | ||
^^^^^^^^^^^^^^^^^^^ | ||
|
||
Currently, SOLP is only available on `GitHub <https://github.com/Zellic/solidity-parser>`_, and when installed, has the | ||
module name solidity-parser. Unfortunately, there is already a module with the same name in PyPI, which can be the | ||
cause of problems if accidentally installed. | ||
|
||
Therefore, it's recommended that you first run this command globally (outside of an activated virtual environment) to | ||
remove packages that can conflict with SOLP. | ||
|
||
.. code-block:: bash | ||
pip uninstall solidity-parser |
Oops, something went wrong.