Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dbt Docs, Use user provided index.html #10674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions core/dbt/task/docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from dataclasses import replace
from datetime import datetime
from itertools import chain
from pathlib import Path
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple

import agate
Expand Down Expand Up @@ -213,6 +214,15 @@ def get_unique_id_mapping(


class GenerateTask(CompileTask):

def get_docs_index_file_path(self, ) -> str:
for docs_dir in self.config.docs_paths:
index_html = Path(self.config.project_root).joinpath(docs_dir).joinpath("index.html")
if index_html.is_file() and index_html.exists():
# click.echo(f"Using user provided documentation page: {index_html.as_posix()}")
return index_html.as_posix()
return DOCS_INDEX_FILE_PATH

def run(self) -> CatalogArtifact:
compile_results = None
if self.args.compile:
Expand All @@ -228,7 +238,7 @@ def run(self) -> CatalogArtifact:
)

shutil.copyfile(
DOCS_INDEX_FILE_PATH, os.path.join(self.config.project_target_path, "index.html")
self.get_docs_index_file_path(), os.path.join(self.config.project_target_path, "index.html")
)

for asset_path in self.config.asset_paths:
Expand Down Expand Up @@ -321,7 +331,7 @@ def run(self) -> CatalogArtifact:
read_catalog_data = load_file_contents(catalog_path)

# Create new static index file contents
index_data = load_file_contents(DOCS_INDEX_FILE_PATH)
index_data = load_file_contents(self.get_docs_index_file_path())
index_data = index_data.replace('"MANIFEST.JSON INLINE DATA"', read_manifest_data)
index_data = index_data.replace('"CATALOG.JSON INLINE DATA"', read_catalog_data)

Expand Down
Loading