-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate static index html documentation (#8615)
* Include option to generate static index.html * Added changie * Using DBT's system load / write file methods for better cross platform support * Updated docs tests with dbt.client.systems calls for file reading * Writing out static_index.html as binary file to prevent line-ending conversions on Windows. (similar behaviour as index.html)
- Loading branch information
Showing
6 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Add an option to generate static documentation | ||
time: 2023-09-11T14:41:26.274655701Z | ||
custom: | ||
Author: mescanne | ||
Issue: "8614" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
|
||
from dbt.clients.system import load_file_contents | ||
from dbt.include.global_project import DOCS_INDEX_FILE_PATH | ||
from dbt.tests.util import run_dbt | ||
import os | ||
|
||
|
||
class TestStaticGenerate: | ||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return {"my_model.sql": "select 1 as fun"} | ||
|
||
def test_static_generated(self, project): | ||
run_dbt(["docs", "generate", "--static"]) | ||
|
||
source_index_html = load_file_contents(DOCS_INDEX_FILE_PATH) | ||
|
||
target_index_html = load_file_contents( | ||
os.path.join(project.project_root, "target", "index.html") | ||
) | ||
|
||
# Validate index.html was copied correctly | ||
assert len(target_index_html) == len(source_index_html) | ||
assert hash(target_index_html) == hash(source_index_html) | ||
|
||
manifest_data = load_file_contents( | ||
os.path.join(project.project_root, "target", "manifest.json") | ||
) | ||
|
||
catalog_data = load_file_contents( | ||
os.path.join(project.project_root, "target", "catalog.json") | ||
) | ||
|
||
static_index_html = load_file_contents( | ||
os.path.join(project.project_root, "target", "static_index.html") | ||
) | ||
|
||
# Calculate expected static_index.html | ||
expected_static_index_html = source_index_html | ||
expected_static_index_html = expected_static_index_html.replace( | ||
'"MANIFEST.JSON INLINE DATA"', manifest_data | ||
) | ||
expected_static_index_html = expected_static_index_html.replace( | ||
'"CATALOG.JSON INLINE DATA"', catalog_data | ||
) | ||
|
||
# Validate static_index.html was generated correctly | ||
assert len(expected_static_index_html) == len(static_index_html) | ||
assert hash(expected_static_index_html) == hash(static_index_html) |