1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

fix(docs): fix error blocking API-doc generation under Windows (#6990)

This commit is contained in:
Victor Wheeler 2024-10-11 13:31:49 -06:00 committed by GitHub
parent 2466d7ca39
commit 52665bf303
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 40 additions and 9 deletions

View File

@ -66,12 +66,18 @@ if len(args) >= 1:
develop = True
def cmd(s):
def cmd(s, start_dir=None):
if start_dir is None:
start_dir = os.getcwd()
saved_dir = os.getcwd()
os.chdir(start_dir)
print("")
print(s)
print("-------------------------------------")
result = os.system(s)
os.chdir(saved_dir)
if result != 0:
print("Exit build due to previous error")
sys.exit(result)
@ -80,7 +86,7 @@ def cmd(s):
# Get the current branch name
status, br = subprocess.getstatusoutput("git branch --show-current")
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
br = re.sub('\* ', '', br)
br = re.sub(r'\* ', '', br)
urlpath = re.sub('release/', '', br)
@ -141,10 +147,12 @@ print("Add translation")
add_translation.exec(temp_directory)
print("Running doxygen")
cmd('cd "{temp_directory}" && doxygen Doxyfile'.format(temp_directory=temp_directory))
cmd('doxygen Doxyfile', temp_directory)
print('Reading Doxygen output')
doc_builder.EMIT_WARNINGS = False
doc_builder.run(
project_path,
temp_directory,
@ -205,11 +213,23 @@ else:
f.write(index_data.encode('utf-8'))
# BUILD HTML
# This version of get_version() works correctly under Windows and Linux.
# Credit: @kdschlosser
def get_version():
_, ver = subprocess.getstatusoutput("../scripts/find_version.sh")
return ver
path = os.path.join(project_path, 'lv_version.h')
with open(path, 'rb') as fle:
d = fle.read().decode('utf-8')
d = d.split('#define LVGL_VERSION_MAJOR', 1)[-1]
major, d = d.split('\n', 1)
d = d.split('#define LVGL_VERSION_MINOR', 1)[-1]
minor, d = d.split('\n', 1)
# d = d.split('#define LVGL_VERSION_PATCH', 1)[-1]
# patch, d = d.split('\n', 1)
return f'{major.strip()}.{minor.strip()}'
cmd('sphinx-build -b html "{src}" "{dst}" -D version="{version}" -E -j {cpu}'.format(
src=html_src_path,

View File

@ -1134,6 +1134,11 @@ def iter_src(n, p):
def clean_name(nme):
# Handle error:
# AttributeError: 'NoneType' object has no attribute 'startswith'
if nme is None:
return nme
if nme.startswith('_lv_'):
nme = nme[4:]
elif nme.startswith('lv_'):
@ -1146,6 +1151,11 @@ def clean_name(nme):
def is_name_match(item_name, obj_name):
# Handle error:
# AttributeError: 'NoneType' object has no attribute 'split'
if obj_name is None:
return False
u_num = item_name.count('_') + 1
obj_name = obj_name.split('_')
@ -1207,7 +1217,7 @@ class XMLSearch(object):
status, br = subprocess.getstatusoutput("git branch")
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
br = re.sub('\* ', '', br)
br = re.sub(r'\* ', '', br)
urlpath = re.sub('release/', '', br)
@ -1292,6 +1302,7 @@ def run(project_path, temp_directory, *doc_paths):
if not os.path.exists(api_path):
os.makedirs(api_path)
# Generate .RST files for API pages.
iter_src('API', '')
index = load_xml('index')