1515import difflib
1616import email .parser
1717import email .policy
18+ import enum
1819import functools
1920import json
2021import os
3839nox .options .default_venv_backend = "uv|virtualenv"
3940
4041
42+ class Docs (enum .Enum ):
43+ Sphinx = "sphinx"
44+ MkDocs = "mkdocs"
45+
46+
4147DIR = Path (__file__ ).parent .resolve ()
4248with DIR .joinpath ("cookiecutter.json" ).open () as f :
4349 BACKENDS = json .load (f )["backend" ]
4753 project_name: cookie-{backend}
4854 backend: {backend}
4955 vcs: {vcs}
56+ docs: {docs}
5057"""
5158
5259
@@ -66,7 +73,7 @@ def get_expected_version(backend: str, vcs: bool) -> str:
6673 return "0.2.3" if vcs and backend not in {"maturin" , "mesonpy" , "uv" } else "0.1.0"
6774
6875
69- def make_copier (session : nox .Session , backend : str , vcs : bool ) -> Path :
76+ def make_copier (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
7077 package_dir = Path (f"copy-{ backend } " )
7178 if package_dir .exists ():
7279 rmtree_ro (package_dir )
@@ -86,20 +93,21 @@ def make_copier(session: nox.Session, backend: str, vcs: bool) -> Path:
86938794 "--data=license=BSD" ,
8895 f"--data=vcs={ vcs } " ,
96+ f"--data=docs={ docs .value } " ,
8997 )
9098
9199 init_git (session , package_dir )
92100
93101 return package_dir
94102
95103
96- def make_cookie (session : nox .Session , backend : str , vcs : bool ) -> Path :
104+ def make_cookie (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
97105 package_dir = Path (f"cookie-{ backend } " )
98106 if package_dir .exists ():
99107 rmtree_ro (package_dir )
100108
101109 Path ("input.yml" ).write_text (
102- JOB_FILE .format (backend = backend , vcs = vcs ), encoding = "utf-8"
110+ JOB_FILE .format (backend = backend , vcs = vcs , docs = docs . value ), encoding = "utf-8"
103111 )
104112
105113 session .run (
@@ -114,7 +122,7 @@ def make_cookie(session: nox.Session, backend: str, vcs: bool) -> Path:
114122 return package_dir
115123
116124
117- def make_cruft (session : nox .Session , backend : str , vcs : bool ) -> Path :
125+ def make_cruft (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> Path :
118126 package_dir = Path (f"cruft-{ backend } " )
119127 if package_dir .exists ():
120128 rmtree_ro (package_dir )
@@ -124,7 +132,8 @@ def make_cruft(session: nox.Session, backend: str, vcs: bool) -> Path:
124132
125133 session .cd (tmp_dir )
126134 Path ("input.yml" ).write_text (
127- JOB_FILE .format (backend = backend , pkg = package_dir , vcs = vcs ), encoding = "utf-8"
135+ JOB_FILE .format (backend = backend , pkg = package_dir , vcs = vcs , docs = docs ),
136+ encoding = "utf-8" ,
128137 )
129138 session .run (
130139 "cruft" ,
@@ -189,14 +198,15 @@ def diff_files(p1: Path, p2: Path) -> bool:
189198
190199
191200@nox .session (default = False )
201+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
192202@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
193203@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
194- def lint (session : nox .Session , backend : str , vcs : bool ) -> None :
204+ def lint (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
195205 session .install ("cookiecutter" , "pre-commit" )
196206
197207 tmp_dir = session .create_tmp ()
198208 session .cd (tmp_dir )
199- cookie = make_cookie (session , backend , vcs )
209+ cookie = make_cookie (session , backend , vcs , docs )
200210 session .chdir (cookie )
201211
202212 session .run (
@@ -215,22 +225,23 @@ def autoupdate(session: nox.Session, backend: str) -> None:
215225
216226 tmp_dir = session .create_tmp ()
217227 session .cd (tmp_dir )
218- cookie = make_cookie (session , backend , True )
228+ cookie = make_cookie (session , backend , True , Docs . Sphinx )
219229 session .chdir (cookie )
220230
221231 session .run ("pre-commit" , "autoupdate" )
222232 session .run ("git" , "diff" , "--exit-code" , external = True )
223233
224234
225235@nox .session (default = False )
236+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
226237@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
227238@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
228- def tests (session : nox .Session , backend : str , vcs : bool ) -> None :
239+ def tests (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
229240 session .install ("cookiecutter" )
230241
231242 tmp_dir = session .create_tmp ()
232243 session .cd (tmp_dir )
233- cookie = make_cookie (session , backend , vcs )
244+ cookie = make_cookie (session , backend , vcs , docs )
234245 session .chdir (cookie )
235246
236247 name = f"cookie-{ backend } "
@@ -249,14 +260,15 @@ def tests(session: nox.Session, backend: str, vcs: bool) -> None:
249260
250261
251262@nox .session (default = False )
263+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
252264@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
253265@nox .parametrize ("backend" , ("poetry" , "pdm" , "hatch" ), ids = ("poetry" , "pdm" , "hatch" ))
254- def native (session : nox .Session , backend : str , vcs : bool ) -> None :
266+ def native (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
255267 session .install ("cookiecutter" , backend )
256268
257269 tmp_dir = session .create_tmp ()
258270 session .cd (tmp_dir )
259- cookie = make_cookie (session , backend , vcs )
271+ cookie = make_cookie (session , backend , vcs , docs )
260272 session .chdir (cookie )
261273
262274 if backend == "hatch" :
@@ -270,14 +282,15 @@ def native(session: nox.Session, backend: str, vcs: bool) -> None:
270282
271283
272284@nox .session (default = False )
285+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
273286@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
274287@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
275- def dist (session : nox .Session , backend : str , vcs : bool ) -> None :
288+ def dist (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
276289 session .install ("cookiecutter" , "build" , "twine" )
277290
278291 tmp_dir = session .create_tmp ()
279292 session .cd (tmp_dir )
280- cookie = make_cookie (session , backend , vcs )
293+ cookie = make_cookie (session , backend , vcs , docs )
281294 session .chdir (cookie )
282295
283296 session .run ("python" , "-m" , "build" , silent = True )
@@ -333,14 +346,15 @@ def dist(session: nox.Session, backend: str, vcs: bool) -> None:
333346
334347
335348@nox .session (name = "nox" , default = False )
349+ @nox .parametrize ("docs" , list (Docs ), ids = [d .value for d in Docs ])
336350@nox .parametrize ("vcs" , [False , True ], ids = ["novcs" , "vcs" ])
337351@nox .parametrize ("backend" , BACKENDS , ids = BACKENDS )
338- def nox_session (session : nox .Session , backend : str , vcs : bool ) -> None :
352+ def nox_session (session : nox .Session , backend : str , vcs : bool , docs : Docs ) -> None :
339353 session .install ("cookiecutter" , "nox" )
340354
341355 tmp_dir = session .create_tmp ()
342356 session .cd (tmp_dir )
343- cookie = make_cookie (session , backend , vcs )
357+ cookie = make_cookie (session , backend , vcs , docs )
344358 session .chdir (cookie )
345359
346360 if session .posargs :
@@ -358,13 +372,14 @@ def compare_copier(session):
358372
359373 for backend in BACKENDS :
360374 for vcs in (False , True ):
361- cookie = make_cookie (session , backend , vcs )
362- copier = make_copier (session , backend , vcs )
375+ for docs in Docs :
376+ cookie = make_cookie (session , backend , vcs , docs )
377+ copier = make_copier (session , backend , vcs , docs )
363378
364- if diff_files (cookie , copier ):
365- session .log (f"{ backend } { vcs = } passed" )
366- else :
367- session .error (f"{ backend } { vcs = } files are not the same!" )
379+ if diff_files (cookie , copier ):
380+ session .log (f"{ backend } { vcs = } passed" )
381+ else :
382+ session .error (f"{ backend } { vcs = } files are not the same!" )
368383
369384
370385@nox .session (default = False )
@@ -376,13 +391,14 @@ def compare_cruft(session):
376391
377392 for backend in BACKENDS :
378393 for vcs in (False , True ):
379- cookie = make_cookie (session , backend , vcs )
380- cruft = make_cruft (session , backend , vcs )
381-
382- if diff_files (cookie , cruft ):
383- session .log (f"{ backend } { vcs = } passed" )
384- else :
385- session .error (f"{ backend } { vcs = } files are not the same!" )
394+ for docs in Docs :
395+ cookie = make_cookie (session , backend , vcs , docs )
396+ cruft = make_cruft (session , backend , vcs , docs )
397+
398+ if diff_files (cookie , cruft ):
399+ session .log (f"{ backend } { vcs = } passed" )
400+ else :
401+ session .error (f"{ backend } { vcs = } files are not the same!" )
386402
387403
388404PC_VERS = re .compile (
0 commit comments