fix(docs): fix error blocking API-doc generation under Windows (#6990)
This commit is contained in:
@@ -66,12 +66,18 @@ if len(args) >= 1:
|
|||||||
develop = True
|
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("")
|
||||||
print(s)
|
print(s)
|
||||||
print("-------------------------------------")
|
print("-------------------------------------")
|
||||||
|
|
||||||
result = os.system(s)
|
result = os.system(s)
|
||||||
|
os.chdir(saved_dir)
|
||||||
|
|
||||||
if result != 0:
|
if result != 0:
|
||||||
print("Exit build due to previous error")
|
print("Exit build due to previous error")
|
||||||
sys.exit(result)
|
sys.exit(result)
|
||||||
@@ -80,7 +86,7 @@ def cmd(s):
|
|||||||
# Get the current branch name
|
# Get the current branch name
|
||||||
status, br = subprocess.getstatusoutput("git branch --show-current")
|
status, br = subprocess.getstatusoutput("git branch --show-current")
|
||||||
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
|
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
|
||||||
br = re.sub('\* ', '', br)
|
br = re.sub(r'\* ', '', br)
|
||||||
|
|
||||||
|
|
||||||
urlpath = re.sub('release/', '', br)
|
urlpath = re.sub('release/', '', br)
|
||||||
@@ -141,10 +147,12 @@ print("Add translation")
|
|||||||
add_translation.exec(temp_directory)
|
add_translation.exec(temp_directory)
|
||||||
|
|
||||||
print("Running doxygen")
|
print("Running doxygen")
|
||||||
cmd('cd "{temp_directory}" && doxygen Doxyfile'.format(temp_directory=temp_directory))
|
cmd('doxygen Doxyfile', temp_directory)
|
||||||
|
|
||||||
print('Reading Doxygen output')
|
print('Reading Doxygen output')
|
||||||
|
|
||||||
|
doc_builder.EMIT_WARNINGS = False
|
||||||
|
|
||||||
doc_builder.run(
|
doc_builder.run(
|
||||||
project_path,
|
project_path,
|
||||||
temp_directory,
|
temp_directory,
|
||||||
@@ -205,11 +213,23 @@ else:
|
|||||||
f.write(index_data.encode('utf-8'))
|
f.write(index_data.encode('utf-8'))
|
||||||
|
|
||||||
# BUILD HTML
|
# BUILD HTML
|
||||||
|
# This version of get_version() works correctly under Windows and Linux.
|
||||||
|
# Credit: @kdschlosser
|
||||||
def get_version():
|
def get_version():
|
||||||
_, ver = subprocess.getstatusoutput("../scripts/find_version.sh")
|
path = os.path.join(project_path, 'lv_version.h')
|
||||||
return ver
|
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(
|
cmd('sphinx-build -b html "{src}" "{dst}" -D version="{version}" -E -j {cpu}'.format(
|
||||||
src=html_src_path,
|
src=html_src_path,
|
||||||
|
|||||||
@@ -1134,6 +1134,11 @@ def iter_src(n, p):
|
|||||||
|
|
||||||
|
|
||||||
def clean_name(nme):
|
def clean_name(nme):
|
||||||
|
# Handle error:
|
||||||
|
# AttributeError: 'NoneType' object has no attribute 'startswith'
|
||||||
|
if nme is None:
|
||||||
|
return nme
|
||||||
|
|
||||||
if nme.startswith('_lv_'):
|
if nme.startswith('_lv_'):
|
||||||
nme = nme[4:]
|
nme = nme[4:]
|
||||||
elif nme.startswith('lv_'):
|
elif nme.startswith('lv_'):
|
||||||
@@ -1146,6 +1151,11 @@ def clean_name(nme):
|
|||||||
|
|
||||||
|
|
||||||
def is_name_match(item_name, obj_name):
|
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
|
u_num = item_name.count('_') + 1
|
||||||
|
|
||||||
obj_name = obj_name.split('_')
|
obj_name = obj_name.split('_')
|
||||||
@@ -1207,7 +1217,7 @@ class XMLSearch(object):
|
|||||||
|
|
||||||
status, br = subprocess.getstatusoutput("git branch")
|
status, br = subprocess.getstatusoutput("git branch")
|
||||||
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
|
_, gitcommit = subprocess.getstatusoutput("git rev-parse HEAD")
|
||||||
br = re.sub('\* ', '', br)
|
br = re.sub(r'\* ', '', br)
|
||||||
|
|
||||||
urlpath = re.sub('release/', '', 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):
|
if not os.path.exists(api_path):
|
||||||
os.makedirs(api_path)
|
os.makedirs(api_path)
|
||||||
|
|
||||||
|
# Generate .RST files for API pages.
|
||||||
iter_src('API', '')
|
iter_src('API', '')
|
||||||
index = load_xml('index')
|
index = load_xml('index')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user