# HG changeset patch # User Franz Glasner # Date 1778612862 -7200 # Node ID 418846a2623cafdf13cea6086379c38f7b017437 # Parent 95754197f5b3e65d94b8d49b77e5e8ee97bb6413 Also link to exampled from the PDF properly diff -r 95754197f5b3 -r 418846a2623c docs/conf.py --- 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): diff -r 95754197f5b3 -r 418846a2623c docs/examples/algorithm-dinic.description --- 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 diff -r 95754197f5b3 -r 418846a2623c docs/examples/algorithm-dinic.pseudocode --- /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 diff -r 95754197f5b3 -r 418846a2623c docs/lexer-algpseudocode.rst --- 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