Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Beamer Theme Support for LaTeX Scanner #4621

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
From Joseph Brill:
- Added error handling when creating MS VC detection debug log file specified by
SCONS_MSCOMMON_DEBUG

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

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

From Keith F Prussing:
- Added support for tracking beamer themes in the LaTeX scanner.

From Mats Wichmann:
- PackageVariable now does what the documentation always said it does
if the variable is used on the command line with one of the enabling
Expand Down Expand Up @@ -61,11 +69,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
a while loop to pull test info from a list of tests and then delete
the test, structure the test data as a list of tuples and iterate it.

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


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

Expand Down
1 change: 1 addition & 0 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CHANGED/ENHANCED EXISTING FUNCTIONALITY
keyword arguments to Builder calls (or manually, through the
undocumented Override method), were modified not to "leak" on item deletion.
The item will now not be deleted from the base environment.
- Added support for tracking beamer themes in the LaTeX scanner.

FIXES
-----
Expand Down
11 changes: 10 additions & 1 deletion SCons/Scanner/LaTeX.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ class LaTeX(ScannerBase):
'addsectionbib': 'BIBINPUTS',
'makeindex': 'INDEXSTYLE',
'usepackage': 'TEXINPUTS',
'usetheme': 'TEXINPUTS',
'usecolortheme': 'TEXINPUTS',
'usefonttheme': 'TEXINPUTS',
'useinnertheme': 'TEXINPUTS',
'useoutertheme': 'TEXINPUTS',
'lstinputlisting': 'TEXINPUTS'}
env_variables = SCons.Util.unique(list(keyword_paths.values()))
two_arg_commands = ['import', 'subimport',
Expand All @@ -193,6 +198,7 @@ def __init__(self, name, suffixes, graphics_extensions, *args, **kwargs) -> None
| addglobalbib
| addsectionbib
| usepackage
| use(?:|color|font|inner|outer)theme(?:\s*\[[^\]]+\])?
)
\s*{([^}]*)} # first arg
(?: \s*{([^}]*)} )? # maybe another arg
Expand Down Expand Up @@ -362,6 +368,9 @@ def scan(self, node, subdir: str='.'):
if inc_type in self.two_arg_commands:
inc_subdir = os.path.join(subdir, include[1])
inc_list = include[2].split(',')
elif re.match('use(|color|font|inner|outer)theme', inc_type):
inc_list = [re.sub('use', 'beamer', inc_type) + _ + '.sty' for _ in
include[1].split(',')]
else:
inc_list = include[1].split(',')
for inc in inc_list:
Expand Down Expand Up @@ -411,7 +420,7 @@ def scan_recurse(self, node, path=()):
if n is None:
# Do not bother with 'usepackage' warnings, as they most
# likely refer to system-level files
if inc_type != 'usepackage':
if inc_type != 'usepackage' or re.match("use(|color|font|inner|outer)theme", inc_type):
SCons.Warnings.warn(
SCons.Warnings.DependencyWarning,
"No dependency generated for file: %s "
Expand Down
22 changes: 22 additions & 0 deletions SCons/Scanner/LaTeXTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@
\only<2>{\includegraphics{inc7.png}}
""")

test.write('test5.latex',r"""
\usetheme{scons}
""")
test.write('beamerthemescons.sty',r"""
\usecolortheme[option]{scons}
\usefonttheme{scons}
\useinnertheme{scons}
\useoutertheme{scons}
""")
for theme in ('color', 'font', 'inner', 'outer'):
test.write('beamer' + theme + 'themescons.sty', "\n")

test.subdir('subdir')

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

class LaTeXScannerTestCase5(unittest.TestCase):
def runTest(self) -> None:
env = DummyEnvironment(TEXINPUTS=[test.workpath("subdir")],LATEXSUFFIXES = [".tex", ".ltx", ".latex"])
s = SCons.Scanner.LaTeX.LaTeXScanner()
path = s.path(env)
deps = s(env.File('test5.latex'), env, path)
files = ['beamer' + _ + 'themescons.sty' for _ in
('color', 'font', 'inner', 'outer', '')]
deps_match(self, deps, files)

if __name__ == "__main__":
unittest.main()

Expand Down