Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ccbr_tools --help

Commands:
send-email Send an email (works on biowulf)
quarto-add Add a quarto extension
quarto-add Add a quarto extension from the CCBR GitHub organization.
install Install a specific version of a CCBR software package,...
cite Print the citation in the desired format
version Print the version of ccbr_tools
Expand Down
10 changes: 6 additions & 4 deletions src/ccbr_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CustomClickGroup,
)
from .send_email import send_email_msg
from .templates import use_quarto_ext, get_quarto_extensions
from .templates import use_quarto_ext
from .software import install as install_software


Expand Down Expand Up @@ -136,19 +136,21 @@ def send_email(to_address, text, subject, attach_html, from_addr, debug):
send_email_msg(to_address, text, subject, attach_html, from_addr, debug)


@click.command(epilog=f"Available extensions: {', '.join(get_quarto_extensions())}")
@click.command()
@click.argument(
"ext_name",
type=str,
required=True,
)
def quarto_add(ext_name):
"""
Add a quarto extension
Add a quarto extension from the CCBR GitHub organization.

Runs `quarto use template CCBR/quarto-{ext_name}`.

\b
Arguments:
ext_name The name of the extension in ccbr_tools
ext_name The name of the extension (e.g. "fnl" for CCBR/quarto-fnl)

\b
Examples:
Expand Down
29 changes: 13 additions & 16 deletions src/ccbr_tools/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

Quarto HTML format with FNL branding guidelines

First run `ccbr_tools quarto-add fnl`, then modify your `_quarto.yml` file with the following:
First run `ccbr_tools quarto-add fnl` (which runs `quarto use template CCBR/quarto-fnl`), then modify your `_quarto.yml` file with the following:

```yaml
website:
Expand All @@ -30,8 +30,7 @@
"""

import importlib.resources
import pathlib
import shutil
import subprocess


def read_template(template_name):
Expand Down Expand Up @@ -98,22 +97,20 @@ def get_quarto_extensions():

def use_quarto_ext(ext_name):
"""
Use a Quarto extension
Use a Quarto extension from the CCBR GitHub organization.

Runs `quarto use template CCBR/quarto-{ext_name}`.

Args:
ext_name (str): The name of the extension in ccbr_tools
ext_name (str): The name of the Quarto extension (e.g. "fnl" for CCBR/quarto-fnl).

Raises:
subprocess.CalledProcessError: If the quarto command fails.

Examples:
>>> use_quarto_ext("fnl")
"""
ext_dir = importlib.resources.files(__package__) / "_extensions"
template_dir = ext_dir / ext_name
if not template_dir.exists() and not (template_dir / "_extension.yml").is_file():
raise FileNotFoundError(
f"{ext_name} does not exist. Available extensions: {', '.join(get_quarto_extensions())}"
)
out_dir = pathlib.Path("_extensions")
if not out_dir.exists():
out_dir.mkdir()
shutil.copytree(template_dir, out_dir / ext_name, dirs_exist_ok=True)
print(f"Copied {ext_name} to {out_dir}")
subprocess.run(
["quarto", "use", "template", f"CCBR/quarto-{ext_name}"],
check=True,
)
Empty file.
18 changes: 0 additions & 18 deletions src/ccbr_tools/templates/_extensions/fnl/__init__.py

This file was deleted.

14 changes: 0 additions & 14 deletions src/ccbr_tools/templates/_extensions/fnl/_extension.yml

This file was deleted.

51 changes: 0 additions & 51 deletions src/ccbr_tools/templates/_extensions/fnl/fnl-dark.scss

This file was deleted.

153 changes: 0 additions & 153 deletions src/ccbr_tools/templates/_extensions/fnl/fnl-light-revealjs.scss

This file was deleted.

46 changes: 0 additions & 46 deletions src/ccbr_tools/templates/_extensions/fnl/fnl-light.scss

This file was deleted.

Binary file not shown.
Binary file not shown.
Loading