Skip to content

Commit

Permalink
Added workflow to check documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Dudnytskyi committed Jun 24, 2024
1 parent 499d8e0 commit 381d588
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: documentation check

on:
push:
pull_request:
branches: [ "master", "dev" , "experimental" ]

jobs:
tests:
name: documentation check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Run script and save results
run: python docs/script/run_script.py README.tmp
- name: Compare temp file with readme.rst
run: diff -u README.rst README.tmp > doc_cmp.result
- name: Fail build if files are not identical
run: |
if [ $? -ne 0 ]; then
echo "Files are not identical"
cat doc_cmp.result
exit 1
fi
17 changes: 9 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Gitignore settings for ESPHome
/.esphome/
__pycache__/
/.vscode/
/secrets.yaml
/buildlog.txt
*.bak
*.local.yaml
# Gitignore settings for ESPHome
/.esphome/
__pycache__/
/.vscode/
/secrets.yaml
/buildlog.txt
*.bak
*.local.yaml
*.tmp
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ Automations

``on_alarm_start`` Trigger
**************************

This automation will be triggered when a new alarm is activated by AC. The error code of the alarm will be given in the variable "code" (type uint8_t), error message in the variable "message" (type char*). Those variables can be used in `lambdas <https://esphome.io/guides/automations#config-lambda>`_

.. code-block:: yaml
Expand Down
23 changes: 14 additions & 9 deletions docs/script/make_doc.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import re
import os
import sys

doc_file_path = [
'esphome-docs/climate/haier.rst',
'esphome-docs/sensor/haier.rst',
'esphome-docs/binary_sensor/haier.rst',
'esphome-docs/text_sensor/haier.rst',
'esphome-docs/button/haier.rst',
'esp32_backup.rst',
'additional_information.rst',
"/".join(["esphome-docs", "climate", "haier.rst"]),
"/".join(["esphome-docs", "sensor", "haier.rst"]),
"/".join(["esphome-docs", "binary_sensor", "haier.rst"]),
"/".join(["esphome-docs", "text_sensor", "haier.rst"]),
"/".join(["esphome-docs", "button", "haier.rst"]),
"esp32_backup.rst",
"additional_information.rst",
]

def process_esphome_refs(line, l_num):
Expand Down Expand Up @@ -72,12 +73,16 @@ def process_section(section, output_file, pth):
" source documentation in ./doc folder or script.\n\n"
]

output_file = open("../../README.rst", "w")
script_path = os.path.dirname(__file__)
output_file_name = "../../README.rst"
if len(sys.argv) > 1:
output_file_name = sys.argv[1]
output_file = open(output_file_name, "w")
output_file.writelines(document_header)
for in_f in doc_file_path:
print(f"Processing: {in_f}")
output_file.write(f".. Generated from {in_f}\n\n")
input_file = open(f"../{in_f}", "r")
input_file = open(os.path.join(script_path, "..", in_f), "r")
p = os.path.dirname(in_f)
lines = input_file.readlines()
is_seo = False
Expand Down

0 comments on commit 381d588

Please sign in to comment.