diff --git a/README.rst b/README.rst index 5b65850..f4c04fc 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,8 @@ Please, don't change. In case you need to make corrections or changes change source documentation in ./doc folder or script. +.. Generated from see_also.rst + .. Generated from esphome-docs/climate/haier.rst Haier Climate @@ -567,10 +569,9 @@ flash_4M.bin** After this, you can flash firmware using ESPHome tools (dashboard, website, esphome command, etc) -.. Generated from additional_information.rst -Additional information -====================== +See Also +======== - `FAQ <./docs/faq.rst>`_ - `HaierProtocol `_ @@ -578,8 +579,14 @@ Additional information - `Haier protocol overview <./docs/protocol_overview.rst>`_ - `Example of climate configuration for smartair2 protocol <./docs/smartair2_example.rst>`_ - `Example of climate configuration for hOn protocol <./docs/hon_example.rst>`_ +- `Esptool.py Documentation `_ +- `Sniffing serial communication <./docs/sniffing_serial_communication.rst>`_ - `ESPHome Haier Climate `_ - `ESPHome Haier Climate Sensors `_ - `ESPHome Haier Climate Binary Sensors `_ -- `Esptool.py Documentation `_ -- `Sniffing serial communication <./docs/sniffing_serial_communication.rst>`_ \ No newline at end of file +- `ESPHome Haier Climate Text Sensors `_ +- `ESPHome Haier Climate Buttons `_ +- `ESPHome Haier Climate Switches `_ +- `Climate Component `_ +- `API Reference `_ +- `Sensor Filters `_ diff --git a/docs/esphome-docs/climate/haier.rst b/docs/esphome-docs/climate/haier.rst index 56ed801..1a1f82f 100644 --- a/docs/esphome-docs/climate/haier.rst +++ b/docs/esphome-docs/climate/haier.rst @@ -53,7 +53,7 @@ Newer Haier models using a module called ESP32-for-Haier. It is an ESP32 single- Also, you can use any other ESP32, ESP8266, or an RPI pico W board. In this case, you will need to cut the original wire or make a connector yourself (the board has a JST SM04B-GHS-TB connector) -This component requires a :ref:`uart` to be setup. +This component requires a :ref:`UART bus ` to be setup. .. code-block:: yaml @@ -343,5 +343,5 @@ See Also - :doc:`Haier Climate Buttons ` - :doc:`Haier Climate Switches ` - :doc:`/components/climate/index` -- :apiref:`haier/climate/haier.h` +- :apiref:`haier/climate/haier_base.h` - :ghedit:`Edit` diff --git a/docs/script/make_doc.py b/docs/script/make_doc.py index dc56e23..d2d01be 100644 --- a/docs/script/make_doc.py +++ b/docs/script/make_doc.py @@ -3,6 +3,7 @@ import sys doc_file_path = [ + "see_also.rst", "/".join(["esphome-docs", "climate", "haier.rst"]), "/".join(["esphome-docs", "sensor", "haier.rst"]), "/".join(["esphome-docs", "binary_sensor", "haier.rst"]), @@ -10,32 +11,43 @@ "/".join(["esphome-docs", "button", "haier.rst"]), "/".join(["esphome-docs", "switch", "haier.rst"]), "esp32_backup.rst", - "additional_information.rst", ] def process_esphome_refs(line, l_num): esphome_refs = [ - (":ref:`uart`", "`UART Bus `_"), (":ref:`config-id`", "`ID `_"), (":ref:`config-time`", "`Time `_"), (":ref:`Automation `", "`Automation `_"), + (":ref:`lambdas `", "`lambdas `_"), (":ref:`haier-on_alarm_start`", "`on_alarm_start Trigger`_"), (":ref:`haier-on_alarm_end`", "`on_alarm_end Trigger`_"), (":ref:`haier-on_status_message`", "`on_status_message Trigger`_"), + (":ref:`UART bus `", "`UART Bus `_"), (":ref:`Climate `", "`Climate `_"), - (":ref:`lambdas `", "`lambdas `_"), (":ref:`Sensor `", "`Sensor `_"), (":ref:`Binary Sensor `", "`Binary Sensor `_"), (":ref:`Text Sensor `", "`Text Sensor `_"), (":ref:`Button `", "`Button `_"), (":ref:`Switch `", "`Switch `_"), (":ref:`Select `", "`Select `_"), + (":ghedit:`Edit`", ""), + (":doc:`/components/climate/index`", "`Climate Component `_"), + (":doc:`Haier Climate `", "`ESPHome Haier Climate `_"), + (":apiref:`haier/climate/haier_base.h`", "`API Reference `_"), + (":ref:`sensor-filters`", "`Sensor Filters `_"), + (":doc:`Haier Climate Sensors `", "`ESPHome Haier Climate Sensors `_"), + (":doc:`Haier Climate Binary Sensors `", "`ESPHome Haier Climate Binary Sensors `_"), + (":doc:`Haier Climate Text Sensors `", "`ESPHome Haier Climate Text Sensors `_"), + (":doc:`Haier Climate Buttons `", "`ESPHome Haier Climate Buttons `_"), + (":doc:`Haier Climate Switches `", "`ESPHome Haier Climate Switches `_"), ] res = line for o, r in esphome_refs: res = res.replace(o, r) if res.find(":ref:") != -1: print(f"\tWarning: ref found, line #{l_num}") + if res.find(":doc:") != -1: + print(f"\tWarning: doc found, line #{l_num}") return res def process_figure(section, output_file, pth): @@ -70,6 +82,17 @@ def process_section(section, output_file, pth): else: output_file.writelines(section) +def process_see_also(see_also_lines, output_file): + print("Processing See Also section") + output_file.write("\nSee Also\n") + output_file.write("========\n\n") + l_counter = 0 + for l in see_also_lines: + if l.find("") == -1: + l_counter += 1 + output_file.write(f"- {l}\n") + print(f"\tProcessed {l_counter} line(s)") + 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", @@ -82,6 +105,7 @@ def process_section(section, output_file, pth): output_file_name = sys.argv[1] output_file = open(output_file_name, "w") output_file.writelines(document_header) +see_also_lines = [] for in_f in doc_file_path: print(f"Processing: {in_f}") output_file.write(f".. Generated from {in_f}\n\n") @@ -90,12 +114,20 @@ def process_section(section, output_file, pth): lines = input_file.readlines() is_seo = False is_section = False + is_in_see_also = False section = [] l_counter = 0 for line in lines: l_counter += 1 if line == "See Also\n": - break + is_in_see_also = True + continue + if is_in_see_also: + if line.startswith('- '): + processed_line = process_esphome_refs(line[2:].rstrip(), l_counter) + if processed_line and (processed_line not in see_also_lines): + see_also_lines.append(processed_line) + continue if is_section: if (line in ['\n', '\r\n']) or line.startswith(" "): section.append(line) @@ -116,4 +148,5 @@ def process_section(section, output_file, pth): continue l = process_esphome_refs(line, l_counter) output_file.write(l) - print(f"\tProcessed {l_counter} line(s)") \ No newline at end of file + print(f"\tProcessed {l_counter} line(s)") +process_see_also(see_also_lines, output_file) diff --git a/docs/additional_information.rst b/docs/see_also.rst similarity index 62% rename from docs/additional_information.rst rename to docs/see_also.rst index ec7d883..975dca5 100644 --- a/docs/additional_information.rst +++ b/docs/see_also.rst @@ -1,5 +1,5 @@ -Additional information -====================== +See Also +-------- - `FAQ <./docs/faq.rst>`_ - `HaierProtocol `_ @@ -7,8 +7,6 @@ Additional information - `Haier protocol overview <./docs/protocol_overview.rst>`_ - `Example of climate configuration for smartair2 protocol <./docs/smartair2_example.rst>`_ - `Example of climate configuration for hOn protocol <./docs/hon_example.rst>`_ -- `ESPHome Haier Climate `_ -- `ESPHome Haier Climate Sensors `_ -- `ESPHome Haier Climate Binary Sensors `_ - `Esptool.py Documentation `_ -- `Sniffing serial communication <./docs/sniffing_serial_communication.rst>`_ \ No newline at end of file +- `Sniffing serial communication <./docs/sniffing_serial_communication.rst>`_ +- :doc:`Haier Climate `