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

Attaches matching docs to model names and columns. #1043

Closed

Conversation

jakebiesinger
Copy link

@jakebiesinger jakebiesinger commented Oct 3, 2018

NOTE: the first commit is part of PR #1042. Once that is in, I can rebase/squash.

Without specifying anything in a schema.yml file, we now:

  • Attach docs to models whose doc name matches the model name,
    regardless of where they are defined.
  • Attach column docs following the nomenclature {% docs <model_name>__<column_name> %} (that's two underscores)

I would have liked to use a . instead of __ to indicate model columns, but . has special jinja meaning.

Closes #979.

Jake Biesinger added 2 commits October 3, 2018 07:10
Since the .sql files have macros that aren't available to the docs
parser (e.g., `ref`), we can instead get the AST for the docs macros and
directly read out the contents without rendering them.

This assumes that when people write `docs` blocks, they don't contain to
any other macros or other Jinja tomfoolery. It's hard for me to tell if
that's a reasonable assumption or not.

Relevant to dbt-labs#979
Without specifying anything in a schema.yml file, we now:
 - Attach docs to models whose doc name matches the model name,
regardless of where they are defined.
 - Attach column docs following the nomenclature `{% docs
<model_name>__<column_name> %}` (that's two underscores)
@drewbanin
Copy link
Contributor

Thanks for the PR @jakebiesinger. Let's discuss #1042 before following up on this one. I imagine that conversation will impact the eventual discussion for this PR

@drewbanin
Copy link
Contributor

@jakebiesinger I'm coming around on a syntax like this:

{% docs model_name__column_name %}
... markdown here...
{% enddocs %}

I think the double underscore delimiter is probably not ideal, as those characters can appear in either model names or columns, and would likely break this approach. We could use a . or a :, but I think we'd need to update the docs parser accordingly.

This PR does a fair amount of jinja ast hacking (based on #1042). I'm going to go ahead and close this since it's pretty out of date at this point, but I think this is a great start. Drop me a line in Slack if you're interested in revisiting this and we can discuss some alternative approaches!

@drewbanin drewbanin closed this Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants