From a24fc07c2ae3d4c0f73af3627c220d1ab1e2f7a7 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Tue, 28 Jan 2025 08:51:13 -0700 Subject: [PATCH] ci: update pre-commit to run docs generation when committing. --- .pre-commit-config.yaml | 9 ++++++++- docs/generate_miners.py | 17 ++++++++++------- docs/miners/antminer/X21.md | 13 +++++++++++++ docs/miners/supported_types.md | 1 + 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 005bb9d7..eaaa2e58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,7 @@ ci: skip: - poetry-lock - unittest + - generate-docs repos: - repo: https://github.com/python-poetry/poetry rev: 2.0.1 @@ -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 diff --git a/docs/generate_miners.py b/docs/generate_miners.py index 7672ab16..a5b406df 100644 --- a/docs/generate_miners.py +++ b/docs/generate_miners.py @@ -2,6 +2,7 @@ import asyncio import importlib import os import warnings +from pathlib import Path from pyasic.miners.factory import MINER_CLASSES, MinerTypes @@ -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): @@ -137,14 +139,14 @@ for m in MINER_CLASSES: 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") @@ -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: @@ -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 @@ -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) diff --git a/docs/miners/antminer/X21.md b/docs/miners/antminer/X21.md index cc9df52a..baa22b11 100644 --- a/docs/miners/antminer/X21.md +++ b/docs/miners/antminer/X21.md @@ -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 diff --git a/docs/miners/supported_types.md b/docs/miners/supported_types.md index 20ca78da..9d6d98d8 100644 --- a/docs/miners/supported_types.md +++ b/docs/miners/supported_types.md @@ -652,6 +652,7 @@ details { X21 Series: