You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pretext/cli.py
+53-11Lines changed: 53 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -326,6 +326,13 @@ def init(refresh):
326
326
type=click.Choice(ASSETS, case_sensitive=False),
327
327
help="Generates assets for target. -g [asset] will generate the specific assets given.",
328
328
)
329
+
@click.option(
330
+
"-q",
331
+
"--no-generate",
332
+
is_flag=True,
333
+
default=False,
334
+
help="Do not generate assets for target, even if their source has changed since last build.",
335
+
)
329
336
@click.option(
330
337
"-x", "--xmlid", type=click.STRING, help="xml:id of element to be generated."
331
338
)
@@ -340,16 +347,14 @@ def build(
340
347
target,
341
348
clean,
342
349
generate,
350
+
no_generate,
343
351
xmlid: t.Optional[str],
344
352
project_ptx_override: t.Tuple[str, str],
345
353
):
346
354
"""
347
355
Build [TARGET] according to settings specified by project.ptx.
348
356
349
-
If using certain elements (webwork, latex-image, etc.) then
350
-
using `--generate` may be necessary for a successful build. Generated
351
-
assets are cached so they need not be regenerated in subsequent builds unless
352
-
they are changed.
357
+
If using elements that require separate generation of assets (e.g., webwork, latex-image, etc.) then these will be generated automatically if their source has changed since the last build. You can suppress this with the `--no-generate` flag, or force a regeneration with the `--generate` flag.
353
358
354
359
Certain builds may require installations not included with the CLI, or internet
355
360
access to external servers. Command-line paths
@@ -375,23 +380,60 @@ def build(
375
380
target=project.target(name=target_name)
376
381
iftarget_nameisNone:
377
382
log.info(
378
-
f"Since no build target was supplied, the first target of the project.ptx manifest ({target.name()}) will be built."
383
+
f"Since no build target was supplied, the first target of the project.ptx manifest ({target.name()}) will be built.\n"
f"\nIt appears the source has changed of an asset that needs to be generated. Now generating asset: {asset} with xmlid: {id}."
418
+
)
419
+
project.generate(
420
+
target.name(), asset_list=[asset], xmlid=id
421
+
)
422
+
target.save_asset_table(target.asset_hash())
423
+
else:
424
+
log.info("Skipping asset generation as requested.")
385
425
ifgenerate=="ALL":
386
-
log.info("Generating all assets in default formats.")
426
+
log.info("Generating all assets in default formats as requested.")
427
+
log.info(
428
+
"Note: PreTeXt will automatically generate assets that have been changed since your last build, so this option is no longer necessary unless something isn't happening as expected."
429
+
)
387
430
project.generate(target.name())
388
431
elifgenerateisnotNone:
389
-
log.warning(f"Generating only {generate} assets.")
432
+
log.info(f"Generating {generate} assets as requested.")
433
+
log.info(
434
+
"Note: PreTeXt will automatically generate assets that have been changed since your last build, so this option is no longer necessary unless something isn't happening as expected."
0 commit comments