dbt-labs / docs.getdbt.com

The code behind docs.getdbt.com
https://docs.getdbt.com/
Apache License 2.0
113 stars 863 forks source link

[Core] How to add a description for custom generic tests #5631

Open dbeatty10 opened 3 weeks ago

dbeatty10 commented 3 weeks ago

Link to the page(s) on docs.getdbt.com requiring updates

https://docs.getdbt.com/best-practices/writing-custom-generic-tests

Tell us more about this update

There are two types of data tests, and users can create custom tests in both types:

When creating a custom generic test, many users want to add a description that shows up in the generated docs site.

One user described how to accomplish this goal: https://github.com/dbt-labs/dbt-core/issues/2578#issuecomment-1868473901

e.g., do something like this:

tests/generic/_generic_data_tests.yml or macros/_generic_data_tests.yml

macros:
  - name: test_not_empty_string
    description: Complementary test to default `not_null` test as it checks that there is not an empty string. It only accepts columns of type string. It is deprecated as this functionality has been included in the custom implementation of `not_null`
    arguments:
      - name: model
        type: string
        description: Model Name
      - name: column_name
        type: string
        description: Column name that should not be an empty string

Note: it doesn't strictly need to be named _generic_data_tests.yml; it could be something else like properties.yml.

Reviewers/Stakeholders/SMEs

.

Related GitHub issues

Additional information

No response