ci: update pre-commit to run docs generation when committing.
This commit is contained in:
@@ -2,6 +2,7 @@ ci:
|
|||||||
skip:
|
skip:
|
||||||
- poetry-lock
|
- poetry-lock
|
||||||
- unittest
|
- unittest
|
||||||
|
- generate-docs
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/python-poetry/poetry
|
- repo: https://github.com/python-poetry/poetry
|
||||||
rev: 2.0.1
|
rev: 2.0.1
|
||||||
@@ -37,6 +38,12 @@ repos:
|
|||||||
name: unittest
|
name: unittest
|
||||||
entry: python -m unittest discover
|
entry: python -m unittest discover
|
||||||
language: system
|
language: system
|
||||||
'types': [python]
|
types: [ python ]
|
||||||
args: ["-p '*test.py'"] # Probably this option is absolutely not needed.
|
args: ["-p '*test.py'"] # Probably this option is absolutely not needed.
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
|
- id: generate-docs
|
||||||
|
name: generate-docs
|
||||||
|
entry: python docs/generate_miners.py
|
||||||
|
language: system
|
||||||
|
types: [ python ]
|
||||||
|
pass_filenames: false
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import asyncio
|
|||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
import warnings
|
import warnings
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from pyasic.miners.factory import MINER_CLASSES, MinerTypes
|
from pyasic.miners.factory import MINER_CLASSES, MinerTypes
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ def backend_str(backend: MinerTypes) -> str:
|
|||||||
return "Stock Firmware Hammer Miners"
|
return "Stock Firmware Hammer Miners"
|
||||||
case MinerTypes.VOLCMINER:
|
case MinerTypes.VOLCMINER:
|
||||||
return "Stock Firmware Volcminers"
|
return "Stock Firmware Volcminers"
|
||||||
|
raise TypeError("Unknown miner backend, cannot generate docs")
|
||||||
|
|
||||||
|
|
||||||
def create_url_str(mtype: str):
|
def create_url_str(mtype: str):
|
||||||
@@ -137,14 +139,14 @@ for m in MINER_CLASSES:
|
|||||||
done.append(miner)
|
done.append(miner)
|
||||||
|
|
||||||
|
|
||||||
async def create_directory_structure(directory, data):
|
def create_directory_structure(directory, data):
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
os.makedirs(directory)
|
os.makedirs(directory)
|
||||||
|
|
||||||
for key, value in data.items():
|
for key, value in data.items():
|
||||||
subdirectory = os.path.join(directory, key)
|
subdirectory = os.path.join(directory, key)
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
await create_directory_structure(subdirectory, value)
|
create_directory_structure(subdirectory, value)
|
||||||
elif isinstance(value, list):
|
elif isinstance(value, list):
|
||||||
file_path = os.path.join(subdirectory + ".md")
|
file_path = os.path.join(subdirectory + ".md")
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ async def create_directory_structure(directory, data):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def create_supported_types(directory):
|
def create_supported_types(directory):
|
||||||
with open(os.path.join(directory, "supported_types.md"), "w") as file:
|
with open(os.path.join(directory, "supported_types.md"), "w") as file:
|
||||||
file.write(SUPPORTED_TYPES_HEADER)
|
file.write(SUPPORTED_TYPES_HEADER)
|
||||||
for mback in MINER_CLASSES:
|
for mback in MINER_CLASSES:
|
||||||
@@ -182,7 +184,7 @@ async def create_supported_types(directory):
|
|||||||
for mtype in backend_types:
|
for mtype in backend_types:
|
||||||
file.write(MINER_TYPE_HEADER.format(mtype))
|
file.write(MINER_TYPE_HEADER.format(mtype))
|
||||||
for minstance in backend_types[mtype]:
|
for minstance in backend_types[mtype]:
|
||||||
model = await minstance("1.1.1.1").get_model()
|
model = minstance("1.1.1.1").model
|
||||||
file.write(
|
file.write(
|
||||||
MINER_DETAILS.format(
|
MINER_DETAILS.format(
|
||||||
make(minstance), mtype, create_url_str(model), model
|
make(minstance), mtype, create_url_str(model), model
|
||||||
@@ -192,6 +194,7 @@ async def create_supported_types(directory):
|
|||||||
file.write(BACKEND_TYPE_CLOSER)
|
file.write(BACKEND_TYPE_CLOSER)
|
||||||
|
|
||||||
|
|
||||||
root_directory = os.path.join(os.getcwd(), "miners")
|
if __name__ == "__main__":
|
||||||
asyncio.run(create_directory_structure(root_directory, m_data))
|
root_directory = Path(__file__).parent.joinpath("miners")
|
||||||
asyncio.run(create_supported_types(root_directory))
|
create_directory_structure(root_directory, m_data)
|
||||||
|
create_supported_types(root_directory)
|
||||||
|
|||||||
@@ -53,6 +53,19 @@
|
|||||||
show_root_heading: false
|
show_root_heading: false
|
||||||
heading_level: 0
|
heading_level: 0
|
||||||
|
|
||||||
|
## S21 Pro (BOS+)
|
||||||
|
|
||||||
|
- [x] Shutdowns
|
||||||
|
- [ ] Power Modes
|
||||||
|
- [x] Setpoints
|
||||||
|
- [ ] Presets
|
||||||
|
|
||||||
|
::: pyasic.miners.antminer.bosminer.X21.S21.BOSMinerS21Pro
|
||||||
|
handler: python
|
||||||
|
options:
|
||||||
|
show_root_heading: false
|
||||||
|
heading_level: 0
|
||||||
|
|
||||||
## T21 (BOS+)
|
## T21 (BOS+)
|
||||||
|
|
||||||
- [x] Shutdowns
|
- [x] Shutdowns
|
||||||
|
|||||||
@@ -652,6 +652,7 @@ details {
|
|||||||
<summary>X21 Series:</summary>
|
<summary>X21 Series:</summary>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="../antminer/X21#s21-bos_1">S21 (BOS+)</a></li>
|
<li><a href="../antminer/X21#s21-bos_1">S21 (BOS+)</a></li>
|
||||||
|
<li><a href="../antminer/X21#s21-pro-bos_1">S21 Pro (BOS+)</a></li>
|
||||||
<li><a href="../antminer/X21#t21-bos_1">T21 (BOS+)</a></li>
|
<li><a href="../antminer/X21#t21-bos_1">T21 (BOS+)</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
Reference in New Issue
Block a user