1515import difflib
1616import email .parser
1717import email .policy
18+ import enum
1819import functools
1920import json
2021import os
3637nox .options .default_venv_backend = "uv|virtualenv"
3738
3839
40+ class Docs (enum .Enum ):
41+ Sphinx = "sphinx"
42+ MkDocs = "mkdocs"
43+
44+
3945DIR = Path (__file__ ).parent .resolve ()
4046with DIR .joinpath ("cookiecutter.json" ).open () as f :
4147 BACKENDS = json .load (f )["backend" ]
4551 project_name: cookie-{backend}
4652 backend: {backend}
4753 vcs: {vcs}
54+ docs: {docs}
4855"""
4956
5057
@@ -64,7 +71,7 @@ def get_expected_version(backend: str, vcs: bool) -> str:
6471 return "0.2.3" if vcs and backend not in {"maturin" , "mesonpy" , "uv" } else "0.1.0"
6572
6673
67- def make_copier (session : nox .Session , backend : str , vcs : bool ) -> Path :
74+ def make_copier (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
6875 package_dir = Path (f"copy-{ backend } " )
6976 if package_dir .exists ():
7077 rmtree_ro (package_dir )
@@ -84,20 +91,21 @@ def make_copier(session: nox.Session, backend: str, vcs: bool) -> Path:
84918592 "--data=license=BSD" ,
8693 f"--data=vcs={ vcs } " ,
94+ f"--data=docs={ docs .value } " ,
8795 )
8896
8997 init_git (session , package_dir )
9098
9199 return package_dir
92100
93101
94- def make_cookie (session : nox .Session , backend : str , vcs : bool ) -> Path :
102+ def make_cookie (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
95103 package_dir = Path (f"cookie-{ backend } " )
96104 if package_dir .exists ():
97105 rmtree_ro (package_dir )
98106
99107 Path ("input.yml" ).write_text (
100- JOB_FILE .format (backend = backend , vcs = vcs ), encoding = "utf-8"
108+ JOB_FILE .format (backend = backend , vcs = vcs , docs = docs . value ), encoding = "utf-8"
101109 )
102110
103111 session .run (
@@ -112,7 +120,7 @@ def make_cookie(session: nox.Session, backend: str, vcs: bool) -> Path:
112120 return package_dir
113121
114122
115- def make_cruft (session : nox .Session , backend : str , vcs : bool ) -> Path :
123+ def make_cruft (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
116124 package_dir = Path (f"cruft-{ backend } " )
117125 if package_dir .exists ():
118126 rmtree_ro (package_dir )
@@ -122,7 +130,8 @@ def make_cruft(session: nox.Session, backend: str, vcs: bool) -> Path:
122130
123131 session .cd (tmp_dir )
124132 Path ("input.yml" ).write_text (
125- JOB_FILE .format (backend = backend , pkg = package_dir , vcs = vcs ), encoding = "utf-8"
133+ JOB_FILE .format (backend = backend , pkg = package_dir , vcs = vcs , docs = docs ),
134+ encoding = "utf-8" ,
126135 )
127136 session .run (
128137 "cruft" ,
@@ -187,14 +196,15 @@ def diff_files(p1: Path, p2: Path) -> bool:
187196
188197
189198@nox .session (default = False )
199+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
190200@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
191201@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
192- def lint (session : nox .Session , backend : str , vcs : bool ) -> None :
202+ def lint (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
193203 session .install ("cookiecutter" , "pre-commit" )
194204
195205 tmp_dir = session .create_tmp ()
196206 session .cd (tmp_dir )
197- cookie = make_cookie (session , backend , vcs )
207+ cookie = make_cookie (session , backend , vcs , docs )
198208 session .chdir (cookie )
199209
200210 session .run (
@@ -213,22 +223,23 @@ def autoupdate(session: nox.Session, backend: str) -> None:
213223
214224 tmp_dir = session .create_tmp ()
215225 session .cd (tmp_dir )
216- cookie = make_cookie (session , backend , True )
226+ cookie = make_cookie (session , backend , True , Docs . Sphinx )
217227 session .chdir (cookie )
218228
219229 session .run ("pre-commit" , "autoupdate" )
220230 session .run ("git" , "diff" , "--exit-code" , external = True )
221231
222232
223233@nox .session (default = False )
234+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
224235@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
225236@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
226- def tests (session : nox .Session , backend : str , vcs : bool ) -> None :
237+ def tests (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
227238 session .install ("cookiecutter" )
228239
229240 tmp_dir = session .create_tmp ()
230241 session .cd (tmp_dir )
231- cookie = make_cookie (session , backend , vcs )
242+ cookie = make_cookie (session , backend , vcs , docs )
232243 session .chdir (cookie )
233244
234245 name = f"cookie-{ backend } "
@@ -247,14 +258,15 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None:
247258
248259
249260@nox .session (default = False )
261+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
250262@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
251263@nox .parametrize ("backend" , ("poetry" , "pdm" , "hatch" ), ids = ("poetry" , "pdm" , "hatch" ))
252- def native (session : nox .Session , backend : str , vcs : bool ) -> None :
264+ def native (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
253265 session .install ("cookiecutter" , backend )
254266
255267 tmp_dir = session .create_tmp ()
256268 session .cd (tmp_dir )
257- cookie = make_cookie (session , backend , vcs )
269+ cookie = make_cookie (session , backend , vcs , docs )
258270 session .chdir (cookie )
259271
260272 if backend == "hatch" :
@@ -268,14 +280,15 @@ def native(session: nox.Session, backend: str, vcs: bool) -> None:
268280
269281
270282@nox .session (default = False )
283+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
271284@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
272285@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
273- def dist (session : nox .Session , backend : str , vcs : bool ) -> None :
286+ def dist (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
274287 session .install ("cookiecutter" , "build" , "twine" )
275288
276289 tmp_dir = session .create_tmp ()
277290 session .cd (tmp_dir )
278- cookie = make_cookie (session , backend , vcs )
291+ cookie = make_cookie (session , backend , vcs , docs )
279292 session .chdir (cookie )
280293
281294 session .run ("python" , "-m" , "build" , silent = True )
@@ -331,14 +344,15 @@ def dist(session: nox.Session, backend: str, vcs: bool) -> None:
331344
332345
333346@nox .session (name = "nox" , default = False )
347+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
334348@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
335349@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
336- def nox_session (session : nox .Session , backend : str , vcs : bool ) -> None :
350+ def nox_session (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
337351 session .install ("cookiecutter" , "nox" )
338352
339353 tmp_dir = session .create_tmp ()
340354 session .cd (tmp_dir )
341- cookie = make_cookie (session , backend , vcs )
355+ cookie = make_cookie (session , backend , vcs , docs )
342356 session .chdir (cookie )
343357
344358 if session .posargs :
@@ -356,13 +370,14 @@ def compare_copier(session):
356370
357371 for backend in BACKENDS :
358372 for vcs in (False , True ):
359- cookie = make_cookie (session , backend , vcs )
360- copier = make_copier (session , backend , vcs )
373+ for docs in Docs :
374+ cookie = make_cookie (session , backend , vcs , docs )
375+ copier = make_copier (session , backend , vcs , docs )
361376
362- if diff_files (cookie , copier ):
363- session .log (f"{ backend } { vcs = } passed" )
364- else :
365- session .error (f"{ backend } { vcs = } files are not the same!" )
377+ if diff_files (cookie , copier ):
378+ session .log (f"{ backend } { vcs = } passed" )
379+ else :
380+ session .error (f"{ backend } { vcs = } files are not the same!" )
366381
367382
368383@nox .session (default = False )
@@ -374,13 +389,14 @@ def compare_cruft(session):
374389
375390 for backend in BACKENDS :
376391 for vcs in (False , True ):
377- cookie = make_cookie (session , backend , vcs )
378- cruft = make_cruft (session , backend , vcs )
379-
380- if diff_files (cookie , cruft ):
381- session .log (f"{ backend } { vcs = } passed" )
382- else :
383- session .error (f"{ backend } { vcs = } files are not the same!" )
392+ for docs in Docs :
393+ cookie = make_cookie (session , backend , vcs , docs )
394+ cruft = make_cruft (session , backend , vcs , docs )
395+
396+ if diff_files (cookie , cruft ):
397+ session .log (f"{ backend } { vcs = } passed" )
398+ else :
399+ session .error (f"{ backend } { vcs = } files are not the same!" )
384400
385401
386402PC_VERS = re .compile (
0 commit comments