From 5591a82a15261a167cccff2be08a99937bd15e99 Mon Sep 17 00:00:00 2001 From: Alf Lervag Date: Tue, 12 May 2020 12:08:34 +0200 Subject: [PATCH 1/2] Make it possible to hide macros in docs --- core/dbt/contracts/graph/parsed.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/dbt/contracts/graph/parsed.py b/core/dbt/contracts/graph/parsed.py index efaff049810..d9433544a35 100644 --- a/core/dbt/contracts/graph/parsed.py +++ b/core/dbt/contracts/graph/parsed.py @@ -287,6 +287,7 @@ class ParsedMacro(UnparsedBaseNode, HasUniqueID): depends_on: MacroDependsOn = field(default_factory=MacroDependsOn) description: str = '' meta: Dict[str, Any] = field(default_factory=dict) + docs: Docs = field(default_factory=Docs) patch_path: Optional[str] = None arguments: List[MacroArgument] = field(default_factory=list) @@ -297,6 +298,7 @@ def patch(self, patch: ParsedMacroPatch): self.patch_path: Optional[str] = patch.original_file_path self.description = patch.description self.meta = patch.meta + self.docs = patch.docs self.arguments = patch.arguments if dbt.flags.STRICT_MODE: assert isinstance(self, JsonSchemaMixin) From 4b90ff892fb0f667b333afbec170a09b5ff80b0f Mon Sep 17 00:00:00 2001 From: Alf Lervag Date: Mon, 18 May 2020 14:08:52 +0200 Subject: [PATCH 2/2] Updated tests and changelog --- CHANGELOG.md | 6 ++++++ .../029_docs_generate_tests/test_docs_generate.py | 4 +++- test/unit/test_contracts_graph_parsed.py | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d4e2e8adf..b58dc00d9e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ### Features - Added a `full_refresh` config item that overrides the behavior of the `--full-refresh` flag ([#1009](https://github.com/fishtown-analytics/dbt/issues/1009), [#2348](https://github.com/fishtown-analytics/dbt/pull/2348)) +- Added a "docs" field to macros, with a "show" subfield to allow for hiding macros from the documentation site ([#2430](https://github.com/fishtown-analytics/dbt/issues/2430)) + +### Under the hood + +Contributors + - [@alf-mindshift](https://github.com/alf-mindshift) ([#2431](https://github.com/fishtown-analytics/dbt/pull/2431) ## dbt 0.17.0 (Release TBD) diff --git a/test/integration/029_docs_generate_tests/test_docs_generate.py b/test/integration/029_docs_generate_tests/test_docs_generate.py index 8cf96e0575a..9eeea700e60 100644 --- a/test/integration/029_docs_generate_tests/test_docs_generate.py +++ b/test/integration/029_docs_generate_tests/test_docs_generate.py @@ -843,7 +843,7 @@ def _verify_generic_macro_structure(self, manifest): 'path', 'original_file_path', 'package_name', 'root_path', 'name', 'unique_id', 'tags', 'resource_type', 'depends_on', 'meta', 'description', 'patch_path', 'arguments', - 'macro_sql', + 'macro_sql', 'docs' } ) # Don't compare the sql, just make sure it exists @@ -869,6 +869,7 @@ def _verify_generic_macro_structure(self, manifest): 'resource_type': 'macro', 'depends_on': {'macros': []}, 'description': '', + 'docs': {'show': True}, 'patch_path': None, 'meta': {}, 'arguments': [], @@ -1689,6 +1690,7 @@ def expected_postgres_references_manifest(self, model_database=None): 'name': 'test_nothing', 'depends_on': {'macros': []}, 'description': 'My custom test that I wrote that does nothing', + 'docs': {'show': True}, 'macro_sql': AnyStringWith('macro test_nothing'), 'original_file_path': self.dir('macros/dummy_test.sql'), 'path': self.dir('macros/dummy_test.sql'), diff --git a/test/unit/test_contracts_graph_parsed.py b/test/unit/test_contracts_graph_parsed.py index dace3716bbb..6324a3e4639 100644 --- a/test/unit/test_contracts_graph_parsed.py +++ b/test/unit/test_contracts_graph_parsed.py @@ -1204,6 +1204,7 @@ def _ok_dict(self): 'depends_on': {'macros': []}, 'meta': {}, 'description': 'my macro description', + 'docs': {'show': True}, 'arguments': [], }