Skip to content

Commit 3b6e4d1

Browse files
authored
Merge pull request SCons#4621 from kprussing/feature/latex-beamer-support
Add Beamer Theme Support for LaTeX Scanner
2 parents 2973001 + 590b9bd commit 3b6e4d1

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

CHANGES.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,18 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
1515
From Joseph Brill:
1616
- Added error handling when creating MS VC detection debug log file specified by
1717
SCONS_MSCOMMON_DEBUG
18+
19+
From Alex James:
20+
- On Darwin, PermissionErrors are now handled while trying to access
21+
/etc/paths.d. This may occur if SCons is invoked in a sandboxed
22+
environment (such as Nix).
1823

1924
From Dillan Mills:
2025
- Fix support for short options (`-x`).
2126

27+
From Keith F Prussing:
28+
- Added support for tracking beamer themes in the LaTeX scanner.
29+
2230
From Mats Wichmann:
2331
- PackageVariable now does what the documentation always said it does
2432
if the variable is used on the command line with one of the enabling
@@ -61,11 +69,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
6169
a while loop to pull test info from a list of tests and then delete
6270
the test, structure the test data as a list of tuples and iterate it.
6371

64-
From Alex James:
65-
- On Darwin, PermissionErrors are now handled while trying to access
66-
/etc/paths.d. This may occur if SCons is invoked in a sandboxed
67-
environment (such as Nix).
68-
6972

7073
RELEASE 4.8.1 - Tue, 03 Sep 2024 17:22:20 -0700
7174

RELEASE.txt

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
3333
keyword arguments to Builder calls (or manually, through the
3434
undocumented Override method), were modified not to "leak" on item deletion.
3535
The item will now not be deleted from the base environment.
36+
- Added support for tracking beamer themes in the LaTeX scanner.
3637

3738
FIXES
3839
-----

SCons/Scanner/LaTeX.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class LaTeX(ScannerBase):
169169
'addsectionbib': 'BIBINPUTS',
170170
'makeindex': 'INDEXSTYLE',
171171
'usepackage': 'TEXINPUTS',
172+
'usetheme': 'TEXINPUTS',
173+
'usecolortheme': 'TEXINPUTS',
174+
'usefonttheme': 'TEXINPUTS',
175+
'useinnertheme': 'TEXINPUTS',
176+
'useoutertheme': 'TEXINPUTS',
172177
'lstinputlisting': 'TEXINPUTS'}
173178
env_variables = SCons.Util.unique(list(keyword_paths.values()))
174179
two_arg_commands = ['import', 'subimport',
@@ -193,6 +198,7 @@ def __init__(self, name, suffixes, graphics_extensions, *args, **kwargs) -> None
193198
| addglobalbib
194199
| addsectionbib
195200
| usepackage
201+
| use(?:|color|font|inner|outer)theme(?:\s*\[[^\]]+\])?
196202
)
197203
\s*{([^}]*)} # first arg
198204
(?: \s*{([^}]*)} )? # maybe another arg
@@ -362,6 +368,9 @@ def scan(self, node, subdir: str='.'):
362368
if inc_type in self.two_arg_commands:
363369
inc_subdir = os.path.join(subdir, include[1])
364370
inc_list = include[2].split(',')
371+
elif re.match('use(|color|font|inner|outer)theme', inc_type):
372+
inc_list = [re.sub('use', 'beamer', inc_type) + _ + '.sty' for _ in
373+
include[1].split(',')]
365374
else:
366375
inc_list = include[1].split(',')
367376
for inc in inc_list:
@@ -411,7 +420,7 @@ def scan_recurse(self, node, path=()):
411420
if n is None:
412421
# Do not bother with 'usepackage' warnings, as they most
413422
# likely refer to system-level files
414-
if inc_type != 'usepackage':
423+
if inc_type != 'usepackage' or re.match("use(|color|font|inner|outer)theme", inc_type):
415424
SCons.Warnings.warn(
416425
SCons.Warnings.DependencyWarning,
417426
"No dependency generated for file: %s "

SCons/Scanner/LaTeXTests.py

+22
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@
6363
\only<2>{\includegraphics{inc7.png}}
6464
""")
6565

66+
test.write('test5.latex',r"""
67+
\usetheme{scons}
68+
""")
69+
test.write('beamerthemescons.sty',r"""
70+
\usecolortheme[option]{scons}
71+
\usefonttheme{scons}
72+
\useinnertheme{scons}
73+
\useoutertheme{scons}
74+
""")
75+
for theme in ('color', 'font', 'inner', 'outer'):
76+
test.write('beamer' + theme + 'themescons.sty', "\n")
77+
6678
test.subdir('subdir')
6779

6880
test.write('inc1.tex',"\n")
@@ -167,6 +179,16 @@ def runTest(self) -> None:
167179
files = ['inc1.tex', 'inc2.tex', 'inc5.xyz', 'inc7.png']
168180
deps_match(self, deps, files)
169181

182+
class LaTeXScannerTestCase5(unittest.TestCase):
183+
def runTest(self) -> None:
184+
env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
185+
s = SCons.Scanner.LaTeX.LaTeXScanner()
186+
path = s.path(env)
187+
deps = s(env.File('test5.latex'), env, path)
188+
files = ['beamer' + _ + 'themescons.sty' for _ in
189+
('color', 'font', 'inner', 'outer', '')]
190+
deps_match(self, deps, files)
191+
170192
if __name__ == "__main__":
171193
unittest.main()
172194

0 commit comments

Comments
 (0)