forked from blender/blender
me-main #1
@ -4,13 +4,15 @@
|
|||||||
# ./blender.bin --background -noaudio --python tests/python/bl_rna_manual_reference.py
|
# ./blender.bin --background -noaudio --python tests/python/bl_rna_manual_reference.py
|
||||||
#
|
#
|
||||||
# 1) test_data() -- ensure the data we have is correct format
|
# 1) test_data() -- ensure the data we have is correct format
|
||||||
# 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path
|
# 2) test_lookup_coverage() -- ensure that we have lookups for _every_ RNA path and all patterns are used.
|
||||||
# 3) test_urls() -- ensure all the URL's are correct
|
# 3) test_urls() -- ensure all the URL's are correct
|
||||||
# 4) test_language_coverage() -- ensure language lookup table is complete
|
# 4) test_language_coverage() -- ensure language lookup table is complete
|
||||||
#
|
#
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
|
||||||
|
VERBOSE = False
|
||||||
|
|
||||||
|
|
||||||
def test_data():
|
def test_data():
|
||||||
import rna_manual_reference
|
import rna_manual_reference
|
||||||
@ -28,6 +30,21 @@ def test_data():
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def lookup_rna_url(rna_id, visit_indices):
|
||||||
|
"""
|
||||||
|
A local version of ``WM_OT_doc_view_manual._lookup_rna_url``
|
||||||
|
that tracks which matches are found.
|
||||||
|
"""
|
||||||
|
import rna_manual_reference
|
||||||
|
from fnmatch import fnmatchcase
|
||||||
|
rna_id = rna_id.lower()
|
||||||
|
for i, (pattern, url_suffix) in enumerate(rna_manual_reference.url_manual_mapping):
|
||||||
|
if fnmatchcase(rna_id, pattern):
|
||||||
|
visit_indices.add(i)
|
||||||
|
return rna_manual_reference.url_manual_prefix + url_suffix
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# a stripped down version of api_dump() in rna_info_dump.py
|
# a stripped down version of api_dump() in rna_info_dump.py
|
||||||
def test_lookup_coverage():
|
def test_lookup_coverage():
|
||||||
|
|
||||||
@ -51,14 +68,37 @@ def test_lookup_coverage():
|
|||||||
set_group_all = set()
|
set_group_all = set()
|
||||||
set_group_doc = set()
|
set_group_doc = set()
|
||||||
|
|
||||||
|
visit_indices = set()
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("----------------------------------")
|
||||||
|
print("RNA Patterns Unknown to the Manual")
|
||||||
|
|
||||||
|
unknown_rna_list = []
|
||||||
|
|
||||||
for rna_group, rna_id in rna_ids():
|
for rna_group, rna_id in rna_ids():
|
||||||
url = wm.WM_OT_doc_view_manual._lookup_rna_url(rna_id, verbose=False)
|
# Correct but slower & doesn't track usage.
|
||||||
print(rna_id, "->", url)
|
# url = wm.WM_OT_doc_view_manual._lookup_rna_url(rna_id, verbose=False)
|
||||||
|
url = lookup_rna_url(rna_id, visit_indices)
|
||||||
|
|
||||||
|
if VERBOSE:
|
||||||
|
print(rna_id, "->", url)
|
||||||
|
else:
|
||||||
|
print(rna_id)
|
||||||
|
|
||||||
set_group_all.add(rna_group)
|
set_group_all.add(rna_group)
|
||||||
if url is not None:
|
if url is not None:
|
||||||
set_group_doc.add(rna_group)
|
set_group_doc.add(rna_group)
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("---------------------------------------")
|
||||||
|
print("Unused RNA Patterns Known to the Manual")
|
||||||
|
|
||||||
|
import rna_manual_reference
|
||||||
|
for i, (pattern, url_suffix) in enumerate(rna_manual_reference.url_manual_mapping):
|
||||||
|
if i not in visit_indices:
|
||||||
|
print(pattern, url_suffix)
|
||||||
|
|
||||||
# finally report undocumented groups
|
# finally report undocumented groups
|
||||||
print("")
|
print("")
|
||||||
print("---------------------")
|
print("---------------------")
|
||||||
@ -103,13 +143,16 @@ def test_urls():
|
|||||||
if LOCAL_PREFIX:
|
if LOCAL_PREFIX:
|
||||||
for url in sorted(urls):
|
for url in sorted(urls):
|
||||||
url_full = os.path.join(LOCAL_PREFIX, url.partition("#")[0])
|
url_full = os.path.join(LOCAL_PREFIX, url.partition("#")[0])
|
||||||
print(" %s ... " % url_full, end="")
|
|
||||||
if os.path.exists(url_full):
|
if os.path.exists(url_full):
|
||||||
print(color_green + "OK" + color_normal)
|
if VERBOSE:
|
||||||
|
print(" %s ... " % url_full, end="")
|
||||||
|
print(color_green + "OK" + color_normal)
|
||||||
else:
|
else:
|
||||||
|
print(" %s ... " % url_full, end="")
|
||||||
print(color_red + "FAIL!" + color_normal)
|
print(color_red + "FAIL!" + color_normal)
|
||||||
urls_fail.append(url)
|
urls_fail.append(url)
|
||||||
else:
|
elif False:
|
||||||
|
# URL lookups are too slow to be practical.
|
||||||
for url in sorted(urls):
|
for url in sorted(urls):
|
||||||
url_full = prefix + url
|
url_full = prefix + url
|
||||||
print(" %s ... " % url_full, end="")
|
print(" %s ... " % url_full, end="")
|
||||||
@ -120,6 +163,8 @@ def test_urls():
|
|||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
print(color_red + "FAIL!" + color_normal)
|
print(color_red + "FAIL!" + color_normal)
|
||||||
urls_fail.append(url)
|
urls_fail.append(url)
|
||||||
|
else:
|
||||||
|
print("Skipping URL lookups, define LOCAL_PREFIX env variable, and point it to a manual build!")
|
||||||
|
|
||||||
if urls_fail:
|
if urls_fail:
|
||||||
urls_len = "%d" % len(urls_fail)
|
urls_len = "%d" % len(urls_fail)
|
||||||
|
Loading…
Reference in New Issue
Block a user