Repository: datnguye/dbterd (language: python)

Issue:
Feature/add optional dbt resource type
Processing https://github.com/datnguye/dbterd/issues/13


Discussion / hints:
Thank you for the suggestion, @datnguye. I will make the changes this weekend.
@datnguye  Modified, please continue, thanks!
## [Codecov](https://codecov.io/gh/datnguye/dbterd/pull/14?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dat+Nguyen) Report
> :exclamation: No coverage uploaded for pull request base (`main@bc30855`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dat+Nguyen#section-missing-base-commit).
> The diff coverage is `n/a`.

```diff
@@           Coverage Diff           @@
##             main      #14   +/-   ##
=======================================
  Coverage        ?   98.99%           
=======================================
  Files           ?       25           
  Lines           ?      596           
  Branches        ?        0           
=======================================
  Hits            ?      590           
  Misses          ?        6           
  Partials        ?        0           
```



Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dat+Nguyen). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Dat+Nguyen)

Now available on pypi: [dbterd/0.3.0b1](https://pypi.org/project/dbterd/0.3.0b1/)

Fix patch:
diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
new file mode 100644
index 0000000..23f636a
--- /dev/null
+++ b/.github/workflows/codecov.yml
@@ -0,0 +1,38 @@
+name: Base Code Coverage
+
+on:
+  push:
+    branches: [ main ]
+
+jobs:
+  build-and-test:
+    runs-on: ${{ matrix.os }}
+    strategy:
+      matrix:
+        os: [ubuntu-latest]
+        python-version: ["3.9"]
+
+    steps:
+      - uses: actions/checkout@v3
+      - name: Set up Python ${{ matrix.python-version }}
+        uses: actions/setup-python@v4
+        with:
+          python-version: ${{ matrix.python-version }}
+
+      - name: Install dependencies
+        run: |
+          pip install poetry
+          poetry config virtualenvs.in-project true
+
+      - name: Install dependencies
+        run: |
+          poetry install
+
+      - name: Run tests
+        run: |
+          poetry run poe test-cov
+
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@v2
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/README.md b/README.md
index c90d656..b949bf7 100644
--- a/README.md
+++ b/README.md
@@ -50,11 +50,16 @@ dbterd run -ad "samples/dbtresto" -o "target" -s schema:dbt.mart -ns model.dbt_r
 
 # other samples
 dbterd run -ad "samples/fivetranlog" -o "target"
+dbterd run -ad "samples/fivetranlog" -o "target" -rt "model" -rt "source"
+
 dbterd run -ad "samples/facebookad" -o "target"
+dbterd run -ad "samples/facebookad" -o "target" -rt "model" -rt "source"
+
 dbterd run -ad "samples/shopify" -o "target"
+dbterd run -ad "samples/shopify" -o "target" -rt "model" -rt "source"
 
 # your own sample without commiting to repo
-dbterd run -mp "samples/local" -o "target"
+dbterd run -mp "samples/local" -o "target" -rt "model" -rt "source"
 ```
 
 ## Decide to exclude Relationship Tests from ERD generated
diff --git a/docs/nav/guide/cli-references.md b/docs/nav/guide/cli-references.md
new file mode 100644
index 0000000..8cbfe7f
--- /dev/null
+++ b/docs/nav/guide/cli-references.md
@@ -0,0 +1,265 @@
+# CLI Reference (dbterd)
+
+Run `--help` or `-h` to see the basic guideline for CLI Reference
+
+Shows the main commands
+
+```
+Usage: dbterd [OPTIONS] COMMAND [ARGS]...
+
+  Tools for producing diagram-as-code
+
+Options:
+  --version   Show the version and exit.
+  -h, --help  Show this message and exit.
+
+Commands:
+  debug  Inspect the hidden magics
+  run    Run the convert
+```
+
+
+## run
+::: dbterd.run
+
+Generate diagram-as-a-code file. Supports: [DBML](https://www.dbml.org/home/)
+
+**Examples:**
+=== "CLI (within dbt project)"
+
+    ```bash
+    dbt docs generate
+    dbterd run
+    ```
+
+=== "--help (-h)"
+    ```
+    Usage: dbterd run [OPTIONS]
+
+    Run the convert
+
+    Options:
+    -ad, --artifacts-dir TEXT     Specified the full path to dbt artifacts path
+                                    which known as /target directory  [default:
+                                    C:\Users\DAT\Documents\Sources\dbterd\target]
+    -mp, --manifest-path TEXT     __DEPRECATED_WARNING__: Specified the full
+                                    directory path to dbt manifest.json file. Use
+                                    --artifacts-dir instead.
+    -o, --output TEXT             Output the result file. Default to the same
+                                    target dir  [default:
+                                    C:\Users\DAT\Documents\Sources\dbterd\target]
+    -s, --select TEXT             Selecttion criteria. Support 'starts with' a
+                                    string
+    -ns, --exclude TEXT           Exclusion criteria. Support 'not starts with'
+                                    a string
+    -t, --target TEXT             Target to the diagram-as-code platform
+                                    [default: dbml]
+    -a, --algo TEXT               Specified algorithm in the way to detect
+                                    diagram connectors  [default:
+                                    test_relationship]
+    -mv, --manifest-version TEXT  Specified dbt manifest.json version
+    -rt, --resource-type TEXT     Specified dbt resource type(seed, model,
+                                    source, snapshot),default:model, use examples,
+                                    -rt model -rt source
+    -h, --help                    Show this message and exit.
+    ```
+
+### --artifacts-dir (-ad)
+::: dbterd.run.--artifacts-dir
+
+Configure the path to directory containing dbt artifact files.
+> Default to `./target`
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -ad "./target"
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --artifacts-dir "./target"
+    ```
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -mp "./target"
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --manifest-path "./target"
+    ```
+
+### --output (-o)
+::: dbterd.run.--output
+
+Configure the path to directory containing the output diagram file.
+> Default to `./target`
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -o "./target"
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --output "./target"
+    ```
+
+### --select (-s)
+::: dbterd.run.--select
+
+Selecttion criteria. Support 'starts with' a string where string is:
+  - table name (or part of it)
+  - schema name (or part of it) formed as `schema:<your_schema_name>
+> Select all dbt models if not specified
+
+**Examples:**
+=== "CLI (by table)"
+
+    ```bash
+    dbterd run -s "model.package_name.model_name"
+    ```
+=== "CLI (by schema)"
+
+    ```bash
+    dbterd run -s "schema:my_schema_name"
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --select "<your-criteria>"
+    ```
+
+### --exclude (-ns)
+::: dbterd.run.todo
+
+Configure todo
+> Default to `todo`
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run todo
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run todo
+    ```
+
+### --target (-t)
+::: dbterd.run.--target
+
+Target to the diagram-as-code platform
+> Default to `dbml`, currently only supported option
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -t dbml
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --target dbml
+    ```
+
+### --algo (-a)
+::: dbterd.run.--algo
+
+Specified algorithm in the way to detect diagram connectors
+> Default to `test_relationship`, currently only supported option
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -a test_relationship
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --algo test_relationship
+    ```
+
+### --manifest-version (-mv)
+::: dbterd.run.--manifest-version
+
+Specified dbt manifest.json version
+> Default to `todo`
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run todo
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run todo
+    ```
+
+### --resource-type (-rt)
+::: dbterd.run.--resource-type
+
+Specified dbt resource type(seed, model, source, snapshot).
+> Default to `["model"]`, supports mulitple options
+
+**Examples:**
+=== "CLI"
+
+    ```bash
+    dbterd run -rt model -rt source
+    ```
+=== "CLI (long style)"
+
+    ```bash
+    dbterd run --resource-type model
+    ```
+
+### ⚠ DEPRECATED WARNING
+
+#### --manifest-path (-mp) (DEPRECATED soon)
+::: dbterd.run.DEPRECATED.--manifest-path
+
+Configure the path to directory containing dbt `manifest.json` file.
+> Default to `./target`
+
+
+## debug
+::: dbterd.debug
+
+Shows hidden configured values
+
+**Examples:**
+=== "Output"
+
+    ```
+    2023-04-08 10:15:03,611 - dbterd - INFO - Run with dbterd==0.2.0 (main.py:43)
+    2023-04-08 10:15:03,612 - dbterd - INFO - **Arguments used** (main.py:52)
+    2023-04-08 10:15:03,613 - dbterd - DEBUG - {
+        "artifacts_dir": "C:\\Users\\DAT\\Documents\\Sources\\dbterd\\target",
+        "manifest_path": null,
+        "output": "C:\\Users\\DAT\\Documents\\Sources\\dbterd\\target",
+        "select": null,
+        "exclude": null,
+        "target": "dbml",
+        "algo": "test_relationship",
+        "manifest_version": null,
+        "resource_type": [
+            "model"
+        ]
+    } (main.py:53)
+    2023-04-08 10:15:03,614 - dbterd - INFO - **Context used** (main.py:54)
+    2023-04-08 10:15:03,614 - dbterd - DEBUG - {} (main.py:55)
+    ```
diff --git a/mkdocs.yml b/mkdocs.yml
index 11adbd4..6a606b5 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -61,7 +61,10 @@ plugins:
       minify_html: true
 
 nav:
-    - Home: index.md
+    - Home:
+      - Introduction:
+        - index.md
+      - User Guide: nav/guide/cli-references.md
     - Development:
       - nav/development/contributing-guide.md
       - nav/development/CHANGELOG.md
@@ -79,7 +82,23 @@ extra:
       link: https://github.com/datnguye
     - icon: fontawesome/brands/linkedin
       link: https://www.linkedin.com/in/tuiladat/
-
+  analytics:
+    provider: google
+    property: <TBU>
+    feedback:
+      title: Was this page helpful?
+      ratings:
+        - icon: material/emoticon-happy-outline
+          name: This page was helpful
+          data: 1
+          note: >-
+            Thanks for your feedback!
+        - icon: material/emoticon-sad-outline
+          name: This page could be improved
+          data: 0
+          note: >-
+            Thanks for your feedback! Help us improve this page by
+            using our <a href="https://github.com/datnguye/dbterd/issues/new/?title=[Feedback]+{title}+-+{url}" target=_blank>feedback form</a>.
 markdown_extensions:
   - abbr
   - admonition


Test patch:
diff --git a/tests/unit/adapters/targets/dbml/test_engine.py b/tests/unit/adapters/targets/dbml/test_engine.py
index 50733d2..8fc87ee 100644
--- a/tests/unit/adapters/targets/dbml/test_engine.py
+++ b/tests/unit/adapters/targets/dbml/test_engine.py
@@ -124,6 +124,18 @@ class DummyManifestTable:
             },
         ),
     }
+    sources = {
+        "source.dummy.source_table": ManifestNode(
+            test_metadata=ManifestNodeTestMetaData(kwargs={}),
+            meta={},
+            database="--database--",
+            schema_="--schema--",
+            columns={
+                "name1": ManifestNodeColumn(name="name1"),
+                "name2": ManifestNodeColumn(name="name2"),
+            },
+        ),
+    }
 
 
 @dataclass
@@ -146,11 +158,16 @@ class DummyCatalogTable:
             columns={"name3": CatalogNodeColumn(type="--name3-type--")}
         ),
     }
+    sources = {
+        "source.dummy.source_table": CatalogNode(
+            columns={"name1": CatalogNodeColumn(type="--name1-type--")}
+        ),
+    }
 
 
 class TestDbmlEngine:
     @pytest.mark.parametrize(
-        "tables, relationships, select, resource_type, expected",
+        "tables, relationships, select, exclude, resource_type, expected",
         [
             (
                 [
@@ -164,6 +181,7 @@ class TestDbmlEngine:
                 ],
                 [],
                 "",
+                None,
                 ["model"],
                 """//Tables (based on the selection criteria)
                 //--configured at schema: --database--.--schema--
@@ -210,6 +228,7 @@ class TestDbmlEngine:
                     ),
                 ],
                 "",
+                None,
                 ["model", "source"],
                 """//Tables (based on the selection criteria)
                 //--configured at schema: --database--.--schema--
@@ -256,6 +275,7 @@ class TestDbmlEngine:
                     )
                 ],
                 "schema:--schema--",
+                None,
                 ["model", "source"],
                 """//Tables (based on the selection criteria)
                 //--configured at schema: --database--.--schema--
@@ -265,9 +285,29 @@ class TestDbmlEngine:
                 //Refs (based on the DBT Relationship Tests)
                 """,
             ),
+            (
+                [
+                    Table(
+                        name="model.dbt_resto.table1",
+                        database="--database--",
+                        schema="--schema--",
+                        columns=[Column(name="name1", data_type="--name1-type--")],
+                        raw_sql="--irrelevant--",
+                    )
+                ],
+                [],
+                "",
+                "model.dbt_resto.table1",
+                ["model"],
+                """//Tables (based on the selection criteria)
+                //Refs (based on the DBT Relationship Tests)
+                """,
+            ),
         ],
     )
-    def test_parse(self, tables, relationships, select, resource_type, expected):
+    def test_parse(
+        self, tables, relationships, select, exclude, resource_type, expected
+    ):
         with mock.patch(
             "dbterd.adapters.targets.dbml.engine.engine.get_tables", return_value=tables
         ) as mock_get_tables:
@@ -279,6 +319,7 @@ def test_parse(self, tables, relationships, select, resource_type, expected):
                     manifest="--manifest--",
                     catalog="--catalog--",
                     select=select,
+                    exclude=exclude,
                     resource_type=resource_type,
                 )
                 print("dbml    ", dbml.replace(" ", "").replace("\n", ""))
@@ -320,8 +361,19 @@ def test_parse(self, tables, relationships, select, resource_type, expected):
                         ],
                         raw_sql="--irrelevant--",
                     ),
+                    Table(
+                        name="source.dummy.source_table",
+                        database="--database--",
+                        schema="--schema--",
+                        columns=[
+                            Column(name="name1", data_type="--name1-type--"),
+                            Column(name="name2"),
+                        ],
+                        raw_sql="--irrelevant--",
+                        resource_type="source",
+                    ),
                 ],
-            )
+            ),
         ],
     )
     def test_get_tables(self, manifest, catalog, expected):