Skip to content

Commit

Permalink
docs: more into on modifying the template
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Ramsay <[email protected]>
  • Loading branch information
seapagan committed Aug 10, 2023
1 parent ae3be87 commit 5555574
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/template/default.md → docs/template/internal.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The 'Default' Template
# The Internal Template

By default, the generated application will have a basic template that you can
use to get started, this template is stored inside the package itself. It will
Expand Down
7 changes: 3 additions & 4 deletions docs/template/modify.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Adding or Modifying files in the template

If you always wish to add or change specific files in the template, you can do
so by adding them to the `~/.pymaker/template` folder. The files (and folders)
in this folder will be copied to the root of the project when the template is
generated.
If you wish to add or change specific files in the template, you can do so by
adding them to the `~/.pymaker/template` folder. The files (and folders) in this
folder will be copied to the root of the project when the template is generated.

Files in this global template folder will override any files in the default
template, so you can for example change the `README.md` file, add to the
Expand Down
24 changes: 20 additions & 4 deletions docs/template/replace.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,30 @@ This will copy the default template to the global template folder
(`~/.pymaker/template`). You can then modify or delete files as you see fit.

Running this command will ask you if you wish to set this exported template as
the default template. If you answer yes, then the default template will be
the default template. It will then ask you if you want to disable the internal
template. If you answer yes, then the internal template will be
disabled, and ONLY the exported template will be used instead. Otherwise, both
will still be used with the exported template taking precedence.

## Use another Template completely
## Change the location of the Template folder

!!! note
This feature is not yet implemented.
If you wish to change the location of the template folder, you can do so in 2
ways:

1. By adding the `--local` flag to the above command (e.g. `pymaker template
dump --local`). This will dump the default template to the current folder,
giving you the option to disable the default template if needed. Note that
any files in the folder will be overwritten.
2. By changing to the folder containing your template and running `pymaker
template set`. This will set the current folder as the template folder and
give you the same option to disable the default template.

You can reset the template location back to the default `~/.pymaker/template`
folder by running the following command:

```console
$ pymaker template reset
```

## Choose to use the Default Template or not

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ nav:
- Quick Start: quick-start.md
- Configuration: configuration.md
- Templates:
- Default Template: template/default.md
- Internal Template: template/internal.md
- Modifying: template/modify.md
- Replacing: template/replace.md
- Task Runner: tasks.md
Expand Down
10 changes: 5 additions & 5 deletions py_maker/commands/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def dump(

if any(output_folder.iterdir()) and not Confirm.ask(
f"[red]The output folder:[/red] {output_folder} "
f"[red]is not empty, do you want to continue?[/red]",
"[red]is not empty, do you want to continue?[/red]",
default=False,
):
raise typer.Exit(ExitErrors.USER_ABORT) # noqa TRY301
Expand Down Expand Up @@ -102,7 +102,7 @@ def default(action: str) -> None:
settings.use_default_template = True
settings.save()
print(
f"[green] -> Default template folder enabled:[/green] "
"[green] -> Default template folder enabled:[/green] "
f"{settings.template_folder}"
)
elif action == "disable":
Expand All @@ -112,7 +112,7 @@ def default(action: str) -> None:
else:
print(
f"[red] -> Invalid action:[/red] {action}\n"
f"[red] -> Action must be either:[/red] enable or disable"
"[red] -> Action must be either:[/red] enable or disable"
)
raise typer.Exit(ExitErrors.INVALID_ACTION)

Expand All @@ -135,7 +135,7 @@ def set_template():
settings.save()

print(
f"[green] -> Template folder set to:[/green] "
"[green] -> Template folder set to:[/green] "
f"{settings.template_folder}"
)
print(
Expand Down Expand Up @@ -165,7 +165,7 @@ def reset_template():
settings.template_folder = str(Path.home() / ".pymaker" / "template")
settings.save()
print(
f"[green] -> Template folder reset to:[/green] "
"[green] -> Template folder reset to:[/green] "
f"{settings.template_folder}"
)
print(
Expand Down

0 comments on commit 5555574

Please sign in to comment.