Skip to content

Commit 48f11e6

Browse files
Create cli.py
1 parent 8fb54e8 commit 48f11e6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

sphinx_autodoc_vyper/cli.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Command-line interface for Vyper Sphinx documentation generator."""
2+
3+
import argparse
4+
import os
5+
import subprocess
6+
from pathlib import Path
7+
from .parser import VyperParser
8+
from .generator import SphinxGenerator
9+
from .server import serve_docs
10+
11+
12+
def main():
13+
"""Main entry point for the CLI."""
14+
parser = argparse.ArgumentParser(description='Generate Sphinx documentation for Vyper contracts')
15+
parser.add_argument('contracts_dir', help='Directory containing Vyper contracts')
16+
parser.add_argument('--output', '-o', default='.', help='Output directory for documentation')
17+
parser.add_argument('--serve', '-s', action='store_true', help='Serve documentation after building')
18+
parser.add_argument('--port', '-p', type=int, default=8000, help='Port for the documentation server')
19+
args = parser.parse_args()
20+
21+
# Parse contracts
22+
vyper_parser = VyperParser(args.contracts_dir)
23+
contracts = vyper_parser.parse_contracts()
24+
25+
# Generate Sphinx documentation
26+
generator = SphinxGenerator(args.output)
27+
generator.generate(contracts)
28+
29+
# Build HTML documentation
30+
docs_dir = Path(args.output) / 'docs'
31+
build_dir = docs_dir / '_build'
32+
subprocess.run(['sphinx-build', '-b', 'html', str(docs_dir), str(build_dir)], check=True)
33+
34+
print(f'Documentation built successfully in {build_dir}/html')
35+
36+
# Serve documentation if requested
37+
if args.serve:
38+
serve_docs(args.port)

0 commit comments

Comments
 (0)