Skip to content

Commit

Permalink
Script for examples added
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldn committed Jul 27, 2024
1 parent 39b81a7 commit 183669f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 27 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
tests:
name: documentation check
- name: Readme check
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -16,3 +16,21 @@ jobs:
run: python docs/script/make_doc.py README.tmp
- name: Compare temp file with readme.rst
run: diff -u --strip-trailing-cr README.rst README.tmp
- name: Check hon_example
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Run script and save results
run: python docs/script/process_examples.py docs/examples/hon_example.rst docs/hon_example.tmp
- name: Compare temp file with hon_example.rst
run: diff -u --strip-trailing-cr docs/hon_example.rst docs/hon_example.tmp
- name: Check smartair2_example
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Run script and save results
run: python docs/script/process_examples.py docs/examples/smartair2_example.rst docs/smartair2_example.tmp
- name: Compare temp file with smartair2_example.rst
run: diff -u --strip-trailing-cr docs/smartair2_example.rst docs/smartair2_example.tmp
12 changes: 12 additions & 0 deletions docs/examples/hon_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Example of climate configuration for hOn protocol
=================================================

Configuration of your climate will depend on capabilities specific model.

Minimal configuration will look like this:

.. example_yaml:: examples/min-hon.yaml

Maximum configuration witch will use all possible options will look like this:

.. example_yaml:: examples/max-hon.yaml
18 changes: 0 additions & 18 deletions docs/examples/res.txt

This file was deleted.

12 changes: 12 additions & 0 deletions docs/examples/smartair2_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Example of climate configuration for smartair2 protocol
=======================================================

Configuration of your climate will depend on capabilities specific model.

Minimal configuration will look like this:

.. example_yaml:: examples/min-smartair2.yaml

Maximum configuration witch will use all possible options will look like this:

.. example_yaml:: examples/max-smartair2.yaml
21 changes: 19 additions & 2 deletions docs/hon_example.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
.. This file is automatically generated by ./docs/script/make_doc.py Python script.
Please, don't change. In case you need to make corrections or changes change
source documentation in ./doc folder or script.
Example of climate configuration for hOn protocol
=================================================

Configuration of your climate will depend on capabilities specific model.

Minimal configuration will look like this:

.. literalinclude:: examples/min-hon.yaml
:language: yaml
.. code-block:: yaml
uart:
baud_rate: 9600
tx_pin: 17
rx_pin: 16
climate:
- platform: haier
protocol: hOn
name: Haier hOn Climate
Maximum configuration witch will use all possible options will look like this:

Expand Down Expand Up @@ -290,3 +304,6 @@ Maximum configuration witch will use all possible options will look like this:
name: Haier hOn Climate Indoor Fan Status
outdoor_fan_status:
name: Haier hOn Climate Outdoor Fan Status
31 changes: 31 additions & 0 deletions docs/script/process_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
import re

document_header = [
".. This file is automatically generated by ./docs/script/make_doc.py Python script.\n",
" Please, don't change. In case you need to make corrections or changes change\n",
" source documentation in ./doc folder or script.\n\n"
]

if len(sys.argv) < 3:
print("Usage: python process_examples.py <input_file> <output_file>")
sys.exit(1)

input_file = sys.argv[1]
output_file = sys.argv[2]

with open(input_file, "r") as f:
ofile = open(output_file, "w")
lines = f.readlines()
ofile.writelines(document_header)
for line in lines:
m = re.match(r"^.. example_yaml:: ([^\n]+)", line)
if m:
print("Processing example: " + m.group(1))
ofile.write(".. code-block:: yaml\n\n")
example = open(m.group(1), "r")
for l in example.readlines():
ofile.write(" " + l)
ofile.write("\n")
else:
ofile.write(line)
19 changes: 13 additions & 6 deletions docs/smartair2_example.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.. This file is automatically generated by ./docs/script/make_doc.py Python script.
Please, don't change. In case you need to make corrections or changes change
source documentation in ./doc folder or script.
Example of climate configuration for smartair2 protocol
=======================================================

Expand All @@ -11,22 +15,22 @@ Minimal configuration will look like this:
baud_rate: 9600
tx_pin: 17
rx_pin: 16
climate:
- platform: haier
name: Haier SmartAir2 Climate
name: Haier hOn Climate
Maximum configuration witch will use all possible options will look like this:

.. code-block:: yaml
uart:
uart:
baud_rate: 9600
tx_pin: 17
rx_pin: 16
id: haier_uart
api:
services:
- service: turn_on
Expand All @@ -35,7 +39,7 @@ Maximum configuration witch will use all possible options will look like this:
- service: turn_off
then:
- climate.haier.power_off: haier_ac
climate:
- platform: haier
id: haier_ac
Expand Down Expand Up @@ -64,7 +68,7 @@ Maximum configuration witch will use all possible options will look like this:
- BOOST
- COMFORT
- AWAY
switch:
- platform: template
id: haier_ac_health_mode
Expand All @@ -89,3 +93,6 @@ Maximum configuration witch will use all possible options will look like this:
climate.haier.display_on: haier_ac
turn_off_action:
climate.haier.display_off: haier_ac

0 comments on commit 183669f

Please sign in to comment.