Skip to content

Commit

Permalink
add relative path snippet (#6547)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Nov 27, 2024
2 parents 4eefa2c + 6a0551e commit 96df61e
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 7 deletions.
23 changes: 21 additions & 2 deletions website/docs/reference/project-configs/analysis-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,31 @@ analysis-paths: [directorypath]
</File>
## Definition
Specify a custom list of directories where [analyses](/docs/build/analyses) are located.
Specify a custom list of directories where [analyses](/docs/build/analyses) are located.
## Default
Without specifying this config, dbt will not compile any `.sql` files as analyses.

However, the [`dbt init` command](/reference/commands/init) populates this value as `analyses` ([source](https://github.com/dbt-labs/dbt-starter-project/blob/HEAD/dbt_project.yml#L15))
However, the [`dbt init` command](/reference/commands/init) populates this value as `analyses` ([source](https://github.com/dbt-labs/dbt-starter-project/blob/HEAD/dbt_project.yml#L15)).

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="analysis-paths"
absolute="/Users/username/project/analyses"
/>

- ✅ **Do**
- Use relative path:
```yml
analysis-paths: ["analyses"]
```

- ❌ **Don't**
- Avoid absolute paths:
```yml
analysis-paths: ["/Users/username/project/analyses"]
```

## Examples
### Use a subdirectory named `analyses`
Expand Down
23 changes: 22 additions & 1 deletion website/docs/reference/project-configs/asset-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,29 @@ asset-paths: [directorypath]
## Definition
Optionally specify a custom list of directories to copy to the `target` directory as part of the `docs generate` command. This is useful for rendering images in your repository in your project documentation.


## Default
By default, dbt will not copy any additional files as part of docs generate, i.e. `asset-paths: []`

By default, dbt will not copy any additional files as part of docs generate. For example, `asset-paths: []`.

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="asset-paths"
absolute="/Users/username/project/assets"
/>

- ✅ **Do**
- Use relative path:
```yml
asset-paths: ["assets"]
```

- ❌ **Don't**
- Avoid absolute paths:
```yml
asset-paths: ["/Users/username/project/assets"]
```

## Examples
### Compile files in the `assets` subdirectory as part of `docs generate`
Expand Down
19 changes: 19 additions & 0 deletions website/docs/reference/project-configs/docs-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ By default, dbt will search in all resource paths for docs blocks (i.e. the comb
</VersionBlock>
import RelativePath from '/snippets/_relative-path.md';
<RelativePath
path="docs-paths"
absolute="/Users/username/project/docs"
/>
- ✅ **Do**
- Use relative path:
```yml
docs-paths: ["docs"]
```
- ❌ **Don't**
- Avoid absolute paths:
```yml
docs-paths: ["/Users/username/project/docs"]
```
## Example
Use a subdirectory named `docs` for docs blocks:
Expand Down
21 changes: 20 additions & 1 deletion website/docs/reference/project-configs/macro-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ macro-paths: [directorypath]
Optionally specify a custom list of directories where [macros](/docs/build/jinja-macros#macros) are located. Note that you cannot co-locate models and macros.
## Default
By default, dbt will search for macros in a directory named `macros`, i.e. `macro-paths: ["macros"]`
By default, dbt will search for macros in a directory named `macros`. For example, `macro-paths: ["macros"]`.

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="macro-paths"
absolute="/Users/username/project/macros"
/>

- ✅ **Do**
- Use relative path:
```yml
macro-paths: ["macros"]
```

- ❌ **Don't:**
- Avoid absolute paths:
```yml
macro-paths: ["/Users/username/project/macros"]
```

## Examples
### Use a subdirectory named `custom_macros` instead of `macros`
Expand Down
21 changes: 20 additions & 1 deletion website/docs/reference/project-configs/model-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ model-paths: [directorypath]
Optionally specify a custom list of directories where [models](/docs/build/models) and [sources](/docs/build/sources) are located.
## Default
By default, dbt will search for models and sources in the `models` directory, i.e. `model-paths: ["models"]`
By default, dbt will search for models and sources in the `models` directory. For example, `model-paths: ["models"]`.

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="model-paths"
absolute="/Users/username/project/models"
/>

- ✅ **Do**
- Use relative path:
```yml
model-paths: ["models"]
```

- ❌ **Don't:**
- Avoid absolute paths:
```yml
model-paths: ["/Users/username/project/models"]
```

## Examples
### Use a subdirectory named `transformations` instead of `models`
Expand Down
21 changes: 20 additions & 1 deletion website/docs/reference/project-configs/seed-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ Optionally specify a custom list of directories where [seed](/docs/build/seeds)
## Default
By default, dbt expects seeds to be located in the `seeds` directory, i.e. `seed-paths: ["seeds"]`
By default, dbt expects seeds to be located in the `seeds` directory. For example, `seed-paths: ["seeds"]`.

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="seed-paths"
absolute="/Users/username/project/seed"
/>

- ✅ **Do**
- Use relative path:
```yml
seed-paths: ["seed"]
```

- ❌ **Don't:**
- Avoid absolute paths:
```yml
seed-paths: ["/Users/username/project/seed"]
```

## Examples
### Use a subdirectory named `custom_seeds` instead of `seeds`
Expand Down
22 changes: 21 additions & 1 deletion website/docs/reference/project-configs/snapshot-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,27 @@ Note that you cannot co-locate models and snapshots. However, in [Versionless](/
</VersionBlock>
## Default
By default, dbt will search for snapshots in the `snapshots` directory, i.e. `snapshot-paths: ["snapshots"]`
By default, dbt will search for snapshots in the `snapshots` directory. For example, `snapshot-paths: ["snapshots"]`.


import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="snapshot-paths"
absolute="/Users/username/project/snapshots"
/>

- ✅ **Do**
- Use relative path:
```yml
snapshot-paths: ["snapshots"]
```

- ❌ **Don't:**
- Avoid absolute paths:
```yml
snapshot-paths: ["/Users/username/project/snapshots"]
```

## Examples
### Use a subdirectory named `archives` instead of `snapshots`
Expand Down
19 changes: 19 additions & 0 deletions website/docs/reference/project-configs/test-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ Without specifying this config, dbt will search for tests in the `tests` directo
- Generic test definitions in the `tests/generic` subdirectory
- Singular tests (all other files)

import RelativePath from '/snippets/_relative-path.md';

<RelativePath
path="test-paths"
absolute="/Users/username/project/test"
/>

- ✅ **Do**
- Use relative path:
```yml
test-paths: ["test"]
```

- ❌ **Don't:**
- Avoid absolute paths:
```yml
test-paths: ["/Users/username/project/test"]
```

## Examples
### Use a subdirectory named `custom_tests` instead of `tests` for data tests

Expand Down
1 change: 1 addition & 0 deletions website/snippets/_relative-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span>Paths specified in <code>{props.path}</code> must be relative to the location of your `dbt_project.yml` file. Avoid using absolute paths like <code>{props.absolute}</code>, as it will lead to unexpected behavior and outcomes.</span>

0 comments on commit 96df61e

Please sign in to comment.