Skip to content

Commit f0a7dd9

Browse files
author
doyougnu
committed
build: add tikz support
1 parent 59d2f42 commit f0a7dd9

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
99
BUILDDIR = _build
10+
LATEXOPTS = "-shell-escape"
1011

1112
# Put it first so that "make" without argument is like "make help".
1213
help:

conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
## underscore
4949
, 'sphinxcontrib.bibtex'
5050
, 'sphinx_copybutton'
51+
, 'sphinxcontrib.tikz'
5152
, 'sphinx_exec_directive'
5253
, 'conceptual_admonitions'
5354
]
@@ -57,6 +58,10 @@
5758
todo_link_only = False
5859
autosectionlabel_prefix_document = True
5960

61+
# tikz support
62+
tikz_proc_suite = "pdf2svg"
63+
tikz_tikzlibraries = "arrows, arrows.meta"
64+
6065
## global links in the book that share a prefix that we've named.
6166
extlinks = {'userGuide': ('https://downloads.haskell.org/~ghc/9.2.4/docs/html/users_guide/%s', '%s'),
6267
'ghcWiki': ('https://gitlab.haskell.org/ghc/ghc/wikis/%s', '#%s'),

flake.nix

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@
5252
};
5353
};
5454

55+
tex-overlay = final: prev: {
56+
tex-env = prev.texlive.combine {
57+
inherit (prev.texlive)
58+
scheme-basic collection-xetex fncychap titlesec tabulary varwidth
59+
framed capt-of wrapfig needspace dejavu-otf helvetic upquote
60+
memorygraphs;
61+
};
62+
};
63+
5564
in
5665
flake-utils.lib.eachDefaultSystem
5766
(system:
@@ -60,15 +69,9 @@
6069
overlays = [ press-theme-overlay
6170
copy-button-overlay
6271
sphinx-exec-directive-overlay
72+
tex-overlay
6373
];
6474
} ;
65-
66-
ourTexLive = pkgs.texlive.combine {
67-
inherit (pkgs.texlive)
68-
scheme-medium collection-xetex fncychap titlesec tabulary varwidth
69-
framed capt-of wrapfig needspace dejavu-otf helvetic upquote;
70-
};
71-
7275
## TODO use this
7376
fonts = pkgs.makeFontsConf { fontDirectories = [ pkgs.dejavu_fonts ]; };
7477

hoh.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ let
1212
# marked as broken in nixpkgs unfortunately
1313
# sphinx-book-theme
1414
## until we have a reason for tex leave this commented out for CI
15-
# ourTexLive
1615
];
1716
nonPythonInputs = with pkgs; [ sphinx-press-theme # this comes from the overlay
1817
sphinx-copybutton # this comes from the overlay
@@ -23,12 +22,14 @@ let
2322
ghc
2423
cabal-install
2524
git
25+
tex-env
2626
];
2727
in
2828
pkgs.stdenv.mkDerivation {
2929
pname = "hoh";
3030
version = "0.0.1";
3131
src = ./.;
32+
phases = [ "unpackPhase" "preBuild" "buildPhase" "installPhase"];
3233
buildInputs = pythonInputs ++ nonPythonInputs;
3334

3435
preBuild = ''
@@ -37,6 +38,7 @@ pkgs.stdenv.mkDerivation {
3738

3839
buildPhase = ''
3940
runHook preBuild
41+
export PATH="${pkgs.lib.makeBinPath (pythonInputs ++ nonPythonInputs)}:$PATH";
4042
SOURCE_DATE_EPOCH="$(${pkgs.coreutils}/bin/date '+%s')"
4143
make clean
4244
make ${target} SPHINXOPTS="-W"

src/glossary.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,24 @@ Glossary
6161

6262
Boxed : Levity
6363

64-
A Boxed value is a value that is represented by a pointer to the heap.
64+
A Boxed value is a value that is represented by a pointer to the heap. For
65+
example, a value such as ``1729 :: Int`` is represented as:
66+
67+
..
68+
.. tikz:: An Example TikZ Directive with Caption
69+
:align: left
70+
71+
\begin{tikzpicture}[memory graph]
72+
\node[arity=2] (hd) {Cons};
73+
\node
74+
[arity=2,below=of hd.arg 2 center,anchor=head north]
75+
(tl) {Cons};
76+
\draw[ref] (hd.arg 2 center)
77+
-- (tl.head north);
78+
\draw[ref] (tl.arg 2 center)
79+
|- ($(hd.head north)+(0,.4)$)
80+
-- (hd.head north);
81+
\end{tikzpicture}
6582
6683
Cardinality Analysis
6784

0 commit comments

Comments
 (0)