mirror of
https://github.com/jomjol/AI-on-the-edge-device-docs.git
synced 2025-12-11 22:17:03 +03:00
moved files
This commit is contained in:
68
param-docs/generate-param-doc-pages.py
Normal file
68
param-docs/generate-param-doc-pages.py
Normal file
@@ -0,0 +1,68 @@
|
||||
"""
|
||||
For each parameter which can be found in the config file,
|
||||
create a markdown file with a templated contentf it does not exist yet.
|
||||
The files are grouped in sub folders representing the config sections.
|
||||
"""
|
||||
|
||||
import os
|
||||
import configparser
|
||||
import urllib.request
|
||||
|
||||
configFileUrl = "https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/rolling/sd-card/config/config.ini"
|
||||
|
||||
parameterDocsFolder = "parameter-pages"
|
||||
parameterTemplateFile = "./templates/parameter.md"
|
||||
|
||||
# Fetch default config file from URL
|
||||
with urllib.request.urlopen(configFileUrl) as response:
|
||||
content = response.read().decode("utf-8")
|
||||
|
||||
lines = str(content).split("\n")
|
||||
|
||||
for l in range(len(lines)):
|
||||
lines[l] = lines[l].strip() + "\n"
|
||||
if lines[l][0] == ";":
|
||||
lines[l] = lines[l][1:] # Remove comment
|
||||
|
||||
content = "".join(lines)
|
||||
|
||||
|
||||
config = configparser.ConfigParser(allow_no_value=True)
|
||||
config.optionxform = str # Make it case-insensitive
|
||||
config.read_string(content)
|
||||
|
||||
#shutil.rmtree(parameterDocsFolder)
|
||||
if not os.path.exists(parameterDocsFolder):
|
||||
os.mkdir(parameterDocsFolder)
|
||||
|
||||
with open(parameterTemplateFile, 'r') as parameterTemplateFileHandle:
|
||||
parameterTemplate = parameterTemplateFileHandle.read()
|
||||
|
||||
|
||||
|
||||
for section in config:
|
||||
if section != "DEFAULT":
|
||||
#print(section)
|
||||
|
||||
subFolder = parameterDocsFolder + "/" + section
|
||||
|
||||
if not os.path.exists(subFolder):
|
||||
os.mkdir(subFolder)
|
||||
|
||||
for parameter in config[section]:
|
||||
if not " " in parameter: # Ignore parameters with whitespaces in them (special format, not part of editable config)
|
||||
value = config[section][parameter]
|
||||
#print(" %s = %s" % (parameter, value))
|
||||
|
||||
"""
|
||||
For each config line, create a markdown file
|
||||
"""
|
||||
parameterDocFile = subFolder + '/' + parameter + ".md"
|
||||
|
||||
if not os.path.exists(parameterDocFile): # File does not exist yet, generate template
|
||||
with open(parameterDocFile, 'w') as paramFileHandle:
|
||||
content = parameterTemplate
|
||||
content = content.replace("$NAME", parameter)
|
||||
content = content.replace("$DEFAULT", value)
|
||||
|
||||
paramFileHandle.write(content)
|
||||
Reference in New Issue
Block a user