module 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
Classes#
class |
truncated documentation |
---|---|
many latex contains examples of codes this describes one of them |
|
Description of a latex file. |
|
Describes a file included a latex file. |
Static Methods#
staticmethod |
truncated documentation |
---|---|
find the greatest position which contains a value below |
Methods#
method |
truncated documentation |
---|---|
constructor |
|
constructor |
|
usual |
|
usual |
|
produces html format containing all the code example |
|
enumerate all pieces of code (in |
|
Enumerates all pieces of code (in |
|
Completes the contructor. |
|
read the latex file and stores into |
Documentation#
Ths file contains some functions to extract pieces of codes from a latex file
- class ensae_teaching_cs.homeblog.latex_file.LatexCode(parent, line, content, comment=None, content_type=None)#
Bases :
object
many latex contains examples of codes this describes one of them
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)- __init__(parent, line, content, comment=None, content_type=None)#
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)
- __str__()#
usual
- class ensae_teaching_cs.homeblog.latex_file.LatexFile(file, root=None, line=())#
Bases :
object
Description of a latex file.
attribute
meaning
file
file name for the latex file
root
every file referenced in the latex will use
root
as a root for the relative pathsfilelines
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)
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
- __init__(file, root=None, line=())#
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
- __str__()#
usual
- code_in_html(header=None, footer=None, classpre='prettyprint', classpre_type='brush: {0}', classcom='codeintro', skip_missing=False, remove_unnecessary_indentation=True)#
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
- Renvoie:
string string
- static dichotomy_find(array, value)#
find the greatest position which contains a value below
value
- Paramètres:
value – value
array – array of integers
- Renvoie:
position p such as array[p] <= value < array[p+1]
- enumerate_code(skip_missing=False)#
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
- Renvoie:
LatexCode
- read()#
read the latex file and stores into
self.content
, if the method is called a second time, the function will use a membercontent
.- Renvoie:
string (file content)
- class ensae_teaching_cs.homeblog.latex_file.LatexIncludedFile(parent, line, file, comment)#
Bases :
object
Describes 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
- 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
- __init__(parent, line, file, comment)#
- 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
- enumerate_code(skip_missing=False)#
Enumerates all pieces of code (in
verbatim
,verbatimx
or\inputcode
sections.- Renvoie:
LatexCode
- init()#
Completes the contructor.