Testing the autorun
Sphinx extension¶
In this page, I am testing an « experimental » feature of Sphinx,
the autorun extension, which provides a .. runblock::
directive,
to execute arbitrary code when generating a Sphinx-powered web-page.
Voir aussi
For a list of possibly useful Sphinx extensions, this page gives a good overview.
Examples¶
pycon¶
The first directive is ..runblock:: pycon
.
It uses the Python language,
but accepts the syntax of an interactive interpreter session.
For instance, this snippet of code:
.. runblock:: pycon
>>> for i in range(5):
... print(i)
will produce this output (raw included in the HTML web-page):
File "<stdin>", line 2
rint(i)
^
IndentationError: expected an indented block
We can also check which version of Python used by the extension:
2.7.18 (default, Jul 1 2022, 12:27:04)
[GCC 9.4.0]
This .. runblock:: pycon
directive is interesting to give example or short demonstration, when writing tutorials or documentation for instance.
But this runcode extension allows to do way more!
A few more interesting examples¶
.. runblock:: console
¶
This directive accepts the syntax of a shell or Bash session, where the code starts with a *$ * symbol.
For instance, the current date and directory:
$ echo "Date: $(date). Directory: $(pwd)."
Date: sam. 17 févr. 2024 13:14:23 CET. Directory: /home/lilian/web-sphinx.
We can also ask for a list of the reStructuredText files .rst
(the source code of each of these web-pages) in the current directory:
$ ls -larth ./{,.}*.rst
-rw-r--r-- 1 lilian lilian 650 janv. 30 2017 ./.javascript.fr.rst
-rw-r--r-- 1 lilian lilian 578 janv. 30 2017 ./.javascript.en.rst
lrwxrwxrwx 1 lilian lilian 22 juin 16 2020 ./admin.rst -> /home/lilian/admin.rst
-rw-r--r-- 1 lilian lilian 739 févr. 8 2021 ./.special.rst
-rw-r--r-- 1 lilian lilian 12K mars 14 2021 ./.blagues.rst
-rw-r--r-- 1 lilian lilian 2,4K avril 12 2021 ./404.rst
-rw-r--r-- 1 lilian lilian 2,4K avril 12 2021 ./403.rst
-rw-r--r-- 1 lilian lilian 8,7K avril 12 2021 ./affaires-voyage.fr.rst
-rw-r--r-- 1 lilian lilian 1,8K avril 12 2021 ./ace.rst
-rw-r--r-- 1 lilian lilian 2,5K avril 12 2021 ./ace2.rst
-rw-r--r-- 1 lilian lilian 8,8K avril 12 2021 ./A953.rst
-rw-r--r-- 1 lilian lilian 12K avril 12 2021 ./beacon.en.rst
-rw-r--r-- 1 lilian lilian 8,6K avril 12 2021 ./avoir.rst
-rw-r--r-- 1 lilian lilian 6,4K avril 12 2021 ./apprendre-python.fr.rst
-rw-r--r-- 1 lilian lilian 14K avril 12 2021 ./apk.fr.rst
-rw-r--r-- 1 lilian lilian 12K avril 12 2021 ./apk.en.rst
-rw-r--r-- 1 lilian lilian 2,2K avril 12 2021 ./blagues.fr.rst
-rw-r--r-- 1 lilian lilian 3,8K avril 12 2021 ./bitbucket-features.fr.rst
-rw-r--r-- 1 lilian lilian 3,7K avril 12 2021 ./bitbucket-features.en.rst
-rw-r--r-- 1 lilian lilian 15K avril 12 2021 ./bin.fr.rst
-rw-r--r-- 1 lilian lilian 15K avril 12 2021 ./bin.en.rst
-rw-r--r-- 1 lilian lilian 11K avril 12 2021 ./beacon.fr.rst
-rw-r--r-- 1 lilian lilian 18K avril 12 2021 ./blog-roll.fr.rst
-rw-r--r-- 1 lilian lilian 18K avril 12 2021 ./blog-roll.en.rst
-rw-r--r-- 1 lilian lilian 23K avril 12 2021 ./cv.en.rst
-rw-r--r-- 1 lilian lilian 4,3K avril 12 2021 ./cookies.fr.rst
-rw-r--r-- 1 lilian lilian 3,0K avril 12 2021 ./cookies.en.rst
-rw-r--r-- 1 lilian lilian 19K avril 12 2021 ./conseils-visio.en.rst
-rw-r--r-- 1 lilian lilian 24K avril 12 2021 ./conseils-email.en.rst
-rw-r--r-- 1 lilian lilian 4,0K avril 12 2021 ./ga.en.rst
-rw-r--r-- 1 lilian lilian 3,6K avril 12 2021 ./freedns.rst
-rw-r--r-- 1 lilian lilian 2,1K avril 12 2021 ./folders.rst
-rw-r--r-- 1 lilian lilian 21K avril 12 2021 ./firefox-extensions.fr.rst
-rw-r--r-- 1 lilian lilian 19K avril 12 2021 ./firefox-extensions.en.rst
-rw-r--r-- 1 lilian lilian 15K avril 12 2021 ./demo.rst
-rw-r--r-- 1 lilian lilian 3,9K avril 12 2021 ./data-analysis-of-2-years-of-sms-2016-2017.fr.rst
-rw-r--r-- 1 lilian lilian 3,5K avril 12 2021 ./data-analysis-of-2-years-of-sms-2016-2017.en.rst
-rw-r--r-- 1 lilian lilian 4,5K avril 12 2021 ./iteri.fr.rst
-rw-r--r-- 1 lilian lilian 4,8K avril 12 2021 ./iteri.en.rst
-rw-r--r-- 1 lilian lilian 9,7K avril 12 2021 ./graph.fr.rst
-rw-r--r-- 1 lilian lilian 9,5K avril 12 2021 ./graph.en.rst
-rw-r--r-- 1 lilian lilian 11K avril 12 2021 ./gnuplot.rst
-rw-r--r-- 1 lilian lilian 7,3K avril 12 2021 ./gnuplot_embed.rst
-rw-r--r-- 1 lilian lilian 4,0K avril 12 2021 ./ga.fr.rst
-rw-r--r-- 1 lilian lilian 684 avril 12 2021 ./my-favorite-tools.en.rst
-rw-r--r-- 1 lilian lilian 3,6K avril 12 2021 ./mount.fr.rst
-rw-r--r-- 1 lilian lilian 3,1K avril 12 2021 ./mount.en.rst
-rw-r--r-- 1 lilian lilian 5,0K avril 12 2021 ./mes-chansons-preferees.fr.rst
-rw-r--r-- 1 lilian lilian 5,1K avril 12 2021 ./matlab-clones.fr.rst
-rw-r--r-- 1 lilian lilian 4,6K avril 12 2021 ./matlab-clones.en.rst
-rw-r--r-- 1 lilian lilian 6,1K avril 12 2021 ./math.rst
-rw-r--r-- 1 lilian lilian 6,0K avril 12 2021 ./learn-python.en.rst
-rw-r--r-- 1 lilian lilian 3,0K avril 12 2021 ./latexonwindows.fr.rst
-rw-r--r-- 1 lilian lilian 3,0K avril 12 2021 ./latexonwindows.en.rst
-rw-r--r-- 1 lilian lilian 4,9K avril 12 2021 ./js.fr.rst
-rw-r--r-- 1 lilian lilian 4,5K avril 12 2021 ./js.en.rst
-rw-r--r-- 1 lilian lilian 1,3K avril 12 2021 ./jokes.en.rst
-rw-r--r-- 1 lilian lilian 6,8K avril 12 2021 ./jitsi.fr.rst
-rw-r--r-- 1 lilian lilian 6,2K avril 12 2021 ./jitsi.en.rst
-rw-r--r-- 1 lilian lilian 4,4K avril 12 2021 ./packing.en.rst
-rw-r--r-- 1 lilian lilian 8,4K avril 12 2021 ./opendns.fr.rst
-rw-r--r-- 1 lilian lilian 7,8K avril 12 2021 ./opendns.en.rst
-rw-r--r-- 1 lilian lilian 3,9K avril 12 2021 ./online-gnu-octave.fr.rst
-rw-r--r-- 1 lilian lilian 3,6K avril 12 2021 ./online-gnu-octave.en.rst
-rw-r--r-- 1 lilian lilian 23K avril 12 2021 ./old_apk.fr.rst
-rw-r--r-- 1 lilian lilian 21K avril 12 2021 ./old_apk.en.rst
-rw-r--r-- 1 lilian lilian 4,2K avril 12 2021 ./ocaml.fr.rst
-rw-r--r-- 1 lilian lilian 4,2K avril 12 2021 ./ocaml.en.rst
-rw-r--r-- 1 lilian lilian 5,7K avril 12 2021 ./ocaml_ace.rst
-rw-r--r-- 1 lilian lilian 16K avril 12 2021 ./NanoSyntax.rst
-rw-r--r-- 1 lilian lilian 14K avril 12 2021 ./recherche.fr.rst
-rw-r--r-- 1 lilian lilian 9,1K avril 12 2021 ./README.rst
-rw-r--r-- 1 lilian lilian 8,5K avril 12 2021 ./python.rst
-rw-r--r-- 1 lilian lilian 19K avril 12 2021 ./publis.fr.rst
-rw-r--r-- 1 lilian lilian 19K avril 12 2021 ./publis.en.rst
-rw-r--r-- 1 lilian lilian 1,3K avril 12 2021 ./plume-air-paris.fr.rst
-rw-r--r-- 1 lilian lilian 1,2K avril 12 2021 ./plume-air-paris.en.rst
-rw-r--r-- 1 lilian lilian 7,6K avril 12 2021 ./pgp.fr.rst
-rw-r--r-- 1 lilian lilian 4,7K avril 12 2021 ./pgp.en.rst
-rw-r--r-- 1 lilian lilian 12K avril 12 2021 ./pair-programming-tools.fr.rst
-rw-r--r-- 1 lilian lilian 3,4K avril 12 2021 ./pair-programming-tools.en.rst
-rw-r--r-- 1 lilian lilian 6,7K avril 12 2021 ./runblock.en.rst
-rw-r--r-- 1 lilian lilian 133K avril 12 2021 ./rules-and-principles.en.rst
-rw-r--r-- 1 lilian lilian 1,6K avril 12 2021 ./rss.rst
-rw-r--r-- 1 lilian lilian 12K avril 12 2021 ./resume-de-mon-annee-2019.rst
-rw-r--r-- 1 lilian lilian 16K avril 12 2021 ./resume-de-mon-annee-2018.rst
-rw-r--r-- 1 lilian lilian 11K avril 12 2021 ./resume-de-mon-annee-2017.rst
-rw-r--r-- 1 lilian lilian 13K avril 12 2021 ./research.en.rst
-rw-r--r-- 1 lilian lilian 5,4K avril 12 2021 ./star-wars.fr.rst
-rw-r--r-- 1 lilian lilian 6,1K avril 12 2021 ./star-wars.en.rst
-rw-r--r-- 1 lilian lilian 3,5K avril 12 2021 ./sphinxtabs.fr.rst
-rw-r--r-- 1 lilian lilian 3,3K avril 12 2021 ./sphinxtabs.en.rst
-rw-r--r-- 1 lilian lilian 23K avril 12 2021 ./slides.rst
-rw-r--r-- 1 lilian lilian 12K avril 12 2021 ./skulpt.rst
-rw-r--r-- 1 lilian lilian 562 avril 12 2021 ./sitemap.fr.rst
-rw-r--r-- 1 lilian lilian 512 avril 12 2021 ./sitemap.en.rst
-rw-r--r-- 1 lilian lilian 908 avril 12 2021 ./self-quantified.fr.rst
-rw-r--r-- 1 lilian lilian 16K avril 12 2021 ./self-quantified.en.rst
-rw-r--r-- 1 lilian lilian 6,9K avril 12 2021 ./runblock.fr.rst
-rw-r--r-- 1 lilian lilian 1,7K avril 12 2021 ./todo.rst
-rw-r--r-- 1 lilian lilian 2,7K avril 12 2021 ./time.rst
-rw-r--r-- 1 lilian lilian 32K avril 12 2021 ./sublimetext.fr.rst
-rw-r--r-- 1 lilian lilian 29K avril 12 2021 ./sublimetext.en.rst
-rw-r--r-- 1 lilian lilian 8,1K avril 12 2021 ./stats-google-analytics.fr.rst
-rw-r--r-- 1 lilian lilian 8,6K avril 12 2021 ./stats-google-analytics.en.rst
-rw-r--r-- 1 lilian lilian 26K avril 12 2021 ./tutogit.fr.rst
-rw-r--r-- 1 lilian lilian 25K avril 12 2021 ./tutogit.en.rst
-rw-r--r-- 1 lilian lilian 6,0K avril 12 2021 ./try-ocaml.fr.rst
-rw-r--r-- 1 lilian lilian 6,0K avril 12 2021 ./try-ocaml.en.rst
-rw-r--r-- 1 lilian lilian 9,3K avril 12 2021 ./transifex.fr.rst
-rw-r--r-- 1 lilian lilian 8,0K avril 12 2021 ./transifex.en.rst
-rw-r--r-- 1 lilian lilian 9,8K avril 12 2021 ./trademarks.rst
-rw-r--r-- 1 lilian lilian 19K avril 12 2021 ./top10.fr.rst
-rw-r--r-- 1 lilian lilian 25K avril 12 2021 ./wakatime.fr.rst
-rw-r--r-- 1 lilian lilian 24K avril 12 2021 ./wakatime.en.rst
-rw-r--r-- 1 lilian lilian 7,8K avril 12 2021 ./vpn.fr.rst
-rw-r--r-- 1 lilian lilian 23K avril 12 2021 ./visualstudiocode.fr.rst
-rw-r--r-- 1 lilian lilian 20K avril 12 2021 ./visualstudiocode.en.rst
-rw-r--r-- 1 lilian lilian 2,7K avril 12 2021 ./zotero.fr.rst
-rw-r--r-- 1 lilian lilian 2,6K avril 12 2021 ./zotero.en.rst
-rw-r--r-- 1 lilian lilian 8,9K avril 12 2021 ./wolfram.fr.rst
-rw-r--r-- 1 lilian lilian 8,9K avril 12 2021 ./wolfram.en.rst
-rw-r--r-- 1 lilian lilian 3,8K avril 12 2021 ./whatsnew.fr.rst
-rw-r--r-- 1 lilian lilian 3,7K avril 12 2021 ./whatsnew.en.rst
lrwxrwxrwx 1 lilian lilian 19 avril 12 2021 ./teaching.fr.rst -> enseignement.fr.rst
lrwxrwxrwx 1 lilian lilian 16 avril 12 2021 ./research.fr.rst -> recherche.fr.rst
lrwxrwxrwx 1 lilian lilian 15 avril 12 2021 ./recherche.en.rst -> research.en.rst
lrwxrwxrwx 1 lilian lilian 22 avril 12 2021 ./packing.fr.rst -> affaires-voyage.fr.rst
lrwxrwxrwx 1 lilian lilian 26 avril 12 2021 ./my-favorite-tools.fr.rst -> mes-outils-preferes.fr.rst
lrwxrwxrwx 1 lilian lilian 24 avril 12 2021 ./mes-outils-preferes.en.rst -> my-favorite-tools.en.rst
lrwxrwxrwx 1 lilian lilian 23 avril 12 2021 ./learn-python.fr.rst -> apprendre-python.fr.rst
lrwxrwxrwx 1 lilian lilian 14 avril 12 2021 ./jokes.fr.rst -> blagues.fr.rst
lrwxrwxrwx 1 lilian lilian 15 avril 12 2021 ./hitch-hiking.fr.rst -> autostop.fr.rst
lrwxrwxrwx 1 lilian lilian 15 avril 12 2021 ./enseignement.en.rst -> teaching.en.rst
lrwxrwxrwx 1 lilian lilian 30 avril 12 2021 ./ce-que-je-regarde-sur-youtube.en.rst -> what-i-watch-on-youtube.en.rst
lrwxrwxrwx 1 lilian lilian 12 avril 12 2021 ./blagues.en.rst -> jokes.en.rst
lrwxrwxrwx 1 lilian lilian 19 avril 12 2021 ./autostop.en.rst -> hitch-hiking.en.rst
lrwxrwxrwx 1 lilian lilian 19 avril 12 2021 ./apprendre-python.en.rst -> learn-python.en.rst
lrwxrwxrwx 1 lilian lilian 14 avril 12 2021 ./affaires-voyage.en.rst -> packing.en.rst
lrwxrwxrwx 1 lilian lilian 36 avril 12 2021 ./what-i-watch-on-youtube.fr.rst -> ce-que-je-regarde-sur-youtube.fr.rst
-rw-r--r-- 1 lilian lilian 21K avril 13 2021 ./teaching.en.rst
-rw-r--r-- 1 lilian lilian 5,0K avril 13 2021 ./coronavirus.en.rst
-rw-r--r-- 1 lilian lilian 61K avril 13 2021 ./top10.en.rst
-rw-r--r-- 1 lilian lilian 2,2K avril 14 2021 ./twitch.en.rst
-rw-r--r-- 1 lilian lilian 9,2K avril 14 2021 ./pokemon.en.rst
-rw-r--r-- 1 lilian lilian 8,6K avril 14 2021 ./pokemon.fr.rst
-rw-r--r-- 1 lilian lilian 3,1K avril 14 2021 ./twitch.fr.rst
-rw-r--r-- 1 lilian lilian 16K avril 18 2021 ./journal-de-bord-pendant-confinement-coronavirus-2020.fr.rst
-rw-r--r-- 1 lilian lilian 23K mai 6 2021 ./coronavirus.fr.rst
-rw-r--r-- 1 lilian lilian 9,2K nov. 23 2022 ./hitch-hiking.en.rst
-rw-r--r-- 1 lilian lilian 11K nov. 23 2022 ./autostop.fr.rst
-rw-r--r-- 1 lilian lilian 26K févr. 21 2023 ./cv.fr.rst
-rw-r--r-- 1 lilian lilian 27K févr. 21 2023 ./conseils-email.fr.rst
-rw-r--r-- 1 lilian lilian 11K févr. 21 2023 ./vieprivee.rst
-rw-r--r-- 1 lilian lilian 21K févr. 21 2023 ./conseils-visio.fr.rst
-rw-r--r-- 1 lilian lilian 32K févr. 21 2023 ./a-faire-avant-30-ans.rst
-rw-r--r-- 1 lilian lilian 7,4K févr. 28 2023 ./resume-de-mon-annee-2022.rst
-rw-r--r-- 1 lilian lilian 38K mai 30 2023 ./what-i-watch-on-youtube.en.rst
-rw-r--r-- 1 lilian lilian 39K mai 30 2023 ./ce-que-je-regarde-sur-youtube.fr.rst
-rw-r--r-- 1 lilian lilian 6,9K août 26 23:21 ./callme.fr.rst
-rw-r--r-- 1 lilian lilian 6,5K août 26 23:23 ./callme.en.rst
-rw-r--r-- 1 lilian lilian 14K août 29 13:00 ./index.en.rst
-rw-r--r-- 1 lilian lilian 21K oct. 11 12:31 ./enseignement.fr.rst
-rw-r--r-- 1 lilian lilian 30K oct. 11 12:35 ./mes-outils-preferes.fr.rst
-rw-r--r-- 1 lilian lilian 16K oct. 11 17:08 ./resume-de-mon-annee-2020.rst
-rw-r--r-- 1 lilian lilian 19K oct. 11 17:13 ./resume-de-mon-annee-2021.rst
-rw-r--r-- 1 lilian lilian 11K févr. 17 13:01 ./resume-de-mon-annee-2023.rst
-rw-r--r-- 1 lilian lilian 6,0K févr. 17 13:09 ./resume-de-mon-annee-2024.rst
-rw-r--r-- 1 lilian lilian 14K févr. 17 13:11 ./index.fr.rst
We can look for the 10 longest filenames of the reStructuredText files in the current directory:
$ for i in $(find -iname '*'.rst | sort); do echo "${#i} : $i" | sed s/'^\([0-9]\) '/'0\1 '/; done | sort | tail | awk '{ print $3 }'
./pair-programming-tools.fr.rst
./stats-google-analytics.en.rst
./stats-google-analytics.fr.rst
./what-i-watch-on-youtube.en.rst
./what-i-watch-on-youtube.fr.rst
./ce-que-je-regarde-sur-youtube.en.rst
./ce-que-je-regarde-sur-youtube.fr.rst
./data-analysis-of-2-years-of-sms-2016-2017.en.rst
./data-analysis-of-2-years-of-sms-2016-2017.fr.rst
./journal-de-bord-pendant-confinement-coronavirus-2020.fr.rst
We can also ask GPG to produce (on the fly) a signature of the current file (for more information about GPG, see pgp.html):
$ gpg --quiet -o - --armor --detach-sign runblock.en.rst
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEE/DSleRq5aEZtX0W7LaPXUOHniXEFAmXQox8ACgkQLaPXUOHn
iXFfmA/+IvjR9MelXySyTW0xgZS5XT8tPT0CW5JV5lczbTg94YkDW4t1c/PXybSY
Hh3B/A3B8tUs53m0aykJlxUr690hG5nrbYlrlaTHlq8kFBsC2TEPTYbBGbwkJVhY
7CwbtPcuc/atU5CNU56qcsIpgUTaLneUKgMIr5MYDHt78OdyvmwiNPD6lh6/Ru1h
KdyCbgBtwda3aThArfSYnFdT48pYfBEbOufhXMUkQ/jNuZ6xfl71PcpSfGMbpJGk
f9GVcxQz5/49wdVP/y2y/epkQLbYhRgqKIFlV4IhKFcaJPoaY8FBeuZl7vLPwpaL
czbVz6tv6qwXgF/X5wrFRx0Cqk4Sq63Cyo1MxOOkxOvdK5zZMNoKouvFPKSz8bHc
uTiUXFSk/YIs3TA2QWIsb0GfRbQxHsqi8GWLDjdMKEfvSFPbZUVcf2yCqYHb1kBS
UW721c7zpdnAGmQUex8pVVjZp36/77/igNtY5ipp7owL33QgAPxupp14YjBxynKW
mj/L0tM5ntHpxen5vBmtQzB3hjfM29iBN7cDBWRez1ckAB7zU/RC9yAY9H16lFwr
cVf9yfzJcg1n5hm6nc1ZJJqu/pXsrBAgRDHgEdnKiE7febh53zLCgoFnagEBd+zS
e9AJwwDyV6DqR/4UBCJDtGP0N5vILduiMHadQJTZWxkAE4JWsp8=
=Jq3q
-----END PGP SIGNATURE-----
Other examples¶
figlet can print text in a nice « ASCII art » form:
$ figlet "Isn't it pretty ?"
___ _ _ _ _ _ _ ___
|_ _|___ _ __ ( ) |_ (_) |_ _ __ _ __ ___| |_| |_ _ _ |__ \
| |/ __| '_ \|/| __| | | __| | '_ \| '__/ _ \ __| __| | | | / /
| |\__ \ | | | | |_ | | |_ | |_) | | | __/ |_| |_| |_| | |_|
|___|___/_| |_| \__| |_|\__| | .__/|_| \___|\__|\__|\__, | (_)
|_| |___/
My script bin/series.sh was conceived to automatically play the next episode for your current TV show, and it uses a ~/current file to know which folder to use. We can use it to display the TV show I am currently watching:
$ echo -e "These days, I am watching the TV show : $(basename "$(cat /home/lilian/current | tr _ ' ')") :)"
These days, I am watching the TV show : The Dragon Prince :)
Current state of the git repository (shows which files are new (N), modified (M) or deleted (D)) :
$ git status --porcelain
A stupid example with an elk:
$ cowthink -W 160 -f /usr/share/cowsay/cows/moose.cow "And you think this is funny?"
______________________________
( And you think this is funny? )
------------------------------
o
o \_\_ _/_/
o \__/
(oo)\_______
(__)\ )\/\
||----w |
|| ||
We can go crazy, and try to display a picture in ASCII text :
$ convert ~/.link.ico jpg:- | jp2a -b - --size=31x20
+-------------------------------+
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMWNNNNNNNNWMMMMMMMMMMM|
|MMMMMMMMMNk'.......ONNWMMMMMMMM|
|MMMMMMMWNc.;::;cxl;'..xWMMMMMMM|
|MMMMMWKl.';;lkkxc,'oxd;'dXXNMMM|
|MMMMNd.'::;.'::;.c0Ox:. .lWMM|
|MMMN;.::c..dl .xOko, ....xNMMM|
|MMMWd,;:c..kkc. ;;'. .okkKWMMMM|
|MMMMMX:';..x00, .l0..Oc..'XMMMM|
|MMMMMMW0: .dO0,.k00,,kkkc'KMMMM|
|MMMMMMMMW: ,ck'.xkkxo;;;dNWMMMM|
|MMMMMMMMW; ..,. ,;;;' lMMMMMMMM|
|MMMMMMW0d,.:' .,,. .. lMMMMMMMM|
|MMMMMMWl 'cc' l0Kc :: lMMMMMMMM|
|MMMMMMMo .,,. ;oo, ll lMMMMMMMM|
|MMMMMMMO:. ',,,,,. .. lMMMMMMMM|
|MMMMMMNko. ;ccccc' ;ONMMMMMM|
|MMMMMMNdcllodddxxxkOO0KKNMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
+-------------------------------+
The same, even bigger (fyi, this image is the favicon of this website):
$ convert ~/.link.ico jpg:- | jp2a -b - --size=62x30
+--------------------------------------------------------------+
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMWXKKKKKKKKKKKKKKKNMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMWNO;...............xMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMWKoc:'........';;,'.'cdddddOWMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMN0Ox:...;cclooooodxkxc,,,'...':xO0XWMMMMMMMMMMMM|
|MMMMMMMMMMMMWXl. .;cccclx00000klc;. c0000Ko. :KWWMWWMMMMMMM|
|MMMMMMMMMMWOc,'''',:c:'.'cdddddc'.':lok00kdd: .:ccc:c0MMMMMM|
|MMMMMMMMWKx;..'ccc:;;,...,;;;;;'..'xK00OOo;;' ..dWMMMMM|
|MMMMMMMNd..':;:ccc,. .lkx; ,dkO000xll, :0XNMMMMMM|
|MMMMMMMXc. 'cccccc' .dKOc''. .ldo:;,'... ;xkkkkkkKWMMMMMMMM|
|MMMMMMMMWOc;,,:ccc' .dK0xdo, .',,,'. .';lddddxOXWMMMMMMMMM|
|MMMMMMMMMMW0:.'ccc' .dK0000: .dKO; ;O0d. .:KMMMMMMMMM|
|MMMMMMMMMMMMNkc;,.. .dK0000c .cloOKO; ;O0koll:. 'OMMMMMMMMM|
|MMMMMMMMMMMMMMNKk;. .oOkO00c ,kK000Oc..:xkkkxkd;.,OMMMMMMMMM|
|MMMMMMMMMMMMMMMMMWd. .;c:dO0: 'x00OO0Okkoc:;...,xXXWMMMMMMMMM|
|MMMMMMMMMMMMMMMMMWd. ..;ol, .:ooooooll,..,x000NMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMNo. ....,,. ',,,,,,,,. '0MMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMWWWNo. .,c:. '0MMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMWx,,''',;:c:. 'oodddc. .,,. '0MMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMWl .;cccc:. ;00K00x' ;xd; 'OMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMo. .,::::;. ;kOOOOd. :OO: 'OMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMo ... .. ....... ,ol, .OMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMWk;;;. .'''''''''',. .,,. 'OWMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMWNKOOOc. .cxdddddddddxl. .kXNWMMMMMMMMMMMMM|
|MMMMMMMMMMMMWO;.... ........'''''.'',,,;;:codkKWMMMMMMMMMMMM|
|MMMMMMMMMMMMMNkoddxxkkkO000000KKKKXXXNNNNWWWMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
|MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM|
+--------------------------------------------------------------+
A few statistics about this git repository:
$ echo "Number of commits per author (on this git repository) :"
$ git --no-pager shortlog -sn --all
Number of commits per author (on this git repository) :
2155 Lilian Besson
5 Lilian Besson (Naereen)
1 Jill-Jênn Vie
A small calendar, showing in ASCII the active days in this git repository (with this other script, note that this web-page is a nice looking version of this ASCII « calendar »):
$ git-cal --ascii
Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Jan Feb
o
M O .
o . . .
W .
F o
. .
Less . o O 0 More
16: Total commits
2: Days ( Feb 27 2023 - Feb 28 2023 ) - Longest streak excluding weekends
2: Days ( Feb 27 2023 - Feb 28 2023 ) - Longest streak including weekends
1: Days ( Feb 17 2024 - Feb 17 2024 ) - Current streak
Adding support for another language: OCaml?¶
In the Sphinx configuration file, conf.py, we can easily add shortcuts to use this runblock extension with other languages.
First, we have to create an empty dictionary called autorun_languages
:
autorun_languages = {}
Then, add a value truc
(which has to be a valid command-line program, like gnuplot or ocaml)
and truc_prefix_chars
(size of the prefix)
to enable a new directive .. code-block:: truc
in all your reStructuredText document (in this project only):
# Add these two lines in your 'conf.py' file
autorun_languages['ocaml'] = u'ocaml -stdin'
autorun_languages['ocaml_prefix_chars'] = 2
autorun_languages['ocaml_input_language'] = 'utf_8'
autorun_languages['ocaml_output_language'] = 'utf_8'
.. runblock:: ocaml
now works¶
With this trick, we can now include example of code snippet in OCaml:
# let rec f = function 0 -> 1 | n -> n *(f (n-1)) in
# print_int (f 11);;
# Printf.printf "\n OCaml version %s\n" Sys.ocaml_version;;
39916800
OCaml version 4.14.1
Pour plus de détails, cf. le code source de l’extension autorun.py.
A weird bug of pygments
¶
This runblock
extension uses the great pygments Python library to color the code.
Sometimes, I have seen the pygments
or pygmentize
command-line tool break completely,
and the only bugfix I found was to manually delete the « experimental » support of pkg_resources
in the pygments file plugin.py,
by manually forcing pkg_resources = None
(at line 41).
It’s durty, but it fixes my bug…