Skip to content

Commit

Permalink
Revert "Add doc_blocks to manifest for nodes and columns (#11224)"
Browse files Browse the repository at this point in the history
This reverts commit d71f309.
  • Loading branch information
aranke committed Feb 7, 2025
1 parent 588cbab commit 02b85cb
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 476 deletions.
6 changes: 0 additions & 6 deletions .changes/unreleased/Features-20250122-170328.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions core/dbt/artifacts/resources/v1/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class ColumnInfo(AdditionalPropertiesMixin, ExtensibleDbtClassMixin):
tags: List[str] = field(default_factory=list)
_extra: Dict[str, Any] = field(default_factory=dict)
granularity: Optional[TimeGranularity] = None
doc_blocks: List[str] = field(default_factory=list)


@dataclass
Expand Down Expand Up @@ -198,7 +197,6 @@ class ParsedResource(ParsedResourceMandatory):
unrendered_config_call_dict: Dict[str, Any] = field(default_factory=dict)
relation_name: Optional[str] = None
raw_code: str = ""
doc_blocks: List[str] = field(default_factory=list)

def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
Expand Down
1 change: 0 additions & 1 deletion core/dbt/artifacts/resources/v1/source_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ class SourceDefinition(ParsedSourceMandatory):
created_at: float = field(default_factory=lambda: time.time())
unrendered_database: Optional[str] = None
unrendered_schema: Optional[str] = None
doc_blocks: List[str] = field(default_factory=list)
65 changes: 12 additions & 53 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union

import msgpack
from jinja2.nodes import Call

import dbt.deprecations
import dbt.exceptions
Expand Down Expand Up @@ -116,7 +115,6 @@
from dbt.parser.sources import SourcePatcher
from dbt.parser.unit_tests import process_models_for_unit_test
from dbt.version import __version__
from dbt_common.clients.jinja import parse
from dbt_common.clients.system import make_directory, path_exists, read_json, write_file
from dbt_common.constants import SECRET_ENV_PREFIX
from dbt_common.dataclass_schema import StrEnum, dbtClassMixin
Expand Down Expand Up @@ -1242,7 +1240,7 @@ def process_docs(self, config: RuntimeConfig):
self.manifest,
config.project_name,
)
_process_docs_for_node(ctx, node, self.manifest)
_process_docs_for_node(ctx, node)

Check warning on line 1243 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L1243

Added line #L1243 was not covered by tests
for source in self.manifest.sources.values():
if source.created_at < self.started_at:
continue
Expand All @@ -1252,7 +1250,7 @@ def process_docs(self, config: RuntimeConfig):
self.manifest,
config.project_name,
)
_process_docs_for_source(ctx, source, self.manifest)
_process_docs_for_source(ctx, source)

Check warning on line 1253 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L1253

Added line #L1253 was not covered by tests
for macro in self.manifest.macros.values():
if macro.created_at < self.started_at:
continue
Expand Down Expand Up @@ -1659,71 +1657,32 @@ def _check_manifest(manifest: Manifest, config: RuntimeConfig) -> None:
DocsContextCallback = Callable[[ResultNode], Dict[str, Any]]


def _get_doc_blocks(description: str, manifest: Manifest, node_package: str) -> List[str]:
ast = parse(description)
doc_blocks: List[str] = []

if not hasattr(ast, "body"):
return doc_blocks

for statement in ast.body:
for node in statement.nodes:
if (
isinstance(node, Call)
and hasattr(node, "node")
and hasattr(node, "args")
and node.node.name == "doc"
):
doc_args = [arg.value for arg in node.args]

if len(doc_args) == 1:
package, name = None, doc_args[0]
elif len(doc_args) == 2:
package, name = doc_args
else:
continue

if not manifest.metadata.project_name:
continue

resolved_doc = manifest.resolve_doc(
name, package, manifest.metadata.project_name, node_package
)

if resolved_doc:
doc_blocks.append(resolved_doc.unique_id)

return doc_blocks


# node and column descriptions
def _process_docs_for_node(
context: Dict[str, Any],
node: ManifestNode,
manifest: Manifest,
):
node.doc_blocks = _get_doc_blocks(node.description, manifest, node.package_name)
node.description = get_rendered(node.description, context)

for column_name, column in node.columns.items():
column.doc_blocks = _get_doc_blocks(column.description, manifest, node.package_name)
column.description = get_rendered(column.description, context)


# source and table descriptions, column descriptions
def _process_docs_for_source(
context: Dict[str, Any],
source: SourceDefinition,
manifest: Manifest,
):
source.doc_blocks = _get_doc_blocks(source.description, manifest, source.package_name)
source.description = get_rendered(source.description, context)

source.source_description = get_rendered(source.source_description, context)
table_description = source.description
source_description = source.source_description
table_description = get_rendered(table_description, context)
source_description = get_rendered(source_description, context)
source.description = table_description
source.source_description = source_description

Check warning on line 1680 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L1675-L1680

Added lines #L1675 - L1680 were not covered by tests

for column in source.columns.values():
column.doc_blocks = _get_doc_blocks(column.description, manifest, source.package_name)
column.description = get_rendered(column.description, context)
column_desc = column.description
column_desc = get_rendered(column_desc, context)
column.description = column_desc

Check warning on line 1685 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L1683-L1685

Added lines #L1683 - L1685 were not covered by tests


# macro argument descriptions
Expand Down Expand Up @@ -2081,7 +2040,7 @@ def process_node(config: RuntimeConfig, manifest: Manifest, node: ManifestNode):
_process_sources_for_node(manifest, config.project_name, node)
_process_refs(manifest, config.project_name, node, config.dependencies)
ctx = generate_runtime_docs_context(config, node, manifest, config.project_name)
_process_docs_for_node(ctx, node, manifest)
_process_docs_for_node(ctx, node)

Check warning on line 2043 in core/dbt/parser/manifest.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/parser/manifest.py#L2043

Added line #L2043 was not covered by tests


def write_semantic_manifest(manifest: Manifest, target_path: str) -> None:
Expand Down
Loading

0 comments on commit 02b85cb

Please sign in to comment.