Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
annotate docs/intro.rst @ 151:4a8c122725b0
Move all the example files to "examples/"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 07 May 2026 16:12:15 +0200 |
| parents | 4acf578ae93f |
| children | 66d49e49b06b |
| rev | line source |
|---|---|
|
86
0c05dc09c9e2
Customize documentation index and prepare for a "Details" documentation page.
Franz Glasner <fzglas.hg@dom66.de>
parents:
45
diff
changeset
|
1 .. -*- coding: utf-8; indent-tabs-mode: nil; -*- |
|
0c05dc09c9e2
Customize documentation index and prepare for a "Details" documentation page.
Franz Glasner <fzglas.hg@dom66.de>
parents:
45
diff
changeset
|
2 |
|
45
6ac1ea5d2d4a
Begin documentation: add the Sphinx generated configuration as-is
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
3 |
|
140
e424fcdd472f
REFACTOR: Change the structure of the documentation: make the README the first page.
Franz Glasner <fzglas.hg@dom66.de>
parents:
138
diff
changeset
|
4 Introduction |
|
e424fcdd472f
REFACTOR: Change the structure of the documentation: make the README the first page.
Franz Glasner <fzglas.hg@dom66.de>
parents:
138
diff
changeset
|
5 ============ |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
6 |
|
141
acd9073cbbe3
Make a lexerlist.rst that contains the table of the lexers because it is used at least twice
Franz Glasner <fzglas.hg@dom66.de>
parents:
140
diff
changeset
|
7 The package contains the following lexers: |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
8 |
|
141
acd9073cbbe3
Make a lexerlist.rst that contains the table of the lexers because it is used at least twice
Franz Glasner <fzglas.hg@dom66.de>
parents:
140
diff
changeset
|
9 .. include:: lexerlist.rst |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
10 |
|
144
b616f9645e37
More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents:
141
diff
changeset
|
11 They may be used in `Sphinx`_ by their aliases: |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
12 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
13 .. code-block:: none |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
14 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
15 .. code-block:: algpseudocode |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
16 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
17 \PROGRAM {The Pseudoprogram} \IS |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
18 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
19 \END PROGRAM {The Pseudoprogram} |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
20 |
|
140
e424fcdd472f
REFACTOR: Change the structure of the documentation: make the README the first page.
Franz Glasner <fzglas.hg@dom66.de>
parents:
138
diff
changeset
|
21 It will be rendered as: |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
22 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
23 .. code-block:: algpseudocode |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
24 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
25 \PROGRAM {The Pseudoprogram} \IS |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
26 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
27 \END PROGRAM {The Pseudoprogram} |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
28 |
|
150
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
29 And the same with the german variant |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
30 (using ``.. code-block:: algpseudocode-de`` as language alias): |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
31 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
32 .. code-block:: algpseudocode-de |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
33 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
34 \PROGRAM {The Pseudoprogram} \IS |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
35 |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
36 \END PROGRAM {The Pseudoprogram} |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
37 |
|
150
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
38 A basic documentation for FrPseudocode you find on its |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
39 :ref:`detail page <fr-pseudocode>`. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
40 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
41 The AlgPseudocode lexer and its friends AlgPseudocodeDE and AlgPseudocodeFR |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
42 basically work in three states: `default`, `expression` and `text`. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
43 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
44 In expressions it automatically recognizes: |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
45 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
46 - Strings (single-quote, double-quote, triple-single-quote, |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
47 triple-double-quote, `Python`_ style) |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
48 - Numbers (also `Python`_ style) |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
49 - (Mathematical) operators and symbols |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
50 - ``\TEXT{...}`` |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
51 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
52 To switch in a text-mode that prohibits automatic expression |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
53 highlighting. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
54 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
55 A closing curly brace can be quoted with ``\}`` to not end the |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
56 text mode prematurely. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
57 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
58 - ``\NAME``, ``\CALL`` and ``\GETS`` |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
59 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
60 - ``\REM`` and ``\REMARK`` for remarks (aka comments) |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
61 |
|
150
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
62 - Names (`Name.Entity`) |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
63 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
64 - :ref:`explicit-token-types` |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
65 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
66 In the default-mode it recogzizes expressions and additionally all |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
67 sorts of comments and commands that are inspired by CTAN's |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
68 `Algpseudocodex`_. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
69 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
70 In texts it recogzizes: |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
71 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
72 - ``\EXPR`` or ``\EXPRESSION`` |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
73 |
|
150
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
74 To switch to expression-mode. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
75 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
76 A closing curly brace can be quoted with ``\}`` to not end the expression |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
77 mode prematurely. |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
78 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
79 - ``\REM`` and ``\REMARK`` for remarks (aka comments) |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
80 |
|
150
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
81 - :ref:`explicit-token-types` |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
82 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
83 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
84 .. rubric:: Some Examples |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
85 |
|
4acf578ae93f
Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents:
147
diff
changeset
|
86 A synthetic example with most features: |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
87 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
88 .. literalinclude:: examples/example-1.pseudocode |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
89 :language: algpseudocode |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
90 :lines: 2- |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
91 |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
92 With a customized `AlgPseudocodeLexer` and its `no_end` |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
93 option set to ``True``. |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
94 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
95 .. literalinclude:: examples/example-1.pseudocode |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
96 :language: NoEndAlgPseudocode |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
97 :lines: 2- |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
98 |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
99 This is Wikipedia's description of *Dinic's Algorithm* |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
100 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm): |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
101 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
102 .. literalinclude:: examples/algorithm-dinic.description |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
103 :language: algpseudocode |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
104 :lines: 2- |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
105 |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
106 This is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm* |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
107 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm): |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
108 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
109 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
110 :language: algpseudocode |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
111 :lines: 2- |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
112 |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
113 This is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm* |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
114 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm): |
|
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
115 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
116 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
117 :language: NoEndAlgPseudocode |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
118 :lines: 2- |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
119 |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
120 And now the *Edmonds–Karp Algorithm* with french keywords: |
|
107
1c1985532139
A couple of real pseudocode examples.
Franz Glasner <fzglas.hg@dom66.de>
parents:
86
diff
changeset
|
121 |
|
151
4a8c122725b0
Move all the example files to "examples/"
Franz Glasner <fzglas.hg@dom66.de>
parents:
150
diff
changeset
|
122 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode |
|
125
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
123 :language: algpseudocode-fr |
|
3629bf09b30d
Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents:
107
diff
changeset
|
124 :lines: 2- |
