LaTeXDocumentHandler

class abjadbooktools.LaTeXDocumentHandler(assets_directory=None, input_file_contents=None, input_file_path=None, latex_root_directory=None)

A LaTeX document handler.

>>> input_file_contents = '''Let's print something:
...
... \\begin{comment}
... <abjad>
... print("hello, world!")
... </abjad>
... \\end{comment}
...
... This is just a simple Python string:
...
... \\begin{comment}
... <abjad>
... just_a_string = \'\'\'
... show(Nothing!)
... \'\'\'
... </abjad>
... \\end{comment}
...
... And let's show some music too:
...
... \\begin{comment}
... <abjad>
... show(Note("c'4"))
... </abjad>
... \\end{comment}
...
... That's it!
... '''
>>> from abjad.tools import abjadbooktools
>>> document_handler = abjadbooktools.LaTeXDocumentHandler(
...     input_file_contents=input_file_contents,
...     input_file_path='test.tex.raw',
...     assets_directory='images',
...     )

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_abjadbooktools { graph [label=abjadbooktools]; "abjad.tools.abjadbooktools.LaTeXDocumentHandler.LaTeXDocumentHandler" [color=black, fontcolor=white, group=1, label=<<B>LaTeXDocumentHandler</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=3, group=2, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abjadbooktools.LaTeXDocumentHandler.LaTeXDocumentHandler"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

assets_directory
collect_asset_output_proxies(input_blocks)
collect_input_blocks(input_file_contents[, ...]) Collects input blocks.
collect_output_blocks(input_file_contents[, ...])
console
errored
extract_code_block_options(source_line) Extracts code block options.
from_path([input_file_path, ...])
get_default_stylesheet()
input_directory
input_file_contents
input_file_path
interpret_input_blocks(input_blocks, console)
latex_assets_prefix
latex_root_directory
rebuild_source(input_blocks, output_blocks, ...)
register_error()
render_asset_output_proxies(input_blocks)
report([output_file_path, stylesheet, verbose])
unregister_error()
write_rebuilt_source(rebuilt_source[, ...])
__call__([clean, configuration, ...])
__eq__(expr) Is true when ID of expr equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad object.
__ne__(expr) Is true when Abjad object does not equal expr.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

LaTeXDocumentHandler.assets_directory
LaTeXDocumentHandler.console
LaTeXDocumentHandler.errored
LaTeXDocumentHandler.input_directory
LaTeXDocumentHandler.input_file_contents
LaTeXDocumentHandler.input_file_path
LaTeXDocumentHandler.latex_assets_prefix
LaTeXDocumentHandler.latex_root_directory

Methods

LaTeXDocumentHandler.collect_asset_output_proxies(input_blocks)
LaTeXDocumentHandler.collect_input_blocks(input_file_contents, stylesheet=None)

Collects input blocks.

>>> input_blocks = document_handler.collect_input_blocks(
...     input_file_contents.splitlines())
>>> for source_line_range in input_blocks.keys():
...     print(source_line_range)
...
(3, 5)
(11, 15)
(21, 23)
>>> for input_block in input_blocks.values():
...     print(format(input_block))
...
abjadbooktools.CodeBlock(
    ('print("hello, world!")',),
    starting_line_number=5,
    )
abjadbooktools.CodeBlock(
    ("just_a_string = '''", 'show(Nothing!)', "'''"),
    starting_line_number=15,
    )
abjadbooktools.CodeBlock(
    ('show(Note("c\'4"))',),
    starting_line_number=23,
    )
LaTeXDocumentHandler.collect_output_blocks(input_file_contents, configuration=None)
LaTeXDocumentHandler.get_default_stylesheet()
LaTeXDocumentHandler.interpret_input_blocks(input_blocks, console, verbose=True)
LaTeXDocumentHandler.rebuild_source(input_blocks, output_blocks, input_file_contents, configuration=None)
LaTeXDocumentHandler.register_error()
LaTeXDocumentHandler.render_asset_output_proxies(input_blocks)
LaTeXDocumentHandler.report(output_file_path=None, stylesheet=None, verbose=None)
LaTeXDocumentHandler.unregister_error()
LaTeXDocumentHandler.write_rebuilt_source(rebuilt_source, output_file_path=None)

Class & static methods

static LaTeXDocumentHandler.extract_code_block_options(source_line)

Extracts code block options.

>>> source_line = '<abjad>'
>>> document_handler.extract_code_block_options(source_line)
{}
>>> source_line = '<abjad>[hide=True]'
>>> document_handler.extract_code_block_options(source_line)
{'hide': True}
>>> source_line = '<abjad>[strip_prompt=true, hide=false]'
>>> options = document_handler.extract_code_block_options(
...     source_line)
>>> for key, value in sorted(options.items()):
...     key, value
...
('hide', False)
('strip_prompt', True)
>>> source_line = '<abjad>[allow_exceptions]'
>>> options = document_handler.extract_code_block_options(
...     source_line)
>>> for key, value in sorted(options.items()):
...     key, value
...
('allow_exceptions', True)
classmethod LaTeXDocumentHandler.from_path(input_file_path=None, assets_directory=None, latex_root_directory=None)

Special methods

LaTeXDocumentHandler.__call__(clean=None, configuration=None, output_file_path=None, return_source=None, skip_rendering=None, stylesheet=None, verbose=None)
(AbjadObject).__eq__(expr)

Is true when ID of expr equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(AbjadObject).__ne__(expr)

Is true when Abjad object does not equal expr. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.