Files
AI-on-the-edge-device/tools/parameter-tooltip-generator/generate-param-doc-tooltips.py
jomjol b5e0d6ee66 Implement InfluxDBv1 and minor changes (#2211)
* Testcase for #2145 and debug-log (#2151)

* new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0

* Testcase for #2145
Added debug log, if allowNegativeRates is handeled

* Fix timezone config parser (#2169)

* make sure to parse the whole config line

* fix crash on empty timezone parameter

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Enhance ROI pages (#2161)

* Check if the ROIs are equidistant. Only if not, untick the checkbox

* renaming

* Check if the ROIs have same y, dy and dx. If so, tick the sync checkbox

* only allow editing space when box is checked

* fix sync check

* show inner frame on all ROIs

* cleanup

* Check if the ROIs have same dy and dx. If so, tick the sync checkbox

* checkbox position

* renaming

* renaming

* show inner frame and cross hairs on all ROIs

* update ROIs on ticking checkboxes

* show timezone hint

* fix deleting last ROI

* cleanup

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* restart timeout on progress, catch error (#2170)

* restart timeout on progress, catch error

* .

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* BugFix #2167

* Release 15.1 preparations (#2171)

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update changelog

* Fix links to PR

* Formating

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

* Update Changelog.md

---------

Co-authored-by: Slider0007 <jobbelle@gmx.net>
Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com>

* fix typo

* Replace relative documentation links with absolute ones pointing to the external documentation (#2180)

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Sort model files in configuration combobox (#2189)

* new models ana-cont-11.0.5, ana-class100-1.5.7, dig-class100-1.6.0

* Testcase for #2145
Added debug log, if allowNegativeRates is handeled

* Sort model files in combobox

* reboot task - increase stack size (#2201)

Avoid stack overflow

* Update interface_influxdb.cpp

* Update Changelog.md

---------

Co-authored-by: Frank Haverland <fspapaping@googlemail.com>
Co-authored-by: CaCO3 <caco3@ruinelli.ch>
Co-authored-by: CaCO3 <caco@ruinelli.ch>
Co-authored-by: Slider0007 <jobbelle@gmx.net>
Co-authored-by: Slider0007 <115730895+Slider0007@users.noreply.github.com>
2023-03-19 18:31:01 +01:00

82 lines
2.7 KiB
Python

"""
Grab all parameter files (markdown) and convert them to html files
"""
import os
import glob
import markdown
parameterDocsFolder = "AI-on-the-edge-device-docs/param-docs/parameter-pages"
docsMainFolder = "../../sd-card/html"
configPage = "edit_config_param.html"
htmlTooltipPrefix = """
<div class="rst-content"><div class="tooltip"><img src="help.png" width="32px"><span class="tooltiptext">
"""
htmlTooltipSuffix = """
</span></div></div>
"""
folders = sorted( filter( os.path.isdir, glob.glob(parameterDocsFolder + '/*') ) )
def generateHtmlTooltip(section, parameter, markdownFile):
# print(section, parameter, markdownFile)
with open(markdownFile, 'r') as markdownFileHandle:
markdownFileContent = markdownFileHandle.read()
markdownFileContent = markdownFileContent.replace("# ", "### ") # Move all headings 2 level down
htmlTooltip = markdown.markdown(markdownFileContent, extensions=['admonition'])
# Make all links to be opened in a new page
htmlTooltip = htmlTooltip.replace("a href", "a target=_blank href")
# Replace relative documentation links with absolute ones pointing to the external documentation
htmlTooltip = htmlTooltip.replace("href=\"../", "href=\"https://jomjol.github.io/AI-on-the-edge-device-docs/")
# Add custom styles
htmlTooltip = htmlTooltip.replace("<h3>", "<h3 style=\"margin: 0\">")
# Update image paths and copy images to right folder
if "../img/" in htmlTooltip:
htmlTooltip = htmlTooltip.replace("../img/", "/")
htmlTooltip = htmlTooltipPrefix + htmlTooltip + htmlTooltipSuffix
# Add the tooltip to the config page
with open(docsMainFolder + "/" + configPage, 'r') as configPageHandle:
configPageContent = configPageHandle.read()
# print("replacing $TOOLTIP_" + section + "_" + parameter + " with the tooltip content...")
configPageContent = configPageContent.replace("<td>$TOOLTIP_" + section + "_" + parameter + "</td>", "<td>" + htmlTooltip + "</td>")
with open(docsMainFolder + "/" + configPage, 'w') as configPageHandle:
configPageHandle.write(configPageContent)
print("Generating Tooltips...")
"""
Generate a HTML tooltip for each markdown page
"""
for folder in folders:
folder = folder.split("/")[-1]
files = sorted(filter(os.path.isfile, glob.glob(parameterDocsFolder + "/" + folder + '/*')))
for file in files:
if not ".md" in file: # Skip non-markdown files
continue
parameter = file.split("/")[-1].replace(".md", "")
parameter = parameter.replace("<", "").replace(">", "")
generateHtmlTooltip(folder, parameter, file)
"""
Copy images to main folder
"""
os.system("cp " + parameterDocsFolder + "/img/* " + docsMainFolder + "/")