Skip to content

Commit 9a6cc22

Browse files
committed
add testing option for generating references
1 parent 27702a4 commit 9a6cc22

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
1313

1414
- New "handout" division, similar to worksheets, but intended for pages you print without exercises.
1515
- `@workspace` can go on most paragraph-level elements in worksheets and handouts.
16+
- Experimental support for improve bibliographies using citeproc. `pretext generate references` will generate the required xml file in generated assets.
1617

1718
### Fixed
1819

pretext/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
"mermaid": ".//mermaid",
142142
"myopenmath": ".//myopenmath",
143143
"dynamic-subs": ".//statement[.//fillin and ancestor::exercise/evaluation]",
144+
"references": ".//biblio"
144145
}
145146
ASSETS = ["ALL"] + list(ASSET_TO_XPATH.keys())
146147

pretext/project/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,22 @@ def generate_assets(
886886
"""
887887
log.info("Generating any needed assets.")
888888

889+
# To help with debugging, we are temporarily adding a reference generation step here. The only way this will be called is if `pretext generate references` is called explicitly.
890+
if requested_asset_types == ("references",):
891+
try:
892+
core.references(
893+
xml_source=self.source_abspath(),
894+
pub_file=self.publication_abspath().as_posix(),
895+
stringparams=self.stringparams.copy(),
896+
xmlid_root=xmlid,
897+
dest_dir=self.generated_dir_abspath() / "references",
898+
)
899+
except Exception as e:
900+
log.error(f"Unable to generate some references:\n {e}")
901+
log.debug(e, exc_info=True)
902+
finally:
903+
return
904+
889905
# clear out the generated assets and cache if requested
890906
if clean:
891907
self.clean_assets()
@@ -1192,6 +1208,20 @@ def generate_assets(
11921208
except Exception as e:
11931209
log.error(f"Unable to generate some datafiles:\n {e}")
11941210
log.debug(e, exc_info=True)
1211+
# The following code will eventually be needed, but for now, we leave as a placeholder.
1212+
#if "references" in assets_to_generate and debug_references:
1213+
# try:
1214+
# core.references(
1215+
# xml_source=self.source_abspath(),
1216+
# pub_file=self.publication_abspath().as_posix(),
1217+
# stringparams=stringparams_copy,
1218+
# xmlid_root=xmlid,
1219+
# dest_dir=self.generated_dir_abspath() / "references",
1220+
# )
1221+
# successful_assets.append("references")
1222+
# except Exception as e:
1223+
# log.error(f"Unable to generate some references:\n {e}")
1224+
# log.debug(e, exc_info=True)
11951225
# Delete temporary directories left behind by core:
11961226
try:
11971227
core.release_temporary_directories()

0 commit comments

Comments
 (0)