module homeblog.latex_file

Inheritance diagram of ensae_teaching_cs.homeblog.latex_file

Short summary

module ensae_teaching_cs.homeblog.latex_file

Ths file contains some functions to extract pieces of codes from a latex file

source on GitHub

Classes

class truncated documentation
LatexCode many latex contains examples of codes this describes one of them
LatexFile description of a latex file
LatexIncludedFile describe a file included a latex file

Static Methods

staticmethod truncated documentation
dichotomy_find find the greatest position which contains a value below value

Methods

method truncated documentation
__init__ constructor
__init__ constructor
__init__ constructor
__str__ usual
__str__ usual
code_in_html produces html format containing all the code example
enumerate_code enumerate all pieces of code (in verbatim, verbatimx or \inputcode sections
enumerate_code enumerate all pieces of code (in verbatim, verbatimx or \inputcode sections
init complete the contructor
read read the latex file and stores into self.content, if the method is called a second time, the function will use a member …

Documentation

Ths file contains some functions to extract pieces of codes from a latex file

source on GitHub

class ensae_teaching_cs.homeblog.latex_file.LatexCode(parent, line, content, comment=None, content_type=None)[source]

Bases : object

many latex contains examples of codes this describes one of them

source on GitHub

constructor

Paramètres:
  • parent – (LatexFile) object
  • line – number (int), 0 is the first one
  • content – code content
  • comment – comment for the piece of code

if comment contains (--<something>--), it indicates the content type of the zone (ie: py)

source on GitHub

__init__(parent, line, content, comment=None, content_type=None)[source]

constructor

Paramètres:
  • parent – (LatexFile) object
  • line – number (int), 0 is the first one
  • content – code content
  • comment – comment for the piece of code

if comment contains (--<something>--), it indicates the content type of the zone (ie: py)

source on GitHub

__str__()[source]

usual

source on GitHub

class ensae_teaching_cs.homeblog.latex_file.LatexFile(file, root=None, line=())[source]

Bases : object

description of a latex file

attribute meaning
file file name for the late file
root every file referenced in the latex will use root as a root for the relative paths
filelines for each line, we store every included file here, it is a dictionary { line number : object file }
line keeps line number in a stack (if this file is included by another one)

source on GitHub

constructor

Paramètres:
  • file – file name
  • root – for included files, the root determines the folder relative paths refer to, if None, the file folder will be used as a root
  • line – if this file is included by another one, it keeps the line number in a stack

source on GitHub

__init__(file, root=None, line=())[source]

constructor

Paramètres:
  • file – file name
  • root – for included files, the root determines the folder relative paths refer to, if None, the file folder will be used as a root
  • line – if this file is included by another one, it keeps the line number in a stack

source on GitHub

__str__()[source]

usual

source on GitHub

code_in_html(header=None, footer=None, classpre='prettyprint', classpre_type='brush: {0}', classcom='codeintro', skip_missing=False, remove_unnecessary_indentation=True)[source]

produces html format containing all the code example

Paramètres:
  • header – if not None, it should end by <body>
  • footer – if not None, it should start by </body>
  • classpre – if not, use <pre> otherwise <pre class="classpre">
  • classpre_type – if the type can be guessed, then this template will used instead of the first one
  • classcom – if the comment is not none, it will output <p class="classcom"> (if classcom is not None)
  • skip_missing – if True, avoids stopping whenever a file is not found
  • remove_unnecessary_indentation – remove unnecessary indentation
Retourne:

string string

source on GitHub

static dichotomy_find(array, value)[source]

find the greatest position which contains a value below value

Paramètres:
  • value – value
  • array – array of integers
Retourne:

position p such as array[p] <= value < array[p+1]

source on GitHub

enumerate_code(skip_missing=False)[source]

enumerate all pieces of code (in verbatim, verbatimx or \inputcode sections

Paramètres:skip_missing – if True, avoids stopping whenever a file is not found
Retourne:LatexCode

source on GitHub

read()[source]

read the latex file and stores into self.content, if the method is called a second time, the function will use a member content.

Retourne:string (file content)

source on GitHub

class ensae_teaching_cs.homeblog.latex_file.LatexIncludedFile(parent, line, file, comment)[source]

Bases : object

describe a file included a latex file

attribute meaning
parent (LatexFile)
line (int) line number
file (str) file name
comment (str) comment
obj (LatexFile|LatexCode) object

source on GitHub

constructor

Paramètres:
  • parent – (LatexFile) which contains this file
  • line – line number where it was found in the late file it belongs to
  • file – file name
  • comment – comment

source on GitHub

__init__(parent, line, file, comment)[source]

constructor

Paramètres:
  • parent – (LatexFile) which contains this file
  • line – line number where it was found in the late file it belongs to
  • file – file name
  • comment – comment

source on GitHub

enumerate_code(skip_missing=False)[source]

enumerate all pieces of code (in verbatim, verbatimx or \inputcode sections

Retourne:LatexCode

source on GitHub

init()[source]

complete the contructor

source on GitHub