Document Layout - AriosJentu/TestingDocumentGenerator GitHub Wiki
There is some information about documents and it's pages layouts.
Classes
This project containing next classes to work with documents:
PageStyle— class to work with document's page style. Containing formattable string for task, exercise and test elements.DocumentLayout— class which containing information about document layout file and pages style.Document— class with possibility to generate documents. Containing layout of the document and information about pages with entries.
Usage in Assignment definitions
Document classes can be obtained with importing Imports module from Modules:
import Modules.Imports as Imports
This classes contained in Imports.Documents module.
Documents
PageStyle
Class with style information about page of document. Contains next arguments:
test_format_string— format-type string with content of test option of the page. Must containing{exercises}element in string to replace them with exercises of the test, and some other text{arg1},{arg2}from executingEntrieselements.exercise_format_string— format-type string for test. Must containing{title}and{tasks}elements in string.tasks_format_string— format-type string for tasks. Must containing{task}element in string. Usage:
test_format = "\t\\generatepage{{{control_event} \\#{event_number}}}{{{student}}}{{{group}}}{{\n{exercises}\n\t}}\n"
exercise_format = "\t\t\\item {title}\n{tasks}"
tasks_format = "\n\t\t\t{task}"
page_style = Imports.Documents.PageStyle(test_format, exercise_format, tasks_format)
This example generates special page style formatting for tests, exercises, and tasks (about {control_event} and {event_number} you can read at Document Entries page). Also, check tests branch for examples.
Updater-function
For PageStyle object there is exist functional method set_page_content_updater_function to update current page content. It needs to change some generation style defects at generation.
Usage:
def replace_tabulars(content):
return content.replace("\t", " ")
page_style.set_page_content_updater_function(replace_tabulars)
This example on every page content converts tabular chars into 4 spaces.
DocumentLayout
Class to work with document layout information. Contains next arguments:
layout_path— path of the layout file. This file will be used to generate new file with content with this layout. Must containcontent_stringword, and also can contain somemodule_path_string's to replace content and module paths respectively. Example of layout file can be found in tests branch.page_style— object ofPageStyleclass, contain information about style of the pages in document.content_string— string which will be replaced with content. By default it's#CONTENT#.module_path_string— string which will be replaced with module path, if layout file contain some relative imports. By default it's#MODULE#. (for example,\usepackage{#MODULE#/Styles/style.sty}). Usage:
layout_path = "Layouts/layout.tex"
Imports.Documents.DocumentLayout(layout_path, page_style)
With custom content strings and module path strings it can be used in next form:
layout_path = "Layouts/layout.tex"
Imports.Documents.DocumentLayout(layout_path, page_style, "#CONTENTSTR#", "#MODULEPATH#")
This example generates document layout from Layouts/layout.tex file with generated below page style.