-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation for macros/analyses (#1041) #2068
Conversation
core/dbt/contracts/graph/manifest.py
Outdated
patch = patches.pop(node.name, None) | ||
if not patch: | ||
continue | ||
expected_key = node.resource_type.pluralize() | ||
if expected_key == patch.yaml_key: | ||
node.patch(patch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we used to double-patch() - github hides the other call by default
8660f17
to
abab3c7
Compare
I just rebased this against dev/barbara-gittings, resolved a few merge conflicts along the way. |
abab3c7
to
8332674
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Some comments inline on this one, but all really minor.
Some bigger picture thoughts as I looked through this one:
- It would be killer if dbt supported the specification of macro arguments + types in a
macros:
block. This would be really great for things like dbt-utils. We could use this info to render docs + really good editor integrations in the future. I'm going to make a separate issue to track that idea. (Describe macro arguments in schema.yml files #2081) - In testing out this PR, I noticed that macros are not rendering in the
depends_on
list for models in the rendered manifest. I don't know if this is a recent regression (it definitely was not introduced in this branch), but it's worth fixing so that we can render the referenced macros for a model in the docs site. I'll create a new issue for that one too. (Add macros to depends_on list for nodes that can call macros #2082) - Another one from testing: If a
description:
is provided which contains adoc()
call, then the docs are rendered with jinja. If the description instead contains an arbitrary jinja expression (eg.{{ 1 + 1}}
) then dbt renders that literal string{{ 1 + 1 }}
into the description field for the node. That's pretty weird, right? I will.... create an issue :) (Weird rendering behavior for schema.yml descriptions #2083)
core/dbt/contracts/graph/manifest.py
Outdated
# target_not_found warning | ||
logger.debug(( | ||
'WARNING: Found documentation for macro "{}" which was ' | ||
'not found or is disabled').format(patch.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'not found or is disabled').format(patch.name) | |
'not found').format(patch.name) |
core/dbt/contracts/graph/manifest.py
Outdated
for patch in patches.values(): | ||
# since patches aren't nodes, we can't use the existing | ||
# target_not_found warning | ||
logger.debug(( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we elevate this to a proper warning?
core/dbt/exceptions.py
Outdated
raise_compiler_error( | ||
f'dbt found two schema.yml entries for the same macro in package ' | ||
f'{package_name} named {name}. Macros may only be described a single ' | ||
f'time. To fix this, remove the macros entry for for {name} in one ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f'time. To fix this, remove the macros entry for for {name} in one ' | |
f'time. To fix this, remove the macros entry for {name} in one ' |
Refactored parsing a bit to support the idea of: - macro patches (no columns) - node patches that don't get tests (analyses)
8332674
to
704b345
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ship it when the tests pass!
704b345
to
04ebdbb
Compare
Fixes #1041
Add and populate a
documentation
field to macrosPopulate the
documentation
field on analyses like we do with models/seeds/snapshotsRefactored parsing a bit to support the idea of: