Skip to content

Commit 4065238

Browse files
danceratopzCarsons-Eels
authored andcommitted
feat(docs): auto-generate a page showing fill's command-line options (ethereum#1747)
1 parent ea1480b commit 4065238

File tree

4 files changed

+117
-75
lines changed

4 files changed

+117
-75
lines changed

docs/filling_tests/filling_tests_command_line.md

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -111,78 +111,4 @@ To list the options that only specific to fill, use:
111111
fill --help
112112
```
113113

114-
Output:
115-
116-
```text
117-
usage: fill [-h] [--strict-alloc] [--ca-start CA_START] [--ca-incr CA_INCR]
118-
[--evm-code-type EVM_CODE_TYPE] [--solc-bin SOLC_BIN] [--solc-version SOLC_VERSION]
119-
[--evm-bin EVM_BIN] [--traces] [--verify-fixtures]
120-
[--verify-fixtures-bin VERIFY_FIXTURES_BIN] [--filler-path FILLER_PATH] [--output OUTPUT]
121-
[--flat-output] [--single-fixture-per-file] [--no-html] [--build-name BUILD_NAME]
122-
[--skip-index SKIP_INDEX] [--block-gas-limit BLOCK_GAS_LIMIT] [--evm-dump-dir EVM_DUMP_DIR]
123-
[--skip-evm-dump] [--forks] [--fork FORK] [--from FROM] [--until UNTIL]
124-
125-
options:
126-
-h, --help show this help message and exit
127-
128-
Arguments defining pre-allocation behavior during test filling.:
129-
--strict-alloc [DEBUG ONLY] Disallows deploying a contract in a predefined address.
130-
--ca-start, --contract-address-start CA_START
131-
The starting address from which tests will deploy contracts.
132-
--ca-incr, --contract-address-increment CA_INCR
133-
The address increment value to each deployed contract by a test.
134-
--evm-code-type EVM_CODE_TYPE
135-
Type of EVM code to deploy in each test by default.
136-
137-
Arguments defining the solc executable:
138-
--solc-bin SOLC_BIN Path to a solc executable (for Yul source compilation). No default; if
139-
unspecified `--solc-version` is used.
140-
--solc-version SOLC_VERSION
141-
Version of the solc compiler to use. Default: 0.8.24.
142-
143-
Arguments defining evm executable behavior:
144-
--evm-bin EVM_BIN Path to an evm executable (or name of an executable in the PATH) that provides
145-
`t8n`. Default: `ethereum-spec-evm-resolver`.
146-
--traces Collect traces of the execution information from the transition tool.
147-
--verify-fixtures Verify generated fixture JSON files using geth's evm blocktest command. By
148-
default, the same evm binary as for the t8n tool is used. A different (geth) evm
149-
binary may be specified via --verify-fixtures-bin, this must be specified if
150-
filling with a non-geth t8n tool that does not support blocktest.
151-
--verify-fixtures-bin VERIFY_FIXTURES_BIN
152-
Path to an evm executable that provides the `blocktest` command. Default: The
153-
first (geth) 'evm' entry in PATH.
154-
155-
Arguments defining filler location and output:
156-
--filler-path FILLER_PATH
157-
Path to filler directives
158-
--output OUTPUT Directory path to store the generated test fixtures. If the specified path ends
159-
in '.tar.gz', then the specified tarball is additionally created (the fixtures
160-
are still written to the specified path without the '.tar.gz' suffix). Can be
161-
deleted. Default: './fixtures'.
162-
--flat-output Output each test case in the directory without the folder structure.
163-
--single-fixture-per-file
164-
Don't group fixtures in JSON files by test function; write each fixture to its
165-
own file. This can be used to increase the granularity of --verify-fixtures.
166-
--no-html Don't generate an HTML test report (in the output directory). The --html flag can
167-
be used to specify a different path.
168-
--build-name BUILD_NAME
169-
Specify a build name for the fixtures.ini file, e.g., 'stable'.
170-
--skip-index SKIP_INDEX
171-
Skip generating an index file for all produced fixtures.
172-
--block-gas-limit BLOCK_GAS_LIMIT
173-
Default gas limit used ceiling used for blocks and tests that attempt to consume
174-
an entire block's gas. (Default: 72000000)
175-
176-
Arguments defining debug behavior:
177-
--evm-dump-dir, --t8n-dump-dir EVM_DUMP_DIR
178-
Path to dump the transition tool debug output. (Default:
179-
<repo>/logs/evm)
180-
--skip-evm-dump, --skip-t8n-dump
181-
Skip dumping the the transition tool debug output.
182-
183-
Specify the fork range to generate fixtures for:
184-
--forks Display forks supported by the test framework and exit.
185-
--fork FORK Only fill tests for the specified fork.
186-
--from FROM Fill tests from and including the specified fork.
187-
--until UNTIL Fill tests until and including the specified fork.
188-
```
114+
For a complete, up-to-date list of all command-line options, see the [Fill Command-Line Options](filling_tests_command_line_options.md) page, which is automatically generated from the current `fill --help` output.

docs/navigation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
* [Filling Tests](filling_tests/index.md)
3030
* [Getting Started](filling_tests/getting_started.md)
3131
* [Filling Tests at a Prompt](filling_tests/filling_tests_command_line.md)
32+
* [Fill Command-Line Options](filling_tests/filling_tests_command_line_options.md)
3233
* [Filling Tests in VS Code](filling_tests/filling_tests_vs_code.md)
3334
* [Filling Tests for Features Under Development](filling_tests/filling_tests_dev_fork.md)
3435
* [An Explanation of Test IDs](filling_tests/test_ids.md)

docs/scripts/generate_fill_help.py

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Generate the fill command help output for documentation.
4+
5+
This script captures the output of 'fill --help' and generates a complete
6+
documentation page that includes both static content and the auto-generated
7+
help output. The generated page replaces the manual help output with
8+
current command-line options.
9+
"""
10+
11+
import logging
12+
import subprocess
13+
import sys
14+
import textwrap
15+
from pathlib import Path
16+
17+
import mkdocs_gen_files
18+
19+
logger = logging.getLogger("mkdocs")
20+
21+
22+
def get_fill_help_output() -> str:
23+
"""Run 'fill --help' and capture its output."""
24+
# Get the repository root (assuming script is in docs/scripts/)
25+
script_dir = Path(__file__).parent
26+
repo_root = script_dir.parent.parent
27+
28+
try:
29+
result = subprocess.run(
30+
["uv", "run", "fill", "--help"],
31+
capture_output=True,
32+
text=True,
33+
check=True,
34+
cwd=repo_root, # Run from repo root where pytest.ini exists
35+
)
36+
return result.stdout
37+
except subprocess.CalledProcessError as e:
38+
logger.error(f"Error running 'fill --help': {e}")
39+
logger.error(f"stderr: {e.stderr}")
40+
sys.exit(1)
41+
42+
43+
def format_help_output(help_text: str, max_width: int = 88) -> str:
44+
"""
45+
Format the help output with proper line wrapping.
46+
47+
Args:
48+
help_text: The raw help output
49+
max_width: Maximum line width (default 88 to match existing docs)
50+
51+
Returns:
52+
Formatted help text suitable for documentation
53+
54+
"""
55+
lines = help_text.splitlines()
56+
formatted_lines = []
57+
58+
for line in lines:
59+
# Don't wrap lines that are part of the usage section or are empty
60+
if not line.strip() or line.startswith("usage:") or line.startswith(" ") and "--" in line:
61+
formatted_lines.append(line)
62+
else:
63+
# Wrap long lines while preserving indentation
64+
indent = len(line) - len(line.lstrip())
65+
if len(line) > max_width and indent == 0:
66+
wrapped = textwrap.fill(
67+
line,
68+
width=max_width,
69+
subsequent_indent=" ",
70+
break_long_words=False,
71+
break_on_hyphens=False,
72+
)
73+
formatted_lines.append(wrapped)
74+
else:
75+
formatted_lines.append(line)
76+
77+
return "\n".join(formatted_lines)
78+
79+
80+
def generate_command_line_options_docs():
81+
"""Generate a standalone page with just the fill command-line options."""
82+
# Get and format the help output
83+
help_output = get_fill_help_output()
84+
formatted_output = format_help_output(help_output)
85+
86+
# Create the complete page content
87+
page_content = f"""# Fill Command-Line Options
88+
89+
Fill is a [pytest](https://docs.pytest.org/en/stable/)-based command. This page lists custom
90+
options that the `fill` command provides. To see the full list of options that is available
91+
to fill (including the standard pytest and plugin command-line options) use `fill --pytest-help`.
92+
93+
*This page is automatically generated from the current `fill --help` output.*
94+
95+
## Command Help Output
96+
97+
```text
98+
{formatted_output}
99+
```
100+
101+
---
102+
103+
*This page was automatically generated from `fill --help` output.*
104+
"""
105+
106+
# Write the generated content to a virtual file
107+
with mkdocs_gen_files.open("filling_tests/filling_tests_command_line_options.md", "w") as f:
108+
f.write(page_content)
109+
110+
logger.info("Generated filling_tests_command_line_options.md with current fill --help output")
111+
112+
113+
# Run the generation
114+
generate_command_line_options_docs()

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ plugins:
2828
scripts:
2929
- docs/scripts/copy_repo_docs_to_mkdocs.py
3030
- docs/scripts/gen_test_case_reference.py
31+
- docs/scripts/generate_fill_help.py
3132
- literate-nav:
3233
nav_file: navigation.md
3334

0 commit comments

Comments
 (0)