diff --git a/config/_default/config.toml b/config/_default/config.toml index bea15ca4dee..3ebaa0669f0 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -39,7 +39,7 @@ summaryLength = 50 # Listing summary length in words. Also, see `abstract_lengt paginate = 10 # Number of items per page in paginated lists. enableEmoji = true footnotereturnlinkcontents = "^" -ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$"] +ignoreFiles = ["\\.ipynb$", ".ipynb_checkpoints$", "\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$", "\\.py$", "\\.mdOUT$"] # Workaround Hugo publishing taxonomy URLs as plurals - consistently use singular across Academic. [permalinks] diff --git a/scripts/rebrand/allowed_changes.txt b/scripts/rebrand/allowed_changes.txt index abad4c66659..b2ca42a2459 100644 --- a/scripts/rebrand/allowed_changes.txt +++ b/scripts/rebrand/allowed_changes.txt @@ -7,6 +7,11 @@ resources/directory.json # The directory's filter data (D16, #868) resources/search.json # The directory's search data, fetched on first search (D16, #868) resources/index.html # Became a list page for its pager, so its SEO tags gain CollectionPage home/7-newsletter.md.old # A retired draft that Hugo copied out by accident, not a page +resources/resource.py # #976: generator script (or draft) Hugo published by accident, not a page +summaries/summaries.py # #976: generator script (or draft) Hugo published by accident, not a page +glossary/_create_glossaries.py # #976: generator script (or draft) Hugo published by accident, not a page +glossary/_build_references.py # #976: generator script (or draft) Hugo published by accident, not a page +replication-hub/submit/submit.mdOUT # #976: generator script (or draft) Hugo published by accident, not a page about/visitors/index.html # Its generated description quotes the stats table, whose link text lost "https://" for the preview js/load-theme.js # The theme's day/night script, gone with the theme's look js/academic.min.FINGERPRINT.js # The theme's script bundle, without its search, under a new name while some pages still need it diff --git a/scripts/tests/test_bundle_exclusions.py b/scripts/tests/test_bundle_exclusions.py new file mode 100644 index 00000000000..8f21c0a5cca --- /dev/null +++ b/scripts/tests/test_bundle_exclusions.py @@ -0,0 +1,33 @@ +"""Hugo's ignoreFiles keeps generator scripts and drafts in content/ out of the site (#976). + +Run: python3 -m unittest discover -s scripts/tests -p test_bundle_exclusions.py +""" + +from pathlib import Path +import re +import tomllib +import unittest + +ROOT = Path(__file__).resolve().parents[2] +CONFIG = tomllib.loads((ROOT / "config/_default/config.toml").read_text(encoding="utf-8")) + + +def ignored(path): + return any(re.search(pattern, path) for pattern in CONFIG["ignoreFiles"]) + + +class BundleExclusionTests(unittest.TestCase): + def test_generator_scripts_and_drafts_are_ignored(self): + for path in sorted(ROOT.glob("content/**/*.py")) + sorted(ROOT.glob("content/**/*.mdOUT")): + with self.subTest(path=path): + self.assertTrue(ignored(str(path.relative_to(ROOT)))) + + def test_pages_and_bundle_assets_are_not_ignored(self): + for path in ("content/summaries/_index.md", "content/summaries/FORRT_O&R_101_Syllabus.pdf", + "content/glossary/apa_lookup.json", "content/clusters/FORRT_Clusters.webp"): + with self.subTest(path=path): + self.assertFalse(ignored(path)) + + +if __name__ == "__main__": + unittest.main()