Last active
November 10, 2022 20:28
-
-
Save wbamberg/8d98ed36d0b5c722e6b1cca8d7e65d21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os | |
dir = sys.argv[1] | |
entries = os.listdir(dir) | |
total_interfaces = 0 | |
total_interface_members = 0 | |
total_overflow = 0 | |
def get_type(path): | |
lines = open(path).read().splitlines() | |
for line in lines: | |
if line.startswith("page-type:"): | |
return line[len("page-type: "):] | |
return "unknown" | |
def analyze_interface(interface): | |
global total_interface_members, total_overflow | |
static_properties = 0 | |
static_methods = 0 | |
instance_properties = 0 | |
instance_methods = 0 | |
events = 0 | |
members = os.listdir(os.path.join(dir, interface)) | |
members = [item for item in members if not os.path.isfile(os.path.join(dir, entry, item))] | |
total_interface_members = total_interface_members + len(members) | |
for member in members: | |
page_type = get_type(os.path.join(dir, entry, member, "index.md")) | |
if page_type == "web-api-static-property": | |
static_properties = static_properties + 1 | |
if page_type == "web-api-static-method": | |
static_methods = static_methods + 1 | |
if page_type == "web-api-instance-property": | |
instance_properties = instance_properties + 1 | |
if page_type == "web-api-instance-method": | |
instance_methods = instance_methods + 1 | |
if page_type == "web-api-events": | |
events = events + 1 | |
if static_properties > 15: | |
total_overflow = total_overflow + static_properties - 15 | |
if static_methods > 15: | |
total_overflow = total_overflow + static_methods - 15 | |
if instance_properties > 15: | |
total_overflow = total_overflow + instance_properties - 15 | |
if instance_methods > 15: | |
total_overflow = total_overflow + instance_methods - 15 | |
if events > 15: | |
total_overflow = total_overflow + events - 15 | |
for entry in entries: | |
if not os.path.isfile(os.path.join(dir, entry)): | |
page_type = get_type(os.path.join(dir, entry, "index.md")) | |
if (page_type == "web-api-interface"): | |
total_interfaces = total_interfaces + 1 | |
analyze_interface(entry) | |
print(total_interfaces) | |
print(total_interface_members) | |
print(total_overflow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment