Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Jun 20, 2024
1 parent 40d94e5 commit d72e9a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
5 changes: 2 additions & 3 deletions website/docs/reference/about-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)

30 changes: 20 additions & 10 deletions website/scripts/update_node_resource_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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}"

Expand Down

0 comments on commit d72e9a1

Please sign in to comment.