5
5
from .parser import Contract
6
6
7
7
8
- class SphinxGenerator :
9
- """Generate Sphinx documentation for Vyper contracts."""
8
+ INDEX_RST = """Vyper Smart Contracts Documentation
9
+ ================================
10
10
11
- def __init__ (self , output_dir : str ):
12
- self .output_dir = output_dir
13
- self .docs_dir = os .path .join (output_dir , "docs" )
14
- os .makedirs (self .docs_dir , exist_ok = True )
11
+ .. toctree::
12
+ :maxdepth: 2
13
+ :caption: Contents:
15
14
16
- def generate (self , contracts : List [Contract ]):
17
- """Generate Sphinx documentation."""
18
- self ._generate_conf_py ()
19
- self ._generate_index_rst (contracts )
20
- self ._generate_contract_docs (contracts )
15
+ """
21
16
22
- def _generate_conf_py (self ):
23
- """Generate Sphinx configuration file."""
24
- conf_content = """# Configuration file for Sphinx documentation
17
+
18
+ CONF_CONTENT = """# Configuration file for Sphinx documentation
25
19
26
20
project = 'Vyper Smart Contracts'
27
21
copyright = '2023'
@@ -39,26 +33,37 @@ def _generate_conf_py(self):
39
33
html_theme = 'sphinx_rtd_theme'
40
34
html_static_path = ['_static']
41
35
"""
42
- with open (os .path .join (self .docs_dir , "conf.py" ), "w" , encoding = "utf-8" ) as f :
43
- f .write (conf_content )
44
36
45
- def _generate_index_rst (self , contracts : List [Contract ]):
46
- """Generate index.rst file."""
47
- content = """Vyper Smart Contracts Documentation
48
- ================================
49
37
50
- .. toctree::
51
- :maxdepth: 2
52
- :caption: Contents:
38
+ class SphinxGenerator :
39
+ """Generate Sphinx documentation for Vyper contracts."""
53
40
54
- """
41
+ def __init__ (self , output_dir : str ):
42
+ self .output_dir = output_dir
43
+ self .docs_dir = os .path .join (output_dir , "docs" )
44
+ os .makedirs (self .docs_dir , exist_ok = True )
45
+
46
+ def generate (self , contracts : List [Contract ]) -> None :
47
+ """Generate Sphinx documentation."""
48
+ self ._generate_conf_py ()
49
+ self ._generate_index_rst (contracts )
50
+ self ._generate_contract_docs (contracts )
51
+
52
+ def _generate_conf_py (self ) -> None :
53
+ """Generate Sphinx configuration file."""
54
+ with open (os .path .join (self .docs_dir , "conf.py" ), "w" , encoding = "utf-8" ) as f :
55
+ f .write (CONF_CONTENT )
56
+
57
+ def _generate_index_rst (self , contracts : List [Contract ]) -> None :
58
+ """Generate index.rst file."""
59
+ content = INDEX_RST
55
60
for contract in contracts :
56
61
content += f" { contract .name } \n "
57
62
58
63
with open (os .path .join (self .docs_dir , "index.rst" ), "w" , encoding = "utf-8" ) as f :
59
64
f .write (content )
60
65
61
- def _generate_contract_docs (self , contracts : List [Contract ]):
66
+ def _generate_contract_docs (self , contracts : List [Contract ]) -> None :
62
67
"""Generate documentation for each contract."""
63
68
for contract in contracts :
64
69
content = f"""{ contract .name }
0 commit comments