<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Thomas Letan's Blog - literate-programming</title>
    <link>https://soap.coffee/~lthms/tags/literate-programming.html</link>
    <description>Posts tagged "literate-programming"</description>
    <atom:link href="https://soap.coffee/~lthms/tags/literate-programming.xml" rel="self"
               type="application/rss+xml" />
    
    
    <item>
      <title>A Literate Toolchain To Build This Website</title>
      <link>https://soap.coffee/~lthms/posts/CleopatraV1.html</link>
      <guid>https://soap.coffee/~lthms/posts/CleopatraV1.html</guid>
      <pubDate>February 4, 2020</pubDate>
      <description>
        
        &lt;h1&gt;A Literate Toolchain To Build This Website&lt;/h1&gt;&lt;div id=&quot;tags-list&quot;&gt;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#tag&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;/~lthms/tags/meta.html&quot; class=&quot;tag hover-sky&quot; marked=&quot;&quot;&gt;meta&lt;/a&gt; &lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#tag&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;/~lthms/tags/literate-programming.html&quot; class=&quot;tag hover-lemon&quot; marked=&quot;&quot;&gt;literate-programming&lt;/a&gt; &lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#tag&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&amp;nbsp;&lt;a href=&quot;/~lthms/tags/emacs.html&quot; class=&quot;tag hover-sky&quot; marked=&quot;&quot;&gt;emacs&lt;/a&gt; &lt;/div&gt;
&lt;div class=&quot;markdown-alert markdown-alert-important&quot;&gt;&lt;p class=&quot;markdown-alert-title&quot;&gt;&lt;svg class=&quot;octicon octicon-report mr-2&quot; viewbox=&quot;0 0 16 16&quot; version=&quot;1.1&quot; width=&quot;16&quot; height=&quot;16&quot; aria-hidden=&quot;true&quot;&gt;&lt;path d=&quot;M0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0 1 14.25 13H8.06l-2.573 2.573A1.458 1.458 0 0 1 3 14.543V13H1.75A1.75 1.75 0 0 1 0 11.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 0 1 .75.75v2.19l2.72-2.72a.749.749 0 0 1 .53-.22h6.5a.25.25 0 0 0 .25-.25v-9.5a.25.25 0 0 0-.25-.25Zm7 2.25v2.5a.75.75 0 0 1-1.5 0v-2.5a.75.75 0 0 1 1.5 0ZM9 9a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z&quot;&gt;&lt;/path&gt;&lt;/svg&gt;Important&lt;/p&gt;&lt;p&gt;What you are reading is actually the rendered version of a Markdown document
that was manually “translated” from the Org original document, named
&lt;code class=&quot;hljs&quot;&gt;Bootstrap.org&lt;/code&gt;. &lt;code class=&quot;hljs&quot;&gt;Bootstrap.org&lt;/code&gt; was probably complete gibberish for anyone
who isn’t me. This version was actually heavily reworked to try to fix that.&lt;/p&gt;
&lt;p&gt;In any case, the tool-suite described here has not been used to generate this
website for a while now.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;A literate program is a particular type of software program where code is not
directly written in source files, but rather in a text document as code
snippets. In essence, literate programming allows for writing in the same place
both the software program and its technical documentation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is a “literate toolchain” I have implemented to build this
website, and you are currently reading it&lt;label for=&quot;fn1&quot; class=&quot;sidenote-number margin-toggle&quot;&gt;&lt;/label&gt;&lt;input id=&quot;fn1&quot; type=&quot;checkbox&quot; class=&quot;margin-toggle&quot;&gt;&lt;span class=&quot;note-right sidenote note&quot;&gt;&lt;span class=&quot;footnote-p&quot;&gt;This sentence was true when this article was published, but things
have changed since then. &lt;/span&gt;
&lt;/span&gt;. That is, &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is
both the build system and an article of this website! To achieve this,
&lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; has been written as a collection of org files which can be
either “tangled” using &lt;a href=&quot;https://orgmode.org/worg/org-contrib/babel/&quot; class=&quot;hover-periwinkle&quot; marked=&quot;&quot;&gt;Babel&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt; or
“exported” as a HTML document. Tangling here refers to extract marked code
blocks into files.&lt;/p&gt;
&lt;p&gt;The page you are currently reading is &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; entry point. Its
primary purpose is to define two Makefiles —&lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; and &lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt;—
and the necessary emacs-lisp script to tangle this document.&lt;/p&gt;
&lt;p&gt;On the one hand, &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; is the main entrypoint of &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt;. It
serves two purposes:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It initiates a few global variables, and&lt;/li&gt;
&lt;li&gt;It provides a rule to tangle this document, that is to update itself and
&lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On the other hand, &lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt; is used to declare the various “generation
processes” used to generate this website.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; and the emacs-lisp scripts are versioned, because they are necessary
to bootstrap &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt;; but since they are also defined in this document,
it means &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; can update itself, in some sense. This is to be kept in mind
when modifying this document to hastily.&lt;/p&gt;
&lt;h2&gt;Global Constants and Variables&lt;/h2&gt;
&lt;p&gt;First, &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; defines several global “constants”&lt;label for=&quot;fn2&quot; class=&quot;sidenote-number margin-toggle&quot;&gt;&lt;/label&gt;&lt;input id=&quot;fn2&quot; type=&quot;checkbox&quot; class=&quot;margin-toggle&quot;&gt;&lt;span class=&quot;note-left sidenote note&quot;&gt;&lt;span class=&quot;footnote-p&quot;&gt;As far as I know, &lt;code class=&quot;hljs&quot;&gt;make&lt;/code&gt; does not support true &lt;em&gt;constant&lt;/em&gt; values,
It is assumed generation processes will not modify them. &lt;/span&gt;
&lt;/span&gt;. In a nutshell,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$ROOT&lt;/span&gt;&lt;/code&gt;  tells Emacs where the root of your website sources is, so
that tangled output filenames can be given relative to it rather than the org
files.  So for instance, the &lt;code class=&quot;hljs&quot;&gt;block_src&lt;/code&gt; tangle parameter for &lt;code class=&quot;hljs&quot;&gt;Makefile&lt;/code&gt;
looks like &lt;code class=&quot;hljs language-lisp&quot;&gt;:tangle Makefile&lt;/code&gt;, instead of &lt;code class=&quot;hljs language-lisp&quot;&gt;:tangle ../../Makefile&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$CLEODIR&lt;/span&gt;&lt;/code&gt; tells &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; where its sources live. If you place
it inside the &lt;code class=&quot;hljs&quot;&gt;site/&lt;/code&gt; directory (as it is intended), and you enable the use
of &lt;code class=&quot;hljs&quot;&gt;org&lt;/code&gt; files to author your contents, then &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; documents will
be part of your website. If you don’t want that, just move the directory
outside the &lt;code class=&quot;hljs&quot;&gt;site/&lt;/code&gt; directory, and update the &lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$CLEODIR&lt;/span&gt;&lt;/code&gt; variable
accordingly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this website, these constants are defined as follows&lt;label for=&quot;fn3&quot; class=&quot;sidenote-number margin-toggle&quot;&gt;&lt;/label&gt;&lt;input id=&quot;fn3&quot; type=&quot;checkbox&quot; class=&quot;margin-toggle&quot;&gt;&lt;span class=&quot;note-right sidenote note&quot;&gt;&lt;span class=&quot;footnote-p&quot;&gt;I will use a comment in the first line to recall to which file a
given block code is expected to be tangled. &lt;/span&gt;
&lt;/span&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
ROOT := &lt;span class=&quot;hljs-variable&quot;&gt;$(&lt;span class=&quot;hljs-built_in&quot;&gt;shell&lt;/span&gt; pwd)&lt;/span&gt;
CLEODIR := site/cleopatra
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We then introduce two variables to list the output of the generation processes,
with two purposes in mind: keeping the &lt;code class=&quot;hljs&quot;&gt;.gitignore&lt;/code&gt; up-to-date automatically,
and providing rules to remove them.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$ARTIFACTS&lt;/span&gt;&lt;/code&gt; lists the short-term artifacts which can be removed
frequently without too much hassle. They will be removed by &lt;code class=&quot;hljs&quot;&gt;make clean&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$CONFIGURE&lt;/span&gt;&lt;/code&gt; lists the long-term artifacts whose generation can be
time consuming. They will only be removed by&lt;code class=&quot;hljs&quot;&gt;~make cleanall&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
ARTIFACTS := build.log
CONFIGURE :=

clean :
	@rm -rf ${ARTIFACTS}

cleanall : clean
	@rm -rf ${CONFIGURE}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Generation processes can declare new build outputs using the &lt;code class=&quot;hljs&quot;&gt;+=&lt;/code&gt; assignement
operators. Using another operator will likely provoke an undesirable result.&lt;/p&gt;
&lt;h2&gt;Tangling Org Documents&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is a literate program implemented with Org mode, an Emacs major
editing mode. We provide the necessary bits to easily tangle Org documents.&lt;/p&gt;
&lt;p&gt;The configuration of Babel is done using an emacs lisp script called
&lt;code class=&quot;hljs&quot;&gt;tangle-org.el&lt;/code&gt; whose status is similar to &lt;code class=&quot;hljs&quot;&gt;Makefile&lt;/code&gt;. It is part of the
bootstrap process, and therefore lives “outside” of &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; (it is not
deleted with &lt;code class=&quot;hljs&quot;&gt;make clean&lt;/code&gt; for instance).  However, it is overwritten when this
file is tangled. If you try to modify it and find that &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; does not
work properly, you should restore it.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-lisp&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;;;; tangle-org.el:&lt;/span&gt;
(&lt;span class=&quot;hljs-name&quot;&gt;require&lt;/span&gt; &apos;org)
(&lt;span class=&quot;hljs-name&quot;&gt;cd&lt;/span&gt; (&lt;span class=&quot;hljs-name&quot;&gt;getenv&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&quot;ROOT&quot;&lt;/span&gt;))
(&lt;span class=&quot;hljs-name&quot;&gt;setq&lt;/span&gt; org-confirm-babel-evaluate &lt;span class=&quot;hljs-literal&quot;&gt;nil&lt;/span&gt;)
(&lt;span class=&quot;hljs-name&quot;&gt;setq&lt;/span&gt; org-src-preserve-indentation &lt;span class=&quot;hljs-literal&quot;&gt;t&lt;/span&gt;)
(&lt;span class=&quot;hljs-name&quot;&gt;add-to-list&lt;/span&gt; &apos;org-babel-default-header-args
             &apos;(&lt;span class=&quot;hljs-symbol&quot;&gt;:mkdirp&lt;/span&gt; . &lt;span class=&quot;hljs-string&quot;&gt;&quot;yes&quot;&lt;/span&gt;))
(&lt;span class=&quot;hljs-name&quot;&gt;org-babel-do-load-languages&lt;/span&gt;
 &apos;org-babel-load-languages
 &apos;((shell . &lt;span class=&quot;hljs-literal&quot;&gt;t&lt;/span&gt;)))
(&lt;span class=&quot;hljs-name&quot;&gt;org-babel-tangle&lt;/span&gt;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We define variables that ensure that the &lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$ROOT&lt;/span&gt;&lt;/code&gt; environment variable is
set and &lt;code class=&quot;hljs&quot;&gt;tangle-org.el&lt;/code&gt; is loaded when using Emacs.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
EMACSBIN := emacs
EMACS := ROOT=&lt;span class=&quot;hljs-string&quot;&gt;&quot;${ROOT}&quot;&lt;/span&gt; ${EMACSBIN}
TANGLE := --batch \
          --load=&lt;span class=&quot;hljs-string&quot;&gt;&quot;${ROOT}/scripts/tangle-org.el&quot;&lt;/span&gt; \
          2&amp;gt;&amp;gt; build.log
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally, we introduce a &lt;a href=&quot;https://www.gnu.org/software/make/manual/html_node/Canned-Recipes.html#Canned-Recipes&quot; class=&quot;hover-peach&quot; marked=&quot;&quot;&gt;canned
recipe&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;
to seamlessly tangle a given file&lt;label for=&quot;fn4&quot; class=&quot;sidenote-number margin-toggle&quot;&gt;&lt;/label&gt;&lt;input id=&quot;fn4&quot; type=&quot;checkbox&quot; class=&quot;margin-toggle&quot;&gt;&lt;span class=&quot;note-left sidenote note&quot;&gt;&lt;span class=&quot;footnote-p&quot;&gt;It was the first time I had used canned recipes, and I don’t think I
had the opportunity to re-use it ever again. &lt;/span&gt;
&lt;/span&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
&lt;span class=&quot;hljs-keyword&quot;&gt;define&lt;/span&gt; emacs-tangle =
echo &lt;span class=&quot;hljs-string&quot;&gt;&quot;  tangle  &lt;span class=&quot;hljs-variable&quot;&gt;$&amp;lt;&lt;/span&gt;&quot;&lt;/span&gt;
${EMACS} &lt;span class=&quot;hljs-variable&quot;&gt;$&amp;lt;&lt;/span&gt; ${TANGLE}
&lt;span class=&quot;hljs-keyword&quot;&gt;endef&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Updating &lt;code class=&quot;hljs&quot;&gt;.gitignore&lt;/code&gt; Automatically&lt;/h2&gt;
&lt;p&gt;Assuming each generation process correctly defines its &lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$ARTIFACTS&lt;/span&gt;&lt;/code&gt;
and &lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$CONFIGURE&lt;/span&gt;&lt;/code&gt; variables, we have all the information we need to
update &lt;code class=&quot;hljs&quot;&gt;.gitignore&lt;/code&gt; automatically.&lt;/p&gt;
&lt;p&gt;This is done by adding markers in &lt;code class=&quot;hljs&quot;&gt;.gitignore&lt;/code&gt; to define a region under the
control of &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt;, and writing a script to update said region after
each build.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# update-gitignore.sh:&lt;/span&gt;
BEGIN_MARKER=&lt;span class=&quot;hljs-string&quot;&gt;&quot;# begin generated files&quot;&lt;/span&gt;
END_MARKER=&lt;span class=&quot;hljs-string&quot;&gt;&quot;# begin generated files&quot;&lt;/span&gt;

&lt;span class=&quot;hljs-comment&quot;&gt;# remove the previous list of generated files to ignore&lt;/span&gt;
sed -i -e &lt;span class=&quot;hljs-string&quot;&gt;&quot;/&lt;span class=&quot;hljs-variable&quot;&gt;${BEGIN_MARKER}&lt;/span&gt;/,/&lt;span class=&quot;hljs-variable&quot;&gt;${END_MARKER}&lt;/span&gt;/d&quot;&lt;/span&gt; .gitignore
&lt;span class=&quot;hljs-comment&quot;&gt;# remove trailing empty lines&lt;/span&gt;
sed -i -e :a -e &lt;span class=&quot;hljs-string&quot;&gt;&apos;/^\n*$/{$d;N;};/\n$/ba&apos;&lt;/span&gt; .gitignore

&lt;span class=&quot;hljs-comment&quot;&gt;# output the list of files to ignore&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt; &amp;gt;&amp;gt; .gitignore
&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;${BEGIN_MARKER}&lt;/span&gt; &amp;gt;&amp;gt; .gitignore
&lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; f &lt;span class=&quot;hljs-keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;$@&lt;/span&gt;; &lt;span class=&quot;hljs-keyword&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-variable&quot;&gt;${f}&lt;/span&gt;&quot;&lt;/span&gt; &amp;gt;&amp;gt; .gitignore
&lt;span class=&quot;hljs-keyword&quot;&gt;done&lt;/span&gt;
&lt;span class=&quot;hljs-built_in&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;hljs-variable&quot;&gt;${END_MARKER}&lt;/span&gt; &amp;gt;&amp;gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code class=&quot;hljs&quot;&gt;ignore&lt;/code&gt; rule of &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; is defined as follows.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
ignore :
	@echo &lt;span class=&quot;hljs-string&quot;&gt;&quot;  update  gitignore&quot;&lt;/span&gt;
	@scripts/update-gitignore.sh \
	   ${ARTIFACTS} \
	   ${CONFIGURE}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Bootstrapping&lt;/h2&gt;
&lt;p&gt;The core purpose of &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt; remains to bootstrap the chain of generation
processes. This chain is divided into three stages: &lt;code class=&quot;hljs&quot;&gt;prebuild&lt;/code&gt;, &lt;code class=&quot;hljs&quot;&gt;build&lt;/code&gt;, and
&lt;code class=&quot;hljs&quot;&gt;postbuild&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This translates as follows in &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-comment&quot;&gt;# makefile:&lt;/span&gt;
default : postbuild ignore

init :
	@rm -f build.log

prebuild : init

build : prebuild

postbuild : build

.PHONY : init prebuild build postbuild ignore
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A &lt;em&gt;generation process&lt;/em&gt; in &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is a Makefile which provides rules for
these three stages, along with the utilities used by these rules. More
precisely, a generation process &lt;code class=&quot;hljs&quot;&gt;proc&lt;/code&gt; is defined in &lt;code class=&quot;hljs&quot;&gt;proc.mk&lt;/code&gt;. The rules of
&lt;code class=&quot;hljs&quot;&gt;proc.mk&lt;/code&gt; for each stage are expected to be prefixed by &lt;code class=&quot;hljs&quot;&gt;proc-&lt;/code&gt;, &lt;em&gt;e.g.&lt;/em&gt;,
&lt;code class=&quot;hljs&quot;&gt;proc-prebuild&lt;/code&gt; for the &lt;code class=&quot;hljs&quot;&gt;prebuild&lt;/code&gt; stage.&lt;/p&gt;
&lt;p&gt;Eventually, the following dependencies are expected between within the chain of
generation processes for every generation process.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;prebuild : proc-prebuild
build : proc-build
postbuild : proc-postbuild

proc-build : proc-prebuild
proc-postbuild : proc build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is a literate toolchain whose main purpose is to allow me to
turn the scripts I wrote to generate my website into blogposts of said website.
As such, it allows me to implement the generation processes using Org mode,
which means that before being able to start generating HTML files,
&lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; has to tangle the generation processes.&lt;/p&gt;
&lt;p&gt;To achieve this, &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; relies on a particular behavior of &lt;code class=&quot;hljs&quot;&gt;make&lt;/code&gt;
regarding the &lt;code class=&quot;hljs&quot;&gt;include&lt;/code&gt; directive. If there exists a rule to generate a
Makefile used as an operand of &lt;code class=&quot;hljs&quot;&gt;include&lt;/code&gt;, &lt;code class=&quot;hljs&quot;&gt;make&lt;/code&gt; will use this rule to update
(if necessary) said Makefile before actually including it.&lt;/p&gt;
&lt;p&gt;Therefore, the rules of the following form achieve our ambition of extensibility.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; ${PROC}.mk

prebuild : ${PROC}-prebuild
build : ${PROC}-build
postbuild : ${PROC}-postbuild

${PROC}-prebuild : ${PROC}.mk ${AUX}
${PROC}-build : ${PROC}-prebuild
${PROC}-postbuild : ${PROC}-build

${PROC}.mk ${AUX} &amp;amp;:\
   ${CLEODIR}/${IN}
	@$(emacs-tangle)

CONFIGURE += ${PROC}.mk ${AUX}

.PHONY : ${PROC}-prebuild \
         ${PROC}-build \
         ${PROC}-postbuild
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$IN&lt;/span&gt;&lt;/code&gt; is the Org document which contains the generation process code&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$PROC&lt;/span&gt;&lt;/code&gt; is the name of the generation process&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$AUX&lt;/span&gt;&lt;/code&gt; lists the utilities of the generation process tangled from
&lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$IN&lt;/span&gt;&lt;/code&gt; with &lt;code class=&quot;hljs language-bash&quot;&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$PROC&lt;/span&gt;.mk&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We use &lt;code class=&quot;hljs&quot;&gt;&amp;amp;:&lt;/code&gt; is used in place of &lt;code class=&quot;hljs&quot;&gt;:&lt;/code&gt; to separate the target from its
dependencies in the “tangle rule.”&lt;label for=&quot;fn5&quot; class=&quot;sidenote-number margin-toggle&quot;&gt;&lt;/label&gt;&lt;input id=&quot;fn5&quot; type=&quot;checkbox&quot; class=&quot;margin-toggle&quot;&gt;&lt;span class=&quot;note-right sidenote note&quot;&gt;&lt;span class=&quot;footnote-p&quot;&gt;Yet another obscure Makefile trick I have never encountered again. &lt;/span&gt;
&lt;/span&gt; This tells &lt;code class=&quot;hljs&quot;&gt;make&lt;/code&gt; that the recipe of this
rule generates all these files.&lt;/p&gt;
&lt;p&gt;Rather than writing these rules manually for each generation process we want to
define, we rely on to &lt;a href=&quot;https://orgmode.org/worg/org-tutorials/org-latex-export.html&quot; class=&quot;hover-sky&quot; marked=&quot;&quot;&gt;noweb of
Babel&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;. We call
&lt;code class=&quot;hljs&quot;&gt;extends&lt;/code&gt; the primitive to generate new generation processes.&lt;/p&gt;
&lt;p&gt;We derive the rule to tangle &lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt; using &lt;code class=&quot;hljs&quot;&gt;extends&lt;/code&gt;, using the following Org mode syntax.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs&quot;&gt;#+BEGIN_SRC makefile :noweb yes
# makefile:
&amp;lt;&amp;lt;extends(IN=&quot;Bootstrap.org&quot;, PROC=&quot;bootstrap&quot;, AUX=&quot;scripts/update-gitignore.sh&quot;)&amp;gt;&amp;gt;
#+END_SRC
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which gives the following result.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;/span&gt; bootstrap.mk

prebuild : bootstrap-prebuild
build : bootstrap-build
postbuild : bootstrap-postbuild

bootstrap-prebuild : bootstrap.mk scripts/update-gitignore.sh
bootstrap-build : bootstrap-prebuild
bootstrap-postbuild : bootstrap-build

bootstrap.mk scripts/update-gitignore.sh &amp;amp;:\
   ${CLEODIR}/Bootstrap.org
	@$(emacs-tangle)

CONFIGURE += bootstrap.mk scripts/update-gitignore.sh

.PHONY : bootstrap-prebuild \
         bootstrap-build \
         bootstrap-postbuild
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These are the last lines of &lt;code class=&quot;hljs&quot;&gt;makefile&lt;/code&gt;. The rest of the generation processes will be
declared in &lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;Generation Processes&lt;/h2&gt;
&lt;p&gt;In this section, we construct &lt;code class=&quot;hljs&quot;&gt;bootstrap.mk&lt;/code&gt; by enumerating the generation
processes that are currently used to generate the website you are reading.&lt;/p&gt;
&lt;p&gt;We recall that each generation process shall&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Define &lt;code class=&quot;hljs&quot;&gt;proc-prebuild&lt;/code&gt;, &lt;code class=&quot;hljs&quot;&gt;proc-build&lt;/code&gt;, and &lt;code class=&quot;hljs&quot;&gt;proc-postbuild&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Declare dependencies between stages of generation processes&lt;/li&gt;
&lt;li&gt;Declare build outputs (see &lt;code class=&quot;hljs&quot;&gt;ARTIFACTS&lt;/code&gt; and &lt;code class=&quot;hljs&quot;&gt;CONFIGURE&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Theming and Templating&lt;/h3&gt;
&lt;p&gt;The
&lt;a href=&quot;https://src.soap.coffee/soap.coffee/lthms.git/tree/site/cleopatra/Theme.org?id=9329e9883a52eb95c0803a46560c396d149ef2c6&quot; class=&quot;hover-peach&quot; marked=&quot;&quot;&gt;&lt;code class=&quot;hljs&quot;&gt;theme&lt;/code&gt;&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;
generation process controls the general appearance of the website. More
precisely, it introduces the main template used by &lt;code class=&quot;hljs&quot;&gt;soupault&lt;/code&gt;
(&lt;code class=&quot;hljs&quot;&gt;main/templates.html&lt;/code&gt;), and the main SASS sheet used by this template.&lt;/p&gt;
&lt;p&gt;If a generation process produces a set of styles within a specific SASS files,
the current approach is&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;To make this file a dependency of &lt;code class=&quot;hljs&quot;&gt;theme-build&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;To modify &lt;code class=&quot;hljs&quot;&gt;style/main.sass&lt;/code&gt; in &lt;code class=&quot;hljs&quot;&gt;theme&lt;/code&gt;
to import this file&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Eventually, the second step will be automated, but, in the meantime,
this customization is mandatory.&lt;/p&gt;
&lt;h3&gt;Configuring Soupault&lt;/h3&gt;
&lt;p&gt;The
&lt;a href=&quot;https://src.soap.coffee/soap.coffee/lthms.git/tree/site/cleopatra/Soupault.org?id=9329e9883a52eb95c0803a46560c396d149ef2c6&quot; class=&quot;hover-lemon&quot; marked=&quot;&quot;&gt;&lt;code class=&quot;hljs&quot;&gt;soupault&lt;/code&gt;&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;
generation configures and run &lt;code class=&quot;hljs&quot;&gt;soupault&lt;/code&gt;, in order to generate a static
website.&lt;/p&gt;
&lt;p&gt;If a generation process &lt;code class=&quot;hljs&quot;&gt;proc&lt;/code&gt; produces files that will eventually be
integrated to your website, its &lt;code class=&quot;hljs&quot;&gt;proc-build&lt;/code&gt; recipe needs to be executed
&lt;em&gt;before&lt;/em&gt; the &lt;code class=&quot;hljs&quot;&gt;soupault-build&lt;/code&gt; recipe. This can be enforced by making the
dependency explicit to &lt;code class=&quot;hljs&quot;&gt;make&lt;/code&gt;, &lt;em&gt;i.e.&lt;/em&gt;,&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;hljs language-makefile&quot;&gt;soupault-build : proc-build
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Eventually, generation processes shall be allowed to produce specific &lt;code class=&quot;hljs&quot;&gt;soupault&lt;/code&gt;
widgets to be integrated into &lt;code class=&quot;hljs&quot;&gt;soupault.conf&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;Authoring Contents&lt;/h3&gt;
&lt;p&gt;The fact that &lt;strong&gt;&lt;code class=&quot;hljs&quot;&gt;cleopatra&lt;/code&gt;&lt;/strong&gt; is a literate program which gradually generates
itself was not intended: it is a consequence of my desire to be able to easily
use whatever format I so desire for writing my contents, and Org documents in
particular.&lt;/p&gt;
&lt;p&gt;In the present website, contents can be written in the following format:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;HTML Files:&lt;/strong&gt; This requires no particular set-up, since HTML is the &lt;em&gt;lingua
franca&lt;/em&gt; of &lt;code class=&quot;hljs&quot;&gt;soupault&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regular Coq files:&lt;/strong&gt; Coq is a system which allows writing machine-checked
proofs, and it comes with a source “prettifier” called &lt;code class=&quot;hljs&quot;&gt;coqdoc&lt;/code&gt;. &lt;a href=&quot;https://src.soap.coffee/soap.coffee/lthms.git/tree/site/cleopatra/Contents/Coq.org?id=9329e9883a52eb95c0803a46560c396d149ef2c6&quot; class=&quot;hover-rose&quot; marked=&quot;&quot;&gt;Learn more
about the generation process for Coq
files&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Org documents:&lt;/strong&gt; Emacs comes with a powerful editing mode called &lt;a href=&quot;https://orgmode.org/&quot; class=&quot;hover-peach&quot; marked=&quot;&quot;&gt;Org
mode&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;, and Org documents are really pleasant to work
with. &lt;a href=&quot;https://src.soap.coffee/soap.coffee/lthms.git/tree/site/cleopatra/Contents/Org.org?id=9329e9883a52eb95c0803a46560c396d149ef2c6&quot; class=&quot;hover-sky&quot; marked=&quot;&quot;&gt;Learn more about the generation process for Org
documents&amp;nbsp;&lt;span class=&quot;icon&quot;&gt;&lt;svg&gt;&lt;use href=&quot;/~lthms/img/icons.svg#external-link&quot;&gt;&lt;/use&gt;&lt;/svg&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
        
      </description>
    </item>
    
    
  </channel>
</rss>
