Repository: dbt-labs/dbt-core

Issue:
Hide macro from docs
### Describe the feature

We have some macros in our project that are not relevant to the consumers of our documentation site. Issue #1671 and pr #2179 came very close to delivering the necessary functionality to hide them.

### Describe alternatives you've considered

We can post-process the manifest.json file instead. This would be annoying and only fix the problem for us. A general solution would be better.

### Additional context

This is a trivial change.

### Who will this benefit?

This makes it easier to tweak the documentation site to work for less technical people.


Discussion:

Resolving patch:
diff --git a/core/dbt/contracts/graph/parsed.py b/core/dbt/contracts/graph/parsed.py
--- 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)


Test patch:
diff --git a/test/integration/029_docs_generate_tests/test_docs_generate.py b/test/integration/029_docs_generate_tests/test_docs_generate.py
--- 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
--- 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': [],
         }