Skip to content

Make scaffold files updatable and optional - #6

Open
lundybernard wants to merge 1 commit into
scientific-python:mainfrom
lundybernard:lb/copier-exclude-options
Open

Make scaffold files updatable and optional#6
lundybernard wants to merge 1 commit into
scientific-python:mainfrom
lundybernard:lb/copier-exclude-options

Conversation

@lundybernard

Copy link
Copy Markdown

Add _skip_if_exists for Makefile, myst.yml, and index.md so a consumer with an already-populated site can run copier update without merge conflicts on those files

Add include_news, include_makefile, and include_team_tools questions (default true), each gated through _exclude. Sites can opt out of scaffold they don't use; the answers persist in .copier-answers.yml, so exclusions survive future updates without CLI flags.

Assisted-by: claude-code:claude-opus-4-8

@lundybernard
lundybernard marked this pull request as draft July 18, 2026 17:44
Add `_skip_if_exists` for Makefile, myst.yml, and index.md so a consumer
with an already-populated site can run `copier update` without merge
conflicts on those files

Add include_news, include_makefile, and include_team_tools questions
(default true), each gated through `_exclude`. Sites can opt out of
scaffold they don't use; the answers persist in .copier-answers.yml, so
exclusions survive future updates without CLI flags.

Gate every reference to an optional file, not just the file itself:
include_team_grid also drops the `plugins:` registration (config becomes
a .jinja template) covering team-grid.mjs and tools/team_query.py, and
include_news drops the `/news` nav entry. This keeps every answer combo
building without unresolved references or missing plugins.

Assisted-by: claude-code:claude-opus-4-8
@lundybernard
lundybernard force-pushed the lb/copier-exclude-options branch from 6b11289 to 6b1e98a Compare July 18, 2026 18:01
@lundybernard
lundybernard marked this pull request as ready for review July 18, 2026 18:08

@drammock drammock left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess my main question here is "how often are users likely to re-run copier after they've started tweaking their site?" I don't know the answer, but maybe @bsipocz or @stefanv does?

Comment on lines +2 to +6
{% if include_team_grid %}
project:
plugins:
- team-grid.mjs

{% endif %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this won't work as-is. the project key also has other stuff under it now (a static_files list) and there's a second plugin now too. My feeling is there's little harm in always including team-grid.mjs since it won't do anything unless the user inserts a team-grid directive.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

True, we could just narrow it down, so that the project section is static, and the - team-grid.mjs is the only line gated by if include_team_grid. I also don't see any real harm in including it by default, its just a little unused disk-space+compute vs the extra prompt in the initial setup.

Comment thread template/myst.yml.jinja
Comment on lines +10 to +13
{% if include_news %}
- title: News
url: /news
{% endif %}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd lean here toward just letting the user delete / modify whichever items they don't want in the nav

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As I understand it, setting the include_ flags allows users to explicitly include/exclude the files/config opts. Without those, re-running copier to update their project will always add the unwanted files (manual delete each time) and overwrite their settings (resolve conflicts each time)... This won't eliminate those issues, but reduce their number.

The choices are explicit in .copier-answers.yml, and can be changed in the future, so adding a feature only requires removing it from .copier-answers.yml's exclude list and re-running copier.

The real question is still "do users only run copy once and maintain manually afterwards, or do they occasionally update the theme files?"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

after actually reading the docs of copier (instead of blindly re-running the same command every time), I realize my objections are moot. copier is quite flexible in its subcommands and flags (copy vs recopy vs update, -A to re-use answers, etc). I still have a lingering "this is more complexity than we need" feeling, but I think I'm convinced that it's not a footgun and not worth spending any more time debating; the stakes are quite low.

Comment thread copier.yml
Comment on lines +5 to +8
_skip_if_exists:
- Makefile
- myst.yml
- index.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these seem potentially useful for the end-user, although during theme development it is actually desirable to overwrite myst.yml possibly index.md and/or Makefile too.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Valid, there are ways to work around it, if you need to overwrite those files frequently.

My concern for users updating their theme is that we don't want to clobber these.

Tell me about your dev workflow where you need to overwrite these files frequently and we can find a good solution.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

never mind. I was heavily editing footer.md.jinja and config/scientific-python.yml but not actually touching index.md.jinja or myst.yaml.jinja. and index.md.jinja is much simpler than the footer (it's just content, not really structure; the structure is inherited from book theme).

@stefanv

stefanv commented Jul 23, 2026

Copy link
Copy Markdown
Member

I can see a case for bringing in the latest theme updates; we used to update the Hugo theme all the time (CSS tweaks etc.), and I imagine it will be the same here.

@lundybernard

Copy link
Copy Markdown
Author

@stefanv I agree, and expect we will be updating these files frequently at least in the near future. Even long-term after the cadence of changes has slowed, I expect occasional updates to deal with changes in MystMD.

Copier is not really built for handling updates like this, so its always going to be a little awkward. Its worth considering if this is a temporary stop-gap to hold us over until we build a fully-fledged scientific-python MystMD theme, or if we really want to avoid that work and stick with project-level configuration instead.

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