Skip to content
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

Merged
merged 2 commits into from
Jan 31, 2020

Conversation

beckjake
Copy link
Contributor

Fixes #1041

Add and populate a documentation field to macros
Populate the documentation field on analyses like we do with models/seeds/snapshots

  • also support documenting columns, etc

Refactored parsing a bit to support the idea of:

  • macro patches (no columns, to tests)
  • analysis patches (no tests)

@cla-bot cla-bot bot added the cla:yes label Jan 24, 2020
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)
Copy link
Contributor Author

@beckjake beckjake Jan 24, 2020

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

@beckjake beckjake changed the base branch from feature/docs-for-everyone to dev/barbara-gittings January 24, 2020 16:46
@beckjake
Copy link
Contributor Author

I just rebased this against dev/barbara-gittings, resolved a few merge conflicts along the way.

Copy link
Contributor

@drewbanin drewbanin left a 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 a doc() 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)

# target_not_found warning
logger.debug((
'WARNING: Found documentation for macro "{}" which was '
'not found or is disabled').format(patch.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'not found or is disabled').format(patch.name)
'not found').format(patch.name)

for patch in patches.values():
# since patches aren't nodes, we can't use the existing
# target_not_found warning
logger.debug((
Copy link
Contributor

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?

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 '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Contributor

@drewbanin drewbanin left a 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!

@beckjake beckjake merged commit 5b65591 into dev/barbara-gittings Jan 31, 2020
@beckjake beckjake deleted the feature/macro-docs branch January 31, 2020 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants