Skip to content

Commit

Permalink
chore: refine nox commands (#47)
Browse files Browse the repository at this point in the history
Signed-off-by: l.feng <[email protected]>
  • Loading branch information
msclock authored Dec 6, 2024
1 parent b8314ad commit 99bbf2b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

project = "Serious Scaffold Pybind11"
copyright = "2024 Serious Scaffold"
author = "msclock"
author = "l.feng"

# -- General configuration ---------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion includes/copier-answers-sample.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Default values for verifying the current project structure
author_email: [email protected]
author_name: msclock
author_name: l.feng
codecov_notify_builds: 1
codecov_threshold: 5%
compiled: true
copyright_holder: Serious Scaffold
copyright_license: MIT License
copyright_year: 2024
Expand Down
27 changes: 19 additions & 8 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def tests(session: nox.Session) -> None:
@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.
Build the docs. Pass "-- --help" to show helps.
"""

parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument(
Expand Down Expand Up @@ -96,10 +95,22 @@ def build(session: nox.Session) -> None:
@nox.session(reuse_venv=True)
def template(session: nox.Session) -> None:
"""
Build template for the current repo only.
Build template from current repo. Pass "-- --help" to show helps.
"""
import os

parser = argparse.ArgumentParser()
parser.add_argument(
"-r", "--vcs-ref", default="HEAD", help="Git reference to generate."
)
parser.add_argument(
"--data-file",
default="includes/copier-answers-sample.yml",
help="Load data from a YAML file.",
)
parser.add_argument("--dest", default=".", help="Destination to generate.")
args, posargs = parser.parse_known_args(session.posargs)

excludes = [".", ".git", "template", "includes", ".nox", "copier.yml"]
for dir_item in os.listdir("."):
if dir_item in excludes:
Expand All @@ -115,12 +126,12 @@ def template(session: nox.Session) -> None:
"copier",
"copy",
"-r",
"HEAD",
args.vcs_ref,
"--data-file",
"includes/copier-answers-sample.yml",
*session.posargs,
"-f",
".",
args.data_file,
".",
args.dest,
*posargs,
)

Path(".copier-answers.yml").unlink()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "ss_pybind11"
description = "A template of serious scaffold family based on pybind11."
readme = "README.md"
license = { text = "MIT" }
authors = [{ email = "[email protected]", name = "msclock" }]
authors = [{ email = "[email protected]", name = "l.feng" }]
requires-python = ">=3.8"
classifiers = [
"Intended Audience :: Science/Research",
Expand Down
27 changes: 19 additions & 8 deletions template/noxfile.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ def tests(session: nox.Session) -> None:
@nox.session(reuse_venv=True)
def docs(session: nox.Session) -> None:
"""
Build the docs. Pass "--serve" to serve. Pass "-b linkcheck" to check links.
Build the docs. Pass "-- --help" to show helps.
"""

parser = argparse.ArgumentParser()
parser.add_argument("--serve", action="store_true", help="Serve after building")
parser.add_argument(
Expand Down Expand Up @@ -117,10 +116,22 @@ def build(session: nox.Session) -> None:
@nox.session(reuse_venv=True)
def template(session: nox.Session) -> None:
"""
Build template for the current repo only.
Build template from current repo. Pass "-- --help" to show helps.
"""
import os

parser = argparse.ArgumentParser()
parser.add_argument(
"-r", "--vcs-ref", default="HEAD", help="Git reference to generate."
)
parser.add_argument(
"--data-file",
default="includes/copier-answers-sample.yml",
help="Load data from a YAML file.",
)
parser.add_argument("--dest", default=".", help="Destination to generate.")
args, posargs = parser.parse_known_args(session.posargs)

excludes = [".", ".git", "template", "includes", ".nox", "copier.yml"]
for dir_item in os.listdir("."):
if dir_item in excludes:
Expand All @@ -136,13 +147,13 @@ def template(session: nox.Session) -> None:
"copier",
"copy",
"-r",
"HEAD",
args.vcs_ref,
"--data-file",
"includes/copier-answers-sample.yml",
*session.posargs,
"-f",
".",
args.data_file,
".",
args.dest,
*posargs,
)

Path(".copier-answers.yml").unlink()
[%- endif %]

0 comments on commit 99bbf2b

Please sign in to comment.