Skip to content

Commit

Permalink
ci: update pre-commit to run docs generation when committing.
Browse files Browse the repository at this point in the history
  • Loading branch information
UpstreamData committed Jan 28, 2025
1 parent 4c64481 commit a24fc07
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ci:
skip:
- poetry-lock
- unittest
- generate-docs
repos:
- repo: https://github.com/python-poetry/poetry
rev: 2.0.1
Expand Down Expand Up @@ -37,6 +38,12 @@ repos:
name: unittest
entry: python -m unittest discover
language: system
'types': [python]
types: [ python ]
args: ["-p '*test.py'"] # Probably this option is absolutely not needed.
pass_filenames: false
- id: generate-docs
name: generate-docs
entry: python docs/generate_miners.py
language: system
types: [ python ]
pass_filenames: false
17 changes: 10 additions & 7 deletions docs/generate_miners.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib
import os
import warnings
from pathlib import Path

from pyasic.miners.factory import MINER_CLASSES, MinerTypes

Expand Down Expand Up @@ -59,6 +60,7 @@ def backend_str(backend: MinerTypes) -> str:
return "Stock Firmware Hammer Miners"
case MinerTypes.VOLCMINER:
return "Stock Firmware Volcminers"
raise TypeError("Unknown miner backend, cannot generate docs")


def create_url_str(mtype: str):
Expand Down Expand Up @@ -137,14 +139,14 @@ def create_url_str(mtype: str):
done.append(miner)


async def create_directory_structure(directory, data):
def create_directory_structure(directory, data):
if not os.path.exists(directory):
os.makedirs(directory)

for key, value in data.items():
subdirectory = os.path.join(directory, key)
if isinstance(value, dict):
await create_directory_structure(subdirectory, value)
create_directory_structure(subdirectory, value)
elif isinstance(value, list):
file_path = os.path.join(subdirectory + ".md")

Expand All @@ -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:
file.write(SUPPORTED_TYPES_HEADER)
for mback in MINER_CLASSES:
Expand All @@ -182,7 +184,7 @@ async def create_supported_types(directory):
for mtype in backend_types:
file.write(MINER_TYPE_HEADER.format(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(
MINER_DETAILS.format(
make(minstance), mtype, create_url_str(model), model
Expand All @@ -192,6 +194,7 @@ async def create_supported_types(directory):
file.write(BACKEND_TYPE_CLOSER)


root_directory = os.path.join(os.getcwd(), "miners")
asyncio.run(create_directory_structure(root_directory, m_data))
asyncio.run(create_supported_types(root_directory))
if __name__ == "__main__":
root_directory = Path(__file__).parent.joinpath("miners")
create_directory_structure(root_directory, m_data)
create_supported_types(root_directory)
13 changes: 13 additions & 0 deletions docs/miners/antminer/X21.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@
show_root_heading: false
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+)

- [x] Shutdowns
Expand Down
1 change: 1 addition & 0 deletions docs/miners/supported_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,7 @@ details {
<summary>X21 Series:</summary>
<ul>
<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>
</ul>
</details>
Expand Down

0 comments on commit a24fc07

Please sign in to comment.