changeset 187:418846a2623c

Also link to exampled from the PDF properly
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 12 May 2026 21:07:42 +0200
parents 95754197f5b3
children 8e172ca6c944
files docs/conf.py docs/examples/algorithm-dinic.description docs/examples/algorithm-dinic.pseudocode docs/lexer-algpseudocode.rst
diffstat 4 files changed, 52 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/docs/conf.py	Tue May 12 20:22:47 2026 +0200
+++ b/docs/conf.py	Tue May 12 21:07:42 2026 +0200
@@ -157,7 +157,11 @@
     ("_latex/index-latex", "PygmentsPseudocodeLexer.tex", "The Pygments Pseudocode Lexer", "Franz Glasner", "manual", True),
 ]
 latex_additional_files = [
-    "_latex/my-doc-fonts.sty"
+    "_latex/my-doc-fonts.sty",
+    "examples/example-1.pseudocode",         # linked via \url{}
+    "examples/algorithm-dinic.pseudocode",
+    "examples/algorithm-ford-fulkerson.pseudocode",
+    "examples/algorithm-edmonds-karp.pseudocode",
 ]
 
 def setup(app):
--- a/docs/examples/algorithm-dinic.description	Tue May 12 20:22:47 2026 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-// -*- coding: utf-8; indent-tabs-mode: nil -*-
-\ALGORITHM{Dinic's Algorithm} \WITH
-  \INPUT{A network \expr{G = ((V , E), c, s, t)}.}
-  \OUTPUT{An \expr{s–t} flow \expr{f} of maximum value.}
-\IS
-  \TEXT{1. Set \expr{f(e) = 0} for each \expr{e ∈ E}.
-  2. Construct \expr{G_L} from \expr{G_f} of \expr{G}.
-     If \expr{\text{dist}(t) = ∞}, stop and output \expr{f}.
-  3. Find a blocking flow \expr{f\'} in \expr{G_L}.
-  4. Augment flow \expr{f} by \expr{f\'} and go back to step 2.}
-\END ALGORITHM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/examples/algorithm-dinic.pseudocode	Tue May 12 21:07:42 2026 +0200
@@ -0,0 +1,11 @@
+// -*- coding: utf-8; indent-tabs-mode: nil -*-
+\ALGORITHM{Dinic's Algorithm} \WITH
+  \INPUT{A network \expr{G = ((V , E), c, s, t)}.}
+  \OUTPUT{An \expr{s–t} flow \expr{f} of maximum value.}
+\IS
+  \TEXT{1. Set \expr{f(e) = 0} for each \expr{e ∈ E}.
+  2. Construct \expr{G_L} from \expr{G_f} of \expr{G}.
+     If \expr{\text{dist}(t) = ∞}, stop and output \expr{f}.
+  3. Find a blocking flow \expr{f\'} in \expr{G_L}.
+  4. Augment flow \expr{f} by \expr{f\'} and go back to step 2.}
+\END ALGORITHM
--- a/docs/lexer-algpseudocode.rst	Tue May 12 20:22:47 2026 +0200
+++ b/docs/lexer-algpseudocode.rst	Tue May 12 21:07:42 2026 +0200
@@ -540,8 +540,15 @@
 Some Examples
 =============
 
-A synthetic example with many features
-(its source code is in :download:`examples/example-1.pseudocode`):
+A synthetic example with many features.
+
+.. only:: builder_html
+
+   Its source code is in :download:`examples/example-1.pseudocode`.
+
+.. raw:: latex
+
+   Its source code can be found at \url{example-1.pseudocode}.
 
 .. literalinclude:: examples/example-1.pseudocode
    :language: algpseudocode
@@ -556,15 +563,30 @@
 
 The second example is Wikipedia's description of *Dinic's Algorithm*
 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm).
-Its source code is in :download:`examples/algorithm-dinic.description`:
+
+.. only:: builder_html
+
+   Its source code is in :download:`examples/algorithm-dinic.pseudocode`.
 
-.. literalinclude:: examples/algorithm-dinic.description
+.. raw:: latex
+
+   Its source code can be found at \url{algorithm-dinic.pseudocode}
+
+.. literalinclude:: examples/algorithm-dinic.pseudocode
    :language: algpseudocode
    :lines: 2-
 
 The third example is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm*
 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm).
-Its source code is in :download:`examples/algorithm-ford-fulkerson.pseudocode`:
+
+.. only:: builder_html
+
+   Its source code is in
+   :download:`examples/algorithm-ford-fulkerson.pseudocode`.
+
+.. raw:: latex
+
+   Its source code can be found at \url{algorithm-ford-fulkerson.pseudocode}.
 
 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode
    :language: algpseudocode
@@ -573,7 +595,15 @@
 The fourth example is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm*
 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm)
 with a custom lexer that skip all ``ENDxxx`` keywords.
-Its source code is in :download:`examples/algorithm-edmonds-karp.pseudocode`:
+
+.. only:: builder_html
+
+   Its source code is in
+   :download:`examples/algorithm-edmonds-karp.pseudocode`.
+
+.. raw:: latex
+
+   Its source code can be found at \url{algorithm-edmonds-karp.pseudocode}.
 
 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
    :language: NoEndAlgPseudocode