You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -24,14 +27,16 @@ import CopilotBeta from '/snippets/_dbt-copilot-avail.md';
24
27
25
28
## Overview
26
29
27
-
dbt provides a way to generate documentation for your dbt project. The documentation for your project includes:
30
+
dbt provides a scalable way to [generate](#generating-documentation) documentation for your dbt project using descriptions and commands. The documentation for your project includes:
28
31
***Information about your project**: including model code, a DAG of your project, any tests you've added to a column, and more.
29
32
***Information about your <Termid="data-warehouse" />**: including column data types, and <Termid="table" /> sizes. This information is generated by running queries against the information schema.
33
+
* Importantly, dbt also provides a way to add **descriptions** to models, columns, sources, and more, to further enhance your documentation.
30
34
31
-
Importantly, dbt also provides a way to add **descriptions** to models, columns, sources, and more, to further enhance your documentation.
35
+
The following sections describe how to [add descriptions](#adding-descriptions-to-your-project) to your project, [generate documentation](#generating-documentation), how to use [docs blocks](#using-docs-blocks), and set a [custom overview](#setting-a-custom-overview) for your documentation.
32
36
33
37
## Adding descriptions to your project
34
-
To add descriptions to your project, use the `description:` key in the same files where you declare [tests](/docs/build/data-tests), like so:
38
+
39
+
Before generating documentation, add [descriptions](/reference/resource-properties/description) to your project resources. Add the `description:` key to the same YAML files where you declare [tests](/docs/build/data-tests). For example:
35
40
36
41
<Filename='models/<filename>.yml'>
37
42
@@ -56,33 +61,42 @@ models:
56
61
- not_null
57
62
58
63
```
59
-
60
64
</File>
61
65
62
-
## Generating project documentation
63
66
64
-
The default documentation experience in dbt Cloud is [dbt Explorer](/docs/collaborate/explore-projects), available on [Team or Enterprise plans](https://www.getdbt.com/pricing/). Use dbt Explorer to view your project's resources (such as models, tests, and metrics), its [metadata](/docs/collaborate/explore-projects#generate-metadata), and their lineage to gain a better understanding of its latest production state.
67
+
### FAQs
68
+
<FAQpath="Project/example-projects"alt_header="Are there any example dbt documentation sites?"/>
69
+
<FAQpath="Docs/document-all-columns" />
70
+
<FAQpath="Docs/long-descriptions" />
71
+
<FAQpath="Docs/sharing-documentation" />
72
+
<FAQpath="Docs/document-other-resources" />
65
73
66
-
dbt Cloud developer and dbt Core users can use [dbt Docs](/docs/collaborate/build-and-view-your-docs#dbt-docs), which generates basic documentation, but doesn't offer the same speed, metadata, or visibility as dbt Explorer.
74
+
## Generating documentation
67
75
68
76
Generate documentation for your project by following these steps:
69
77
70
-
1. Run `dbt docs generate`— this command tells dbt to compile relevant information about your dbt project and warehouse into `manifest.json` and `catalog.json` files, respectively.
71
-
2. Ensure you've created the models with `dbt run` to view the documentation for all columns, not just those described in your project.
72
-
3. Run `dbt docs serve` if you're developing locally to use these `.json` files to populate a local website.
78
+
1. Run the `dbt docs generate`[command](/reference/commands/cmd-docs#dbt-docs-generate) to compile relevant information about your dbt project and warehouse into `manifest.json` and `catalog.json` files, respectively.
79
+
2. Ensure you've created the models with `dbt run`or `dbt build`to view the documentation for all columns, not just those described in your project.
80
+
3. Run the `dbt docs serve`[command](/reference/commands/cmd-docs#dbt-docs-serve) if you're developing locally to use these `.json` files to populate a local website.
73
81
74
-
To view a resource, its metadata, and what commands are needed in dbt Explorer, refer to [generate metadata](/docs/collaborate/explore-projects#generate-metadata) for more details.
82
+
dbt provides two complementary ways to [view documentation](/docs/build/view-documentation), and your descriptions, after it's generated:
75
83
76
-
## FAQs
77
-
<FAQpath="Project/example-projects"alt_header="Are there any example dbt documentation sites?"/>
78
-
<FAQpath="Docs/document-all-columns" />
79
-
<FAQpath="Docs/long-descriptions" />
80
-
<FAQpath="Docs/sharing-documentation" />
81
-
<FAQpath="Docs/document-other-resources" />
84
+
-[**dbt Docs**:](/docs/build/view-documentation#dbt-docs) A static documentation site with model lineage, metadata, and documentation that can be hosted on your web server (like S3 or Netlify). Available for dbt Core or dbt Cloud Developer plans.
85
+
-[**dbt Explorer**](/docs/collaborate/explore-projects): Builds upon dbt Docs to provide a dynamic, real-time interface with enhanced metadata, customizable views, deeper project insights, and collaboration tools. Available on dbt Cloud Team or Enterprise plans.
86
+
87
+
See [View documentation](/docs/build/view-documentation) to get the most out of your dbt project's documentation.
82
88
83
89
## Using docs blocks
90
+
91
+
Docs blocks provide a robust method for documenting models and other resources using Jinja and markdown. Docs block files can contain arbitrary markdown, but they must be uniquely named.
92
+
84
93
### Syntax
85
-
To declare a docs block, use the jinja `docs` tag. Docs blocks can contain arbitrary markdown, but they must be uniquely named. Their names may contain uppercase and lowercase letters (A-Z, a-z), digits (0-9), and underscores (_), but can't start with a digit.
94
+
To declare a docs block, use the Jinja `docs` tag. Their names may contain:
95
+
96
+
- Can't start with a digit
97
+
- Uppercase and lowercase letters (A-Z, a-z)
98
+
- Digits (0-9)
99
+
- Underscores (_)
86
100
87
101
<Filename='events.md'>
88
102
@@ -102,7 +116,7 @@ The events in this table are recorded by [Snowplow](http://github.com/snowplow/s
102
116
103
117
</File>
104
118
105
-
In the above example, a docs block named `table_events` is defined with some descriptive markdown contents. There is nothing significant about the name `table_events` — docs blocks can be named however you like, as long as the name only contains alphanumeric and underscore characters and does not start with a numeric character.
119
+
In this example, a docs block named `table_events` is defined with some descriptive markdown contents. There is nothing significant about the name `table_events` — docs blocks can be named however you like, as long as the name only contains alphanumeric and underscore characters and doesn't start with a numeric character.
106
120
107
121
### Placement
108
122
@@ -118,9 +132,8 @@ Docs blocks should be placed in files with a `.md` file extension. By default, d
118
132
119
133
</VersionBlock>
120
134
121
-
122
135
### Usage
123
-
To use a docs block, reference it from your `schema.yml` file with the [doc()](/reference/dbt-jinja-functions/doc) function in place of a markdown string. Using the examples above, the `table_events` docs can be included in the `schema.yml` file as shown below:
136
+
To use a docs block, reference it from your `schema.yml` file with the [doc()](/reference/dbt-jinja-functions/doc) function in place of a markdown string. Using the examples above, the `table_events` docs can be included in the `schema.yml` file as shown here:
124
137
125
138
<Filename='schema.yml'>
126
139
@@ -147,7 +160,11 @@ In the resulting documentation, `'{{ doc("table_events") }}'` will be expanded t
147
160
## Setting a custom overview
148
161
*Currently available for dbt Docs only.*
149
162
150
-
The "overview" shown in the dbt Docs website can be overridden by supplying your own docs block called `__overview__`. By default, dbt supplies an overview with helpful information about the docs site itself. Depending on your needs, it may be a good idea to override this docs block with specific information about your company style guide, links to reports, or information about who to contact for help. To override the default overview, create a docs block that looks like this:
163
+
The "overview" shown in the dbt Docs website can be overridden by supplying your own docs block called `__overview__`.
164
+
165
+
- By default, dbt supplies an overview with helpful information about the docs site itself.
166
+
- Depending on your needs, it may be a good idea to override this docs block with specific information about your company style guide, links to reports, or information about who to contact for help.
167
+
- To override the default overview, create a docs block that looks like this:
151
168
152
169
<File name='models/overview.md'>
153
170
@@ -168,7 +185,9 @@ as well as the repo for this project \[here](https://github.com/dbt-labs/mrr-pla
168
185
*Currently available for dbt Docs only.*
169
186
170
187
You can set different overviews for each dbt project/package included in your documentation site
171
-
by creating a docs block named `__[project_name]__`. For example, in order to define
188
+
by creating a docs block named `__[project_name]__`.
189
+
190
+
For example, in order to define
172
191
custom overview pages that appear when a viewer navigates inside the `dbt_utils` or `snowplow` package:
173
192
174
193
<File name='models/overview.md'>
@@ -190,48 +209,3 @@ up to page views and sessions.
190
209
```
191
210
192
211
</File>
193
-
194
-
## Navigating the documentation site
195
-
196
-
Use [dbt Explorer](/docs/collaborate/explore-projects) for a richer documentation experience and more interactive experience for understanding your project's resources and lineage. Available on [Team or Enterprise plans](https://www.getdbt.com/pricing/).
197
-
198
-
For additional details on how to explore your lineage and navigate your resources, refer to [dbt Explorer](/docs/collaborate/explore-projects).
199
-
200
-
<Lightboxsrc="/img/docs/collaborate/dbt-explorer/example-model-details.png"width="100%"title="Example of resource details" />
201
-
202
-
<Expandablealt_header="For dbt Docs">
203
-
If you're using the dbt Docs interface, you can navigate to the documentation for a specific model. That might look something like this:
204
-
205
-
<Lightboxsrc="/img/docs/building-a-dbt-project/testing-and-documentation/f2221dc-Screen_Shot_2018-08-14_at_6.29.55_PM.png"title="Auto-generated documentation for a dbt model"/>
206
-
207
-
Here, you can see a representation of the project structure, a markdown description for a model, and a list of all of the columns (with documentation) in the model.
208
-
209
-
From the dbt Docs page, you can click the green button in the bottom-right corner of the webpage to expand a "mini-map" of your DAG. This pane (shown below) will display the immediate parents and children of the model that you're exploring.
210
-
211
-
<Lightboxsrc="/img/docs/building-a-dbt-project/testing-and-documentation/ec77c45-Screen_Shot_2018-08-14_at_6.31.56_PM.png"title="Opening the DAG mini-map"/>
212
-
213
-
In this example, the `fct_subscription_transactions` model only has one direct parent. By clicking the "Expand" button in the top-right corner of the window, we can pivot the graph horizontally and view the full <Termid="data-lineage">lineage</Term> for our model. This lineage is filterable using the `--select` and `--exclude` flags, which are consistent with the semantics of [model selection syntax](/reference/node-selection/syntax). Further, you can right-click to interact with the DAG, jump to documentation, or share links to your graph visualization with your coworkers.
214
-
215
-
<Lightboxsrc="/img/docs/building-a-dbt-project/testing-and-documentation/ac97fba-Screen_Shot_2018-08-14_at_6.35.14_PM.png"title="The full lineage for a dbt model"/>
216
-
217
-
</Expandable>
218
-
219
-
## Deploying the documentation site
220
-
221
-
With dbt Cloud, use [dbt Explorer](/docs/collaborate/explore-projects) automatically retrieves the metadata updates after each job run in the production or staging deployment environment so it always has the latest results for your project — meaning it's always automatically updated after each job run.
222
-
223
-
:::caution Security
224
-
225
-
The `dbt docs serve` command is only intended for local/development hosting of the documentation site. Please use one of the methods listed below (or similar) to ensure that your documentation site is hosted securely!
226
-
227
-
:::
228
-
229
-
#### For dbt Docs users
230
-
231
-
dbt's documentation website was built to make it easy to host on the web. The site is "static,” meaning you don't need any "dynamic" servers to serve the docs. You can host your documentation in several ways:
232
-
233
-
* Use [dbt Cloud's](/docs/collaborate/build-and-view-your-docs) default documentation experience with [dbt Explorer](/docs/collaborate/explore-projects).
234
-
* Host on [Amazon S3](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html) (optionally [with IP access restrictions](https://docs.aws.amazon.com/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-3))
235
-
* Publish with [Netlify](https://discourse.getdbt.com/t/publishing-dbt-docs-to-netlify/121)
0 commit comments