From b113c0afcb18bfadc4b642ad89b8d2c3e600bf0c Mon Sep 17 00:00:00 2001 From: sgalland Date: Sun, 4 May 2014 00:10:03 +0200 Subject: [PATCH] Include the AutoLaTeX compiler with the builder API of LaTeXTools. This commit is related to the issue SublimeText/LaTeXTools#344. --- LaTeXTools.default-settings | 8 ++++- builders/autolatexBuilder.py | 66 ++++++++++++++++++++++++++++++++++++ makePDF.py | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 builders/autolatexBuilder.py diff --git a/LaTeXTools.default-settings b/LaTeXTools.default-settings index 8c7f2ebc3..1148eab01 100644 --- a/LaTeXTools.default-settings +++ b/LaTeXTools.default-settings @@ -86,6 +86,9 @@ // "traditional" replicates the 'old' system based on // latexmk (TeXLive) / texify (MiKTeX) // + // "autolatex" invoke autolatex with the settings + // specified in "builder_settings" + // // "script" external script: just invokes the script // specified in "builder_settings" // @@ -122,6 +125,9 @@ // (built-ins): true shows the log of each command in the output panel "display_log" : false, + // (built-ins): the level of verbosity for the builder (greater or equal to 0) + "verbose_level" : 2, + // Platform-specific settings: "osx" : { // See README or third-party documentation @@ -174,4 +180,4 @@ // Similarly, the formatting for the autocomplete panel: "cite_autocomplete_format": "{keyword}: {title}" -} \ No newline at end of file +} diff --git a/builders/autolatexBuilder.py b/builders/autolatexBuilder.py new file mode 100644 index 000000000..3785f7135 --- /dev/null +++ b/builders/autolatexBuilder.py @@ -0,0 +1,66 @@ +# ST2/ST3 compat +from __future__ import print_function +import sublime +if sublime.version() < '3000': + # we are on ST2 and Python 2.X + _ST3 = False +else: + _ST3 = True + +import os.path +import re +# This will work because makePDF.py puts the appropriate +# builders directory in sys.path +from pdfBuilder import PdfBuilder + +DEBUG = False + + + + +#---------------------------------------------------------------- +# AutoLaTeXBuilder class +# +# Call the autolatex building tool. +# + +class AutolatexBuilder(PdfBuilder): + + def __init__(self, tex_root, output, builder_settings, platform_settings): + # Sets the file name parts, plus internal stuff + super(AutolatexBuilder, self).__init__(tex_root, output, builder_settings, platform_settings) + # Now do our own initialization: set our name, see if we want to display output + self.name = "AutoLaTeX Builder" + self.display_log = builder_settings.get("display_log", False) + self.verbose_level = builder_settings.get("verbose_level", 2) + + def commands(self): + # Print greeting + self.display("\n\nAutolatexBuilder: ") + + autolatex = ["autolatex", "--stdout", "--noview", "--pdf", "--pdflatex", "--file="+self.tex_name, "--synctex"] + for lvl in range(1, self.verbose_level): + autolatex = autolatex + ["-v"] + autolatex = autolatex + ["all"] + + # We have commands in our PATH, and are in the same dir as the master file + + # This is for debugging purposes + def display_results(): + if self.display_log: + self.display("Command results:\n" ) + self.display(self.out) + self.display("\n") + + yield (autolatex, "autolatex run; ") + display_results() + + self.display("done.\n") + + + + + + + + diff --git a/makePDF.py b/makePDF.py index 80e542787..60f7dd9e1 100644 --- a/makePDF.py +++ b/makePDF.py @@ -259,7 +259,7 @@ def run(self, cmd="", file_regex="", path=""): # Safety check: if we are using a built-in builder, disregard # builder_path, even if it was specified in the pref file - if builder_name in ['simple', 'traditional', 'script', 'default','']: + if builder_name in ['simple', 'traditional', 'script', 'default','autolatex','']: builder_path = None # Now actually get the builder