From d72e9a187c2a2d9be06d37b37b6b855bb17d96e7 Mon Sep 17 00:00:00 2001 From: mirnawong1 Date: Thu, 20 Jun 2024 15:17:12 +0100 Subject: [PATCH] add --- website/docs/reference/about-resources.md | 5 ++-- website/scripts/update_node_resource_table.py | 30 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/website/docs/reference/about-resources.md b/website/docs/reference/about-resources.md index b42ac577cda..d1eeb74c482 100644 --- a/website/docs/reference/about-resources.md +++ b/website/docs/reference/about-resources.md @@ -7,7 +7,7 @@ sidebar_label: "About resource types" dbt supports different types of resource types. Each one has a set of supported [properties and configurations](/reference/configs-and-properties) within a dbt project, which are key to how they function and integrate within your data project. - +## Resource types The following tables describes each resource type, its identifier, and a brief description of its purpose. @@ -61,8 +61,7 @@ Properties or configurations support different resource types and are applied in | | | | | | | Special Properties | description, tests, docs, columns, quote, source properties, exposure properties, macro properties | | `properties.yml` | - - ## Related docs - [About resource paths](/reference/resource-configs/resource-path) - [About configs and properties](/reference/configs-and-properties) + diff --git a/website/scripts/update_node_resource_table.py b/website/scripts/update_node_resource_table.py index 665046cbf5d..47b402e6a4b 100644 --- a/website/scripts/update_node_resource_table.py +++ b/website/scripts/update_node_resource_table.py @@ -20,8 +20,8 @@ def extract_resource_types(tree): for item in node.body: if isinstance(item, ast.Assign): for target in item.targets: - if isinstance(target, ast.Name): - resource_types[target.id] = item.value.value + if isinstance(target, ast.Name) and isinstance(item.value, ast.Constant): + resource_types[target.id.lower()] = item.value.value.lower() return resource_types def extract_node_type_lists(tree): @@ -31,12 +31,18 @@ def extract_node_type_lists(tree): for node in tree.body: if isinstance(node, ast.Assign): for target in node.targets: - if target.id == "EXECUTABLE_NODE_TYPES": - executable_nodes = [elt.attr.lower() for elt in node.value.elts if isinstance(elt, ast.Attribute)] - elif target.id == "REFABLE_NODE_TYPES": - refable_nodes = [elt.attr.lower() for elt in node.value.elts if isinstance(elt, ast.Attribute)] - elif target.id == "VERSIONED_NODE_TYPES": - versioned_nodes = [elt.attr.lower() for elt in node.value.elts if isinstance(elt, ast.Attribute)] + if isinstance(target, ast.Name): + if target.id == "EXECUTABLE_NODE_TYPES": + executable_nodes = [elt.attr for elt in node.value.elts if isinstance(elt, ast.Attribute)] + elif target.id == "REFABLE_NODE_TYPES": + refable_nodes = [elt.attr for elt in node.value.elts if isinstance(elt, ast.Attribute)] + elif target.id == "VERSIONED_NODE_TYPES": + versioned_nodes = [elt.attr for elt in node.value.elts if isinstance(elt, ast.Attribute)] + # Print debug information + print("Raw Executable Nodes:", executable_nodes) + print("Raw Refable Nodes:", refable_nodes) + print("Raw Versioned Nodes:", versioned_nodes) + return executable_nodes, refable_nodes, versioned_nodes # Extract resource types and node types @@ -54,6 +60,9 @@ def extract_node_type_lists(tree): # Debugging output print("Resource Types:", resource_types) +print("Executable Nodes:", executable_nodes) +print("Refable Nodes:", refable_nodes) +print("Versioned Nodes:", versioned_nodes) print("Node Types:", node_types) # Generate the markdown content @@ -76,7 +85,7 @@ def generate_markdown(resource_types, node_types): if node_types.get(value, {}).get('executable', False): versioned_ref_exec.append("Executable") versioned_ref_exec_str = ", ".join(versioned_ref_exec) - markdown_content += f"| {resource} | {executed} | {exists} | {created} | {upstream} | {downstream} | {versioned_ref_exec_str} |\n" + markdown_content += f"| {value} | {executed} | {exists} | {created} | {upstream} | {downstream} | {versioned_ref_exec_str} |\n" return markdown_content @@ -91,7 +100,8 @@ def generate_markdown(resource_types, node_types): # Insert the markdown table content under the specified header header = "## Resource types" if header in content: - content = content.replace(header, f"{header}\n\n{markdown_table_content}") + header_index = content.index(header) + len(header) + content = content[:header_index] + f"\n\n{markdown_table_content}" + content[header_index:] else: content += f"\n{header}\n\n{markdown_table_content}"