Skip to content

Conversation

@derks
Copy link
Member

@derks derks commented Jun 10, 2025

Add support for App.Meta.template_dirs and configuration override.

Resolves Issue #746

Summary by CodeRabbit

  • New Features
    • Added support for specifying multiple template directories via configuration settings.
  • Documentation
    • Updated changelog to reflect the new feature.
    • Added a new contributor to the contributors list.
  • Tests
    • Introduced tests to verify configuration-based template directory overrides and interactions.

@coderabbitai
Copy link

coderabbitai bot commented Jun 10, 2025

Walkthrough

Support for specifying template_dirs via application configuration was added, allowing configuration values to override the previously hardcoded meta attribute. The setup logic for template directories was updated to handle this, and three new tests were introduced to verify the new behavior. Documentation was updated to reflect these changes and a new contributor was acknowledged.

Changes

File(s) Change Summary
CHANGELOG.md Updated to document new feature: support for App.Meta.template_dirs in configuration, referencing Issue #746.
CONTRIBUTORS.md Added "Tom Freudenberg (TomFreudenberg)" as a new contributor.
cement/core/foundation.py Added support for reading template_dirs from config, updated _setup_template_handler, and allowed config override.
tests/core/test_foundation.py Added three tests: config override of template_dirs, string-to-list conversion, and interaction with template_dir.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Config
    participant TemplateHandler

    User->>App: Start application
    App->>Config: Check for 'template_dirs' in config
    alt 'template_dirs' found in config
        Config-->>App: Return config 'template_dirs'
        App->>App: Parse and set template_dirs from config
    else Not found
        App->>App: Use Meta.template_dirs
    end
    App->>TemplateHandler: Setup with final template_dirs list
Loading

Poem

In the warren of code, a new path appears,
Template dirs from config, now everyone cheers!
With tests to ensure that all works just right,
And a new friend named Tom joining the flight.
🐇✨
The templates now hop where the user prefers—
Oh, what a day for directory transfers!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cement/core/foundation.py (1)

525-535: Fix typo in comment.

There's a typo in the comment: "becuase" should be "because".

-            # reverse it becuase it will be reverse again (keep user preference)
+            # reverse it because it will be reversed again (keep user preference)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b03817 and 0cf3873.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • CONTRIBUTORS.md (1 hunks)
  • cement/core/foundation.py (3 hunks)
  • tests/core/test_foundation.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
cement/core/foundation.py

[error] 1554-1554: Instance of 'Meta' has no 'core_user_template_dirs' member

(E1101)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (8)
cement/core/foundation.py (4)

500-500: LGTM: Adding template_dirs to core_meta_override list.

This correctly enables configuration override for the template_dirs meta attribute, consistent with other overridable meta options.


525-535: Excellent implementation of config override logic.

The logic correctly:

  • Checks for template_dirs in the config section
  • Handles both list and comma-separated string formats
  • Reverses the list to maintain user preference order
  • Follows established patterns from similar config overrides

544-553: LGTM: Config-aware template directory selection.

The conditional logic properly prioritizes config-provided template_dirs over meta-defined ones while maintaining the established directory precedence order.


1554-1554: The static analysis hint is a false positive.

The static analysis tool flagged core_user_template_dirs as missing, but this attribute is clearly defined in the Meta class at lines 723-726. This is a false positive and can be safely ignored.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 1554-1554: Instance of 'Meta' has no 'core_user_template_dirs' member

(E1101)

tests/core/test_foundation.py (3)

782-795: Excellent test coverage for config override functionality.

This test properly verifies that:

  • Config template_dirs override meta template_dirs
  • Original meta paths are excluded when config overrides exist
  • Both list formats work correctly

The test design is clean and assertions are appropriate.


797-809: Good test for string format conversion.

This test correctly validates the comma-separated string parsing functionality, including handling of whitespace around commas. The test design matches the expected behavior from the implementation.


811-823: Thorough test for template_dir and template_dirs interaction.

This test ensures that both singular template_dir and plural template_dirs settings work together correctly, which is important for backward compatibility and flexibility.

CONTRIBUTORS.md (1)

26-26: LGTM: Welcome new contributor!

Appropriate addition of the new contributor following the established format.

Comment on lines +11 to +12
- `[core.foundation]` Support for App.Meta.template_dirs.
- [Issue #746](https://github.com/datafolklabs/cement/issues/749)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect issue reference.

The changelog entry references Issue #749, but according to the PR objectives, this feature addresses Issue #746.

-  - [Issue #746](https://github.com/datafolklabs/cement/issues/749)
+  - [Issue #746](https://github.com/datafolklabs/cement/issues/746)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `[core.foundation]` Support for App.Meta.template_dirs.
- [Issue #746](https://github.com/datafolklabs/cement/issues/749)
- `[core.foundation]` Support for App.Meta.template_dirs.
- [Issue #746](https://github.com/datafolklabs/cement/issues/746)
🤖 Prompt for AI Agents
In CHANGELOG.md around lines 11 to 12, the issue reference is incorrect; it
currently points to Issue #749 instead of the correct Issue #746. Update the
changelog entry to reference Issue #746 to accurately reflect the PR objectives.

@derks
Copy link
Member Author

derks commented Jun 10, 2025

@TomFreudenberg this PR is ready for review if you are interested to test it. I believe it solves your requests in Issue #746 - I'm not going to merge it just yet, I need to review some things. Particularly, on whether the config template_dirs should append to App.Meta.template_dirs, or overwrite it. Currently (in this PR) it is overwriting it but I'm not 100% on that yet. Happy to hear your thoughts as a user/consumer.

This also adds you to the CONTRIBUTORS.md file that you mentioned in a previous PR.

Thank you for your patience.

@TomFreudenberg
Copy link
Contributor

TomFreudenberg commented Oct 30, 2025

Dear @derks

sorry for being very late on your feedback and your effort. I had some private issues and it took a while for me to continue work. I will come up to you with feedback soon.

Kindly regards
Tom

@derks
Copy link
Member Author

derks commented Oct 30, 2025

@TomFreudenberg good to hear from you, and sorry to hear the unfortunate news. I have fallen behind in active dev, so this is a good reminder for me as well. No rush, its always good to have your feedback on Cement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants