Package SCons :: Package Scanner :: Module LaTeX :: Class LaTeX
[hide private]
[frames] | no frames]

Class LaTeX

source code

object --+    
         |    
      Base --+
             |
            LaTeX

Class for scanning LaTeX files for included files.

Unlike most scanners, which use regular expressions that just
return the included file name, this returns a tuple consisting
of the keyword for the inclusion ("include", "includegraphics",
"input", or "bibliography"), and then the file name itself.  
Based on a quick look at LaTeX documentation, it seems that we 
should append .tex suffix for the "include" keywords, append .tex if
there is no extension for the "input" keyword, and need to add .bib
for the "bibliography" keyword that does not accept extensions by itself.

Finally, if there is no extension for an "includegraphics" keyword
latex will append .ps or .eps to find the file, while pdftex may use .pdf,
.jpg, .tif, .mps, or .png.

The actual subset and search order may be altered by
DeclareGraphicsExtensions command. This complication is ignored.
The default order corresponds to experimentation with teTeX
    $ latex --version
    pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
    kpathsea version 3.5.4
The order is:
    ['.eps', '.ps'] for latex
    ['.png', '.pdf', '.jpg', '.tif'].

Another difference is that the search path is determined by the type
of the file being searched:
env['TEXINPUTS'] for "input" and "include" keywords
env['TEXINPUTS'] for "includegraphics" keyword
env['TEXINPUTS'] for "lstinputlisting" keyword
env['BIBINPUTS'] for "bibliography" keyword
env['BSTINPUTS'] for "bibliographystyle" keyword
env['INDEXSTYLE'] for "makeindex" keyword, no scanning support needed
                  just allows user to set it if needed.

FIXME: also look for the class or style in document[class|style]{}
FIXME: also look for the argument of bibliographystyle{}

Instance Methods [hide private]
 
__init__(self, name, suffixes, graphics_extensions, *args, **kw)
Construct a new scanner object given a scanner function.
source code
 
_latex_names(self, include) source code
 
sort_key(self, include) source code
 
find_include(self, include, source_dir, path) source code
 
canonical_text(self, text)
Standardize an input TeX-file contents.
source code
 
scan(self, node) source code
 
scan_recurse(self, node, path=())
do a recursive scan of the top level target file This lets us search for included files based on the directory of the main file just as latex does
source code

Inherited from Base: __call__, __cmp__, __hash__, __str__, add_scanner, add_skey, get_skeys, path, recurse_nodes, select

Inherited from Base (private): _recurse_all_nodes, _recurse_no_nodes

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  keyword_paths = {'addbibresource': 'BIBINPUTS', 'addglobalbib'...
  env_variables = ['INDEXSTYLE', 'BIBINPUTS', 'TEXINPUTS', 'BSTI...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, suffixes, graphics_extensions, *args, **kw)
(Constructor)

source code 

Construct a new scanner object given a scanner function.

'function' - a scanner function taking two or three arguments and returning a list of strings.

'name' - a name for identifying this scanner object.

'argument' - an optional argument that, if specified, will be passed to both the scanner function and the path_function.

'skeys' - an optional list argument that can be used to determine which scanner should be used for a given Node. In the case of File nodes, for example, the 'skeys' would be file suffixes.

'path_function' - a function that takes four or five arguments (a construction environment, Node for the directory containing the SConscript file that defined the primary target, list of target nodes, list of source nodes, and optional argument for this instance) and returns a tuple of the directories that can be searched for implicit dependency files. May also return a callable() which is called with no args and returns the tuple (supporting Bindable class).

'node_class' - the class of Nodes which this scan will return. If node_class is None, then this scanner will not enforce any Node conversion and will return the raw results from the underlying scanner function.

'node_factory' - the factory function to be called to translate the raw results returned by the scanner function into the expected node_class objects.

'scan_check' - a function to be called to first check whether this node really needs to be scanned.

'recursive' - specifies that this scanner should be invoked recursively on all of the implicit dependencies it returns (the canonical example being #include lines in C source files). May be a callable, which will be called to filter the list of nodes found to select a subset for recursive scanning (the canonical example being only recursively scanning subdirectories within a directory).

The scanner function's first argument will be a Node that should be scanned for dependencies, the second argument will be an Environment object, the third argument will be the tuple of paths returned by the path_function, and the fourth argument will be the value passed into 'argument', and the returned list should contain the Nodes for all the direct dependencies of the file.

Examples:

s = Scanner(my_scanner_function)

s = Scanner(function = my_scanner_function)

s = Scanner(function = my_scanner_function, argument = 'foo')

Overrides: object.__init__
(inherited documentation)

canonical_text(self, text)

source code 

Standardize an input TeX-file contents.

Currently:
  • removes comments, unwrapping comment-wrapped lines.

Class Variable Details [hide private]

keyword_paths

Value:
{'addbibresource': 'BIBINPUTS',
 'addglobalbib': 'BIBINPUTS',
 'addsectionbib': 'BIBINPUTS',
 'bibliography': 'BIBINPUTS',
 'bibliographystyle': 'BSTINPUTS',
 'include': 'TEXINPUTS',
 'includegraphics': 'TEXINPUTS',
 'input': 'TEXINPUTS',
...

env_variables

Value:
['INDEXSTYLE', 'BIBINPUTS', 'TEXINPUTS', 'BSTINPUTS']