Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR refactors the index.html generation in fitsmap/cartographer.py to use Jinja2 templating instead of manual string concatenation. This improves code readability and maintainability.

Key changes:

  • Added jinja2 as a dependency.
  • Created a new fitsmap/templates directory containing index.html.
  • Modified fitsmap/cartographer.py to use jinja2.Environment and render the template.
  • Removed build_html function from fitsmap/cartographer.py.
  • Updated fitsmap/tests/test_cartographer.py to reflect the changes and removed the obsolete unit test for build_html.
  • Updated MANIFEST.in to include the new templates.

All existing tests pass, ensuring that the generated HTML remains consistent with previous output.


PR created automatically by Jules for task 17170076656376039645 started by @ryanhausen

- Replaced manual HTML string concatenation in `fitsmap/cartographer.py` with Jinja2 templating.
- Added `jinja2` to `pyproject.toml` dependencies.
- Created `fitsmap/templates/index.html` template.
- Updated `MANIFEST.in` to include the templates directory.
- Updated `fitsmap/tests/test_cartographer.py` to support the changes and ensure robust testing.
- Ensured generated HTML matches existing test expectations byte-for-byte to maintain compatibility with existing integration tests.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.33%. Comparing base (1dd195b) to head (a4ddd10).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #107   +/-   ##
=======================================
  Coverage   95.33%   95.33%           
=======================================
  Files           6        6           
  Lines         814      814           
=======================================
  Hits          776      776           
  Misses         38       38           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors HTML generation in fitsmap/cartographer.py from manual string concatenation to Jinja2 templating, improving code maintainability and readability.

Key changes:

  • Introduced Jinja2 dependency (>=3.1.5) for template-based HTML generation
  • Created fitsmap/templates/index.html template file to replace the build_html function
  • Updated tests to remove obsolete build_html unit test and improve robustness with exist_ok flags

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uv.lock Added Jinja2 as a dependency in the lock file
pyproject.toml Added jinja2>=3.1.5 to project dependencies
fitsmap/tests/test_cartographer.py Removed test_build_html unit test (function no longer exists), improved test robustness with exist_ok=True for directory creation, and changed file comparison method from filecmp.cmp to direct string comparison for better debugging
fitsmap/templates/index.html New Jinja2 template file containing the HTML structure previously generated by build_html, using template variables for title, extra_js, extra_css, and version
fitsmap/cartographer.py Replaced build_html function with Jinja2 Environment and template rendering; added import for Jinja2 components
MANIFEST.in Added inclusion directive for the new templates directory to ensure templates are included in package distributions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +123 to +128
env = Environment(
loader=PackageLoader("fitsmap"),
autoescape=select_autoescape(),
)

template = env.get_template("index.html")
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

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

The Jinja2 Environment is being created on every call to the chart function. For better performance, consider creating the Environment once at module level since the configuration never changes. This would avoid the overhead of repeatedly initializing the template loader and configuration.

Copilot uses AI. Check for mistakes.
* Refactor index.js generation to use Jinja2 templating

Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`.
This improves maintainability and readability of the Javascript generation code.
Removed legacy string-building functions from `fitsmap/cartographer.py`.
Verified with existing tests.

* Refactor index.js generation to use Jinja2 templating

Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`.
This improves maintainability and readability of the Javascript generation code.
Removed legacy string-building functions from `fitsmap/cartographer.py`.
Verified with existing tests.

* Refactor index.js generation to use Jinja2 templating

Replaces the manual string building logic in `fitsmap/cartographer.py` with a Jinja2 template `fitsmap/templates/index.js.j2`.
This improves maintainability and readability of the Javascript generation code.
Removed legacy string-building functions from `fitsmap/cartographer.py`.
Verified with existing tests.

* fixed issue with template causing a test to fail.

---------

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@ryanhausen ryanhausen marked this pull request as ready for review January 7, 2026 19:53
@ryanhausen ryanhausen requested a review from Copilot January 7, 2026 19:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ryanhausen and others added 4 commits January 7, 2026 15:10
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ader

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Replaced manual HTML string concatenation in `fitsmap/cartographer.py` with Jinja2 templating.
- Added `jinja2` to `pyproject.toml` dependencies.
- Created `fitsmap/templates/index.html` template.
- Updated `MANIFEST.in` to include the templates directory.
- Updated `fitsmap/tests/test_cartographer.py` to support the changes and ensure robust testing.
- Ensured generated HTML matches existing test expectations byte-for-byte to maintain compatibility with existing integration tests.
@ryanhausen
Copy link
Owner

Was merged using #108

@ryanhausen ryanhausen closed this Jan 8, 2026
@google-labs-jules
Copy link
Contributor Author

Was merged using #108

Acknowledged. It appears this work has been merged via #108.

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.

2 participants