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

Add rule catalog #24

Merged
merged 7 commits into from
May 24, 2024
Merged

Add rule catalog #24

merged 7 commits into from
May 24, 2024

Conversation

matthieucan
Copy link
Contributor

@matthieucan matthieucan commented May 21, 2024

Add the list CLI command, which is able to:

  • display in the terminal the list of known rules, along with their description
  • generate a markdown output of the know rules, suitable for website documentation

To that end:

  • Add necessary mkdocs configuration.
  • Allow Config to have its values overloaded. CLI values overwrite pyproject.toml values.
  • Fix project entry point, to go through __main__.py (which sets up logging).
  • Add -n/--namespace option to CLI commands, to overwrite the rule namespaces.
  • Refactor RuleRegistry, to instantiate rules automatically, and only look for the namespace list in the provided config.

src/dbt_score/cli.py Outdated Show resolved Hide resolved
.github/workflows/release.yml Outdated Show resolved Hide resolved
src/dbt_score/__main__.py Outdated Show resolved Hide resolved
src/dbt_score/rule_catalog.py Outdated Show resolved Hide resolved
Comment on lines +91 to +106
template = f"""## `{rule_name}`

{rule_description}

??? quote "Source code"
```python
{rule_source_code}
```

### Default configuration

```toml title="pyproject.toml"
{rule_configuration}
```
"""
return template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first tried that approach, but it ended up creating more issues, when mixing with {rule_source_code} which is itself indented

Copy link
Contributor

@jochemvandooren jochemvandooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation looks amazing 🤩

src/dbt_score/rule_registry.py Outdated Show resolved Hide resolved
src/dbt_score/rule_registry.py Outdated Show resolved Hide resolved
@@ -21,7 +21,7 @@ class Config:

def __init__(self) -> None:
"""Initialize the Config object."""
self.rule_namespaces: list[str] = ["dbt_score_rules"]
self.rule_namespaces: list[str] = ["dbt_score.rules", "dbt_score_rules"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I liked about the previous implementation is that dbt_score.rules was always included, also when additional rule_namespaces were supplied. Now when users want to add a namespace (and not lose dbt_score.rules) they will have to add it as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct. The advantage of this approach is that users are able to remove dbt_score.rules altogether - it puts everything at the same level.
Do you think that'd be an issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be confusing, but let's document it well 👍

src/dbt_score/cli.py Show resolved Hide resolved
src/dbt_score/rule_catalog.py Outdated Show resolved Hide resolved
mkdocs.yml Show resolved Hide resolved
Copy link
Contributor

@jochemvandooren jochemvandooren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@matthieucan matthieucan force-pushed the matthieucan/catalog branch from a9be9c3 to 5485ba8 Compare May 23, 2024 16:46
@matthieucan matthieucan merged commit 6011dac into master May 24, 2024
2 checks passed
@matthieucan matthieucan deleted the matthieucan/catalog branch May 24, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants