From 98d853d48b6adfd313586ed9648985067689091e Mon Sep 17 00:00:00 2001
From: Nicolas Fidel <nico24093@gmail.com>
Date: Tue, 10 Jan 2023 15:22:06 +0100
Subject: [PATCH 1/4] style: format python file

* source/conf.py,
* source/patch.py: Here.
---
 source/conf.py  | 68 ++++++++++++++++++++++++-------------------------
 source/patch.py | 47 ++++++++++++++++++++++++++++++----
 2 files changed, 76 insertions(+), 39 deletions(-)

diff --git a/source/conf.py b/source/conf.py
index 931e477f9..61f8b5007 100644
--- a/source/conf.py
+++ b/source/conf.py
@@ -1,48 +1,48 @@
 # -- Project information -----------------------------------------------------
 
-project = u'Assignments'
-copyright = u'2021, LRDE'
-author = u'LRDE'
+project = "Assignments"
+copyright = "2021, LRDE"
+author = "LRDE"
 
 # The short X.Y version
-version = u''
+version = ""
 # The full version, including alpha/beta/rc tags
-release = u''
+release = ""
 
 extensions = [
-    'sphinx.ext.extlinks',
-    'sphinx.ext.graphviz',
-    'sphinxcontrib.programoutput',
-    'sphinx-prompt',
-    'sphinx_substitution_extensions'
+    "sphinx.ext.extlinks",
+    "sphinx.ext.graphviz",
+    "sphinxcontrib.programoutput",
+    "sphinx-prompt",
+    "sphinx_substitution_extensions",
 ]
 
-smartquotes_action = 'qe'
+smartquotes_action = "qe"
 
-source_suffix = '.rst'
-master_doc = 'index'
+source_suffix = ".rst"
+master_doc = "index"
 language = None
 exclude_patterns = []
 
-pygments_style = 'sphinx'
-html_theme = 'sphinx_rtd_theme'
-html_favicon = 'favicon.ico'
-html_static_path = ['_static']
+pygments_style = "sphinx"
+html_theme = "sphinx_rtd_theme"
+html_favicon = "favicon.ico"
+html_static_path = ["_static"]
 html_show_sourcelink = False
 html_context = {
-  'css_files': [
-    '_static/theme_overrides.css',
-  ],
+    "css_files": [
+        "_static/theme_overrides.css",
+    ],
 }
 
 
 latex_documents = [
-    (master_doc, 'assignments.tex', u'assignments Documentation', u'LRDE', 'manual'),
+    (master_doc, "assignments.tex", "assignments Documentation", "LRDE", "manual"),
 ]
 
-lrde_root_url = 'https://www.lrde.epita.fr/'
+lrde_root_url = "https://www.lrde.epita.fr/"
 
-rst_prolog = f'''
+rst_prolog = f"""
     .. |Project| replace:: Tiger
     .. |compiler| replace:: TC
     .. |lrde| replace:: {lrde_root_url}
@@ -69,21 +69,21 @@ rst_prolog = f'''
     .. |pythonversion| replace:: 3.9.10
     .. |swigversion| replace:: 4.0.2
     .. |valgrindversion| replace:: 3.18.1
-'''
+"""
 
 extlinks = {
-    'lrde': (lrde_root_url + '%s', ''),
-    'wiki': (lrde_root_url + 'wiki/%s', ''),
-    'tiger': (lrde_root_url + '~tiger/%s', ''),
-    'tigerdoc': (lrde_root_url + '~tiger/doc/%s', ''),
-    'lectures': (lrde_root_url + '~tiger/lecture-notes/slides/ccmp/%s', ''),
-    'cppcgl': (
-        'https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#%s',
-        'CppCoreGuidelines#'
+    "lrde": (lrde_root_url + "%s", ""),
+    "wiki": (lrde_root_url + "wiki/%s", ""),
+    "tiger": (lrde_root_url + "~tiger/%s", ""),
+    "tigerdoc": (lrde_root_url + "~tiger/doc/%s", ""),
+    "lectures": (lrde_root_url + "~tiger/lecture-notes/slides/ccmp/%s", ""),
+    "cppcgl": (
+        "https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#%s",
+        "CppCoreGuidelines#",
     ),
 }
 
-charset_table="0..9, A..Z->a..z, _, a..z, \
+charset_table = "0..9, A..Z->a..z, _, a..z, \
   U+C0->a, U+C1->a, U+C2->a, U+C3->a, U+C4->a, U+C5->a, U+C6->a, \
   U+E0->a, U+E1->a, U+E2->a, U+E3->a, U+E4->a, U+E5->a, U+E6->a, U+C7->c,U+E7->c,\
   U+C8->e, U+C9->e, U+CA->e, U+CB->e, U+E8->e, U+E9->e, U+EA->e, U+EB->e, \
@@ -100,7 +100,7 @@ charset_table="0..9, A..Z->a..z, _, a..z, \
   U+1EBF->e, U+1EC0->e, U+1EC1->e, U+1EC2->e, U+1EC3->e, U+1EC4->e, U+1EC5->e, \
   U+1EC6->e, U+1EC7->e, U+2091->e, U+21D2->e,"
 
-latex_engine='lualatex'
+latex_engine = "lualatex"
 
 programoutput_prompt_template = """
 $ {command}
diff --git a/source/patch.py b/source/patch.py
index 62493a0f5..dfb33e857 100755
--- a/source/patch.py
+++ b/source/patch.py
@@ -13,122 +13,158 @@ def title_repl(m):
     match = m.group(1)
     return match + "\n" + "-" * len(match)
 
+
 def title_process(data):
     data = re.sub(r"@subsection ([a-zA-Z0-9 ]+)", title_repl, data)
     return data
 
+
 def node_rpl(m):
     match = m.group(1)
     return ".. _" + match + ":\n"
 
+
 def node_process(data):
     data = re.sub(r"@node ([a-zA-Z0-9 ]+)", node_rpl, data)
     return data
 
+
 def value_rpl(m):
     match = m.group(1)
     return "|" + match + "|"
 
+
 def value_process(data):
     data = re.sub(r"@value{([a-zA-Z0-9 ]+)}", value_rpl, data)
     return data
 
+
 def paragraph_rpl(m):
-    return m.group(1) + "\n  " + re.sub("\n  $", "\n", re.sub(r"\n", "\n  ", m.group(2)))
+    return (
+        m.group(1) + "\n  " + re.sub("\n  $", "\n", re.sub(r"\n", "\n  ", m.group(2)))
+    )
+
 
 def paragraph_process(data):
-    data = re.sub(r"@item ([a-zA-Z0-9\-_@{}`+: ]+)\n(.+?)(?=(@item|@end))", paragraph_rpl, data, flags=re.DOTALL)
+    data = re.sub(
+        r"@item ([a-zA-Z0-9\-_@{}`+: ]+)\n(.+?)(?=(@item|@end))",
+        paragraph_rpl,
+        data,
+        flags=re.DOTALL,
+    )
     data = re.sub(r"@table @asis", "", data)
     data = re.sub(r"@end table", "", data)
     return data
 
+
 def file_rpl(m):
     match = m.group(1)
     return ":file:`" + match + "`"
 
+
 def file_process(data):
     data = re.sub(r"@file{([a-zA-Z0-9./\-_ *]+)}", file_rpl, data)
     return data
 
+
 def code_rpl(m):
     match = m.group(1)
     return ":code:`" + match + "`"
 
+
 def code_process(data):
     data = re.sub(r"@code{([a-zA-Z0-9.\-_&|#<>:/ ]+)}", code_rpl, data)
     return data
 
+
 def comma_process(data):
     data = re.sub(r"@comma{}", ",", data)
     return data
 
+
 def ref_rpl(m):
     match = m.group(1)
-    splitted = match.split(',')
+    splitted = match.split(",")
     return ":ref:`" + splitted[0] + "`"
 
+
 def ref_process(data):
     data = re.sub(r"@ref{([a-zA-Z0-9.\n\-_:, ]+)}", ref_rpl, data)
     return data
 
+
 def xref_rpl(m):
     match = m.group(1)
-    splitted = match.split(',')
+    splitted = match.split(",")
     return ":ref:`" + splitted[0] + "`"
 
+
 def xref_process(data):
     data = re.sub(r"@xref{([a-zA-Z0-9.\n\-_:, ]+)}", xref_rpl, data)
     return data
 
+
 def acro_rpl(m):
     match = m.group(1)
     return match.upper()
 
+
 def acro_process(data):
     data = re.sub(r"@acro{([a-zA-Z0-9.\n\-_:, ]+)}", acro_rpl, data)
     return data
 
+
 def emph_rpl(m):
     match = m.group(1)
     return "*" + match + "*"
 
+
 def emph_process(data):
     data = re.sub(r"@emph{([a-zA-Z0-9.\n\-_:, ]+)}", emph_rpl, data)
     return data
 
+
 def href_rpl(m):
     match = m.group(1)
-    splitted = match.split(',')
+    splitted = match.split(",")
     return "`" + ",".join(splitted[1:]).lstrip() + " <" + splitted[0] + ">`_"
 
+
 def href_process(data):
     data = re.sub(r"@href{([a-zA-Z0-9./\n\-_:#%*, ]+)}", href_rpl, data)
     return data
 
+
 def execcaption_rpl(m):
     match = m.group(1)
     return ".. command-output::" + match + "\n"
 
+
 def execcaption_process(data):
     data = re.sub(r"@execcaption{.*,(.*)}", execcaption_rpl, data)
     return data
 
+
 def samp_process(data):
     data = re.sub(r"@samp{([a-zA-Z0-9.\-_&|#<>:/ ]+)}", code_rpl, data)
     return data
 
+
 def option_process(data):
     data = re.sub(r"@option{([a-zA-Z0-9.\-_&|#<>:/ ]+)}", code_rpl, data)
     return data
 
+
 def command_process(data):
     data = re.sub(r"@command{([a-zA-Z0-9.\-_&|#<>:/ ]+)}", code_rpl, data)
     return data
 
+
 def example_process(data):
     data = re.sub(r"@example", ".. code-block::", data)
     return data
 
+
 def main():
     data = ""
     with open(sys.argv[1], "r+") as f:
@@ -160,4 +196,5 @@ def main():
     with open(sys.argv[1], "w") as f:
         f.write(stripped)
 
+
 main()
-- 
GitLab


From 67f11091275d5ce619249e73d28aa3e9b4319597 Mon Sep 17 00:00:00 2001
From: Nicolas Fidel <nico24093@gmail.com>
Date: Mon, 16 Jan 2023 14:51:54 +0100
Subject: [PATCH 2/4] sphinx: bump to 5.0

* requirements.txt,
* source/conf.py: Here.
---
 requirements.txt | 3 ++-
 source/conf.py   | 4 +++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index edf25267b..41a6a482c 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,6 +1,7 @@
 pygments-tiger
-sphinx==3.5.4
+sphinx==5.0.0
 sphinx_rtd_theme
 sphinxcontrib-programoutput>=0.16
 sphinx-substitution-extensions
+sphinx-prompt
 jinja2<3.1
diff --git a/source/conf.py b/source/conf.py
index 61f8b5007..7fce8b2a8 100644
--- a/source/conf.py
+++ b/source/conf.py
@@ -21,7 +21,7 @@ smartquotes_action = "qe"
 
 source_suffix = ".rst"
 master_doc = "index"
-language = None
+language = "en"
 exclude_patterns = []
 
 pygments_style = "sphinx"
@@ -32,6 +32,8 @@ html_show_sourcelink = False
 html_context = {
     "css_files": [
         "_static/theme_overrides.css",
+        "_static/css/theme.css",
+        "_static/pygments.css",
     ],
 }
 
-- 
GitLab


From 6c43536c868846052fe5b2c07b7be819663f8d31 Mon Sep 17 00:00:00 2001
From: Nicolas Fidel <nico24093@gmail.com>
Date: Mon, 16 Jan 2023 17:09:39 +0100
Subject: [PATCH 3/4] dev: add hotreload system for dev

* Makefile,
* requirements.txt: Here.
---
 Makefile         | 9 +++++++++
 requirements.txt | 1 +
 2 files changed, 10 insertions(+)

diff --git a/Makefile b/Makefile
index f13eb9842..24764d24d 100644
--- a/Makefile
+++ b/Makefile
@@ -8,10 +8,19 @@ SPHINXPROJ    = assignments
 SOURCEDIR     = source
 BUILDDIR      = _build
 
+
+# variables for dev
+HOST = 0.0.0.0
+PORT = 8000
+
 # Put it first so that "make" without argument is like "make help".
 help:
 	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
+dev:
+	sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" --host $(HOST) --port $(PORT)
+
+
 .PHONY: help Makefile
 
 # Catch-all target: route all unknown targets to Sphinx using the new
diff --git a/requirements.txt b/requirements.txt
index 41a6a482c..19340d578 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,3 +5,4 @@ sphinxcontrib-programoutput>=0.16
 sphinx-substitution-extensions
 sphinx-prompt
 jinja2<3.1
+sphinx-autobuild
-- 
GitLab


From 415c780882d7137deffd33628a5e9a2f96e05fb0 Mon Sep 17 00:00:00 2001
From: Nicolas Fidel <nico24093@gmail.com>
Date: Mon, 16 Jan 2023 14:51:22 +0100
Subject: [PATCH 4/4] Dockerfile: add dockerfile for dev

* Dockerfile.dev,
* Makefile,
* README -> README.md: Here.
---
 Dockerfile.dev      | 32 ++++++++++++++++++++++++++++++++
 Makefile            | 10 +++++++---
 README => README.md | 18 +++++++++++++++++-
 3 files changed, 56 insertions(+), 4 deletions(-)
 create mode 100644 Dockerfile.dev
 rename README => README.md (77%)

diff --git a/Dockerfile.dev b/Dockerfile.dev
new file mode 100644
index 000000000..0ab184e96
--- /dev/null
+++ b/Dockerfile.dev
@@ -0,0 +1,32 @@
+FROM debian:sid
+
+LABEL maintainer="etienne.renault@lre.epita.fr"
+
+WORKDIR /tc
+
+RUN dpkg --add-architecture i386 \
+    && apt-get update \
+    && RUNLEVEL=1 DEBIAN_FRONTEND=noninteractive \
+    apt-get install -y \
+    python3 \
+    python3-dev \
+    python3-pip \
+    graphviz \
+    latexmk \
+    texlive \
+    texlive-font-utils \
+    texlive-fonts-extra \
+    texlive-luatex \
+    # Clean
+    && apt-get autoremove \
+    && apt-get clean \
+    && rm -rf /var/lib/apt/lists/
+
+
+COPY requirements.txt .
+
+RUN pip install --break-system-packages -r requirements.txt
+
+COPY . /tc/
+
+ENTRYPOINT ["make", "dev"]
diff --git a/Makefile b/Makefile
index 24764d24d..37264e3fa 100644
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,11 @@
 # You can set these variables from the command line.
 SPHINXOPTS    =
 SPHINXBUILD   = sphinx-build
+SHPINXAUTOBUILD = sphinx-autobuild
 SPHINXPROJ    = assignments
 SOURCEDIR     = source
 BUILDDIR      = _build
-
+DOCKER_IMAGE  = registry.lrde.epita.fr/tiger/assignments
 
 # variables for dev
 HOST = 0.0.0.0
@@ -17,11 +18,14 @@ PORT = 8000
 help:
 	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
 
+docker-build:
+	docker build . -f Dockerfile.dev -t $(DOCKER_IMAGE)
+
 dev:
-	sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" --host $(HOST) --port $(PORT)
+	$(SHPINXAUTOBUILD) "$(SOURCEDIR)" "$(BUILDDIR)" --host $(HOST) --port $(PORT)
 
 
-.PHONY: help Makefile
+.PHONY: help Makefile docker-build dev
 
 # Catch-all target: route all unknown targets to Sphinx using the new
 # "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
diff --git a/README b/README.md
similarity index 77%
rename from README
rename to README.md
index 7fa4f4ad6..359778466 100644
--- a/README
+++ b/README.md
@@ -1,4 +1,4 @@
-                                                            -*- text -*-
+# Assignements
 
 This package contains the specifications of the Tiger Project as done
 at EPITA, École Pour l'Informatique et les Techniques Avancées.
@@ -6,6 +6,22 @@ at EPITA, École Pour l'Informatique et les Techniques Avancées.
 To work properly, you should really be on a GNU/Linux box, since we
 run IA32 code generated with the ELF syntax, not the Mach-O one.
 
+
+# How to work locally?
+
+A special dockerfile for the developpers exists which is Dockerfile.dev
+
+## For the build:
+
+```bash
+    make docker-build
+```
+
+## To run:
+```bash
+    docker run -it --rm --workdir /tc -v $PWD:/tc -p 8000:8000 registry.lrde.epita.fr/tiger/assignments
+```
+
 -----
 
 Copyright (C) 2003-2015 Akim Demaille
-- 
GitLab