Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
"""Test Html Renderer.
 
The commands are not run, so what a command wrote stands in for itself. What is checked is the page that comes out, since where a
linefeed goes is what makes one build of the documentation comparable with the next."""
 
####################################################################################################################################
import os
import struct
import tempfile
 
from harness.test import *
 
from common.error import *
from common.storage import file_read, file_write, path_list
from common.var_store import VarStore
from common.xml import xml_node_attribute, xml_parse
from command.render.execute import CacheInvalidError
from command.render.html import DocHtmlPage, HtmlBuilder, HtmlElement, _resource_version, html_render
from command.render.manifest import RENDER_HTML, Manifest
 
MANIFEST = """<doc>
    <variable-list>
        <variable key="project">pgBackRest</variable>
        <variable key="project-exe">pgbackrest</variable>
        <variable key="project-url-root">/</variable>
        <variable key="html-footer">Footer.</variable>
    </variable-list>
 
    <source-list>
        <source key="index"/>
        <source key="user-guide"/>
    </source-list>
 
    <render-list>
        <render type="html">
            <render-source key="index" menu="Home"/>
            <render-source key="user-guide" menu="Guide"/>
        </render>
    </render-list>
</doc>
"""
 
USER_GUIDE = """<doc title="User Guide" subtitle="Reliable">
    <description>How to use it.</description>
 
    <section id="start">
        <title>Start</title>
 
        <text><p>An introduction.</p></text>
 
        <p>A paragraph with <id>markup</id>.</p>
 
        <p html="n">Only in the markdown.</p>
 
        <admonition type="note">Careful.</admonition>
 
        <list>
            <list-item>One</list-item>
            <list-item>Two</list-item>
        </list>
 
        <code-block title="Example" type="bash">
            echo one
              echo two
        </code-block>
 
        <table>
            <title label="Table 1">Options</title>
 
            <table-header>
                <table-column fill="y">Name</table-column>
                <table-column align="right">Value</table-column>
            </table-header>
 
            <table-data>
                <table-row>
                    <table-cell>one</table-cell>
                    <table-cell>1</table-cell>
                </table-row>
            </table-data>
        </table>
 
        <execute-list host="repo">
            <title>Run it</title>
 
            <execute output="y">
                <exe-cmd>pgbackrest info</exe-cmd>
                <exe-highlight>suppressed</exe-highlight>
            </execute>
        </execute-list>
 
        <backrest-config host="repo" file="/etc/pgbackrest.conf">
            <title>Configure</title>
 
            <backrest-config-option section="global" key="repo1-path">/var/lib</backrest-config-option>
        </backrest-config>
 
        <postgres-config host="repo" file="/pg/postgresql.conf">
            <title>Configure PostgreSQL</title>
 
            <postgres-config-option key="archive_mode">on</postgres-config-option>
        </postgres-config>
 
        <section id="shown" toc-title="Shown">
            <title>Shown In Contents</title>
        </section>
 
        <section id="inner" toc="n">
            <title>Inner</title>
 
            <subtitle><text>A Subtitle</text></subtitle>
 
            <subsubtitle><text>A Subsubtitle</text></subsubtitle>
        </section>
    </section>
 
    <section id="side" aside="y">
        <title>Aside</title>
 
        <p>Down the side of the page.</p>
    </section>
 
    <section id="quiet" toc="n">
        <title>Quiet</title>
 
        <p>Not in the contents.</p>
    </section>
 
    <section id="bare" header="n">
        <title>Bare</title>
 
        <p>No header on the page.</p>
    </section>
 
    <section id="elsewhere" html="n">
        <title>Elsewhere</title>
 
        <p>Only in the markdown.</p>
    </section>
 
</doc>
"""
 
SIMPLE_GUIDE = """<doc title="User Guide">
    <description>How to use it.</description>
 
    <section id="start">
        <title>Start</title>
 
        <execute-list host="repo">
            <title>Run it</title>
 
            <execute output="y"><exe-cmd>pgbackrest info</exe-cmd></execute>
        </execute-list>
    </section>
</doc>
"""
 
INDEX = """<doc title="Index" toc="n">
    <description>The index.</description>
 
    <section id="about">
        <title>About</title>
 
        <sponsor-list>
            <sponsor url="https://one" img="one.png" width="100">One</sponsor>
            <sponsor url="https://two" img="two.png" img-dark="two-dark.png" width="50">Two</sponsor>
        </sponsor-list>
    </section>
</doc>
"""
 
 
####################################################################################################################################
class _Config:
    """The options a manifest reads."""
 
    def __init__(self, **kwargs):
        self.deploy = False
        self.cache_only = False
        self.pre = False
        self.require = []
        self.include = []
        self.exclude = []
        self.key_var_map = {}
 
        for name, value in kwargs.items():
            setattr(self, name, value)
 
 
####################################################################################################################################
def _doc_path(path, manifest=MANIFEST, user_guide=USER_GUIDE):
    """Write the documentation a page is rendered from."""
 
    file_write(os.path.join(path, "manifest.xml"), manifest)
    file_write(os.path.join(path, "xml/index.xml"), INDEX)
    file_write(os.path.join(path, "xml/user-guide.xml"), user_guide)
    file_write(os.path.join(path, "resource/html/default.css"), "body\n{\n    color: black; /* black */\n}\n")
    file_write(os.path.join(path, "resource/html/default.js"), "// what it is\nvar page = 1;\n")
    file_write(os.path.join(path, "resource/slogo.svg"), "<svg></svg>\n")
 
    return path
 
 
####################################################################################################################################
def _manifest(path, config=None):
    """Load the documentation."""
 
    return Manifest(path, VarStore(), {}, _Config() if config is None else config)
 
 
####################################################################################################################################
def _page(path, key="user-guide", config=None):
    """Render a page without running any of the commands it holds."""
 
    manifest = _manifest(path, config)
    render = manifest.render_get(RENDER_HTML)
 
    return manifest.var_store.replace_str(DocHtmlPage(manifest, key, render.menu, False, "style1", "script1").process())
 
 
####################################################################################################################################
def test_element():
    """A page is built as a tree of elements so the code that decides what it holds never deals with markup."""
 
    builder = HtmlBuilder("Name", "Title", None, None, None, None, "style1", "script1")
    body = builder.body
 
    body.add_new("div", "one", content="Content")
    body.add(HtmlElement("div", "two"))
 
    assert_in('<div class="one">\nContent\n', builder.render())
    assert_in('<div class="two"></div>', builder.render())
 
 
####################################################################################################################################
def test_builder():
    """A page says what it is."""
 
    builder = HtmlBuilder("pgBackRest", "Guide & More", "logo.svg", "card.png", (1200, 630), "How to use it.", "style1", "script1")
 
    result = builder.render(analytics=True)
 
    assert_in("<!DOCTYPE html PUBLIC", result)
    assert_in('<link rel="icon" href="logo.svg" type="image/svg+xml"></link>', result)
 
    # The card says where it is and what shape it is, so a preview can be laid out before the image has been fetched
    assert_in('<meta property="og:image" content="{[backrest-url-base]}/card.png"></meta>', result)
    assert_in('<meta property="og:image:width" content="1200"></meta>', result)
    assert_in('<meta property="og:image:height" content="630"></meta>', result)
    assert_in('<meta property="og:image:alt" content="pgBackRest"></meta>', result)
    assert_in('<meta name="twitter:card" content="summary_large_image"></meta>', result)
 
    assert_in('<meta name="description" content="How to use it."></meta>', result)
    assert_in('<link rel="stylesheet" href="default.css?v=style1" type="text/css"></link>', result)
    assert_in('<script src="default.js?v=script1" defer="defer"></script>', result)
    assert_in('<meta name="viewport" content="width=device-width, initial-scale=1"></meta>', result)
    assert_in("googletagmanager.com", result)
 
    # What cannot appear in an attribute is escaped
    assert_in("Guide &amp; More", result)
 
 
####################################################################################################################################
def test_page():
    """A page holds a header, a menu, a table of contents, and the sections of the document."""
 
    with tempfile.TemporaryDirectory() as path:
        page = _page(_doc_path(path))
 
        # The logo is a link home and holds the name for a reader who cannot see what it is drawn as
        assert_in('<a class="page-header-logo" href="/"><span class="page-header-logo-name">\npgBackRest\n', page)
 
        assert_in('<div class="page-header-title">\nUser Guide\n', page)
        assert_in('<div class="page-header-subtitle">\nReliable\n', page)
        assert_in("<title>", page)
 
        # The page a reader is on is in the menu with the rest, marked rather than linked
        assert_in('<a class="menu-link" href="/">\nHome\n', page)
        assert_in('<span class="menu-current">\nGuide\n', page)
 
        # A section is anchored so a link can point at it
        assert_in('<a id="start"></a>', page)
        assert_in('<a id="start/inner"></a>', page)
        assert_in('<div class="page-toc-title">\nTable of Contents\n', page)
 
        # A page with contents says so, since that is what puts them in a column beside the text
        assert_in('<body class="page-sidebar">', page)
 
        # A section can give the contents a shorter title than it gives the page
        assert_in('<div class="section2-title">\nShown In Contents\n', page)
        assert_in('<a href="#start/shown">\nShown\n', page)
 
        # A section that says it is not in the contents is still on the page
        assert_in('<a id="quiet"></a>', page)
        assert_not_in('href="#quiet"', page)
 
        # A section set aside says so and goes first, since the text can only run beside what is already there
        assert_in('<div class="section1 section-aside"><a id="side"></a>', page)
        assert_true(page.index('id="side"') < page.index('id="start"'))
 
        # What the document wrote after it says so, which is what puts the aside back in place when it cannot go down the side
        assert_in('<div class="section1 section-after-aside"><a id="quiet"></a>', page)
        assert_not_in('section-after-aside"><a id="start"', page)
 
        # A section that says it has no header keeps its anchor, its content, and its place in the contents
        assert_in('<a id="bare"></a>', page)
        assert_not_in('<div class="section1-title">\nBare\n', page)
        assert_in("No header on the page.", page)
        assert_in('href="#bare"', page)
 
        assert_in('<div class="page-footer">\nFooter.\n', page)
 
 
####################################################################################################################################
def test_page_content():
    """Everything a section can hold is rendered as what the page writes for it."""
 
    with tempfile.TemporaryDirectory() as path:
        page = _page(_doc_path(path))
 
        assert_in('<div class="section-intro">\nAn introduction.\n', page)
        assert_in('A paragraph with <span class="id">markup</span>.', page)
 
        # Something the document keeps for another way of rendering it is left out of this one, whether it is part of a section
        assert_not_in("Only in the markdown.", page)
        assert_not_in('id="elsewhere"', page)
        assert_in('<div class="note">\nNOTE:\n', page)
        assert_in('<li class="list-unordered">\nOne\n', page)
        assert_in('<div class="section2-subtitle">\nA Subtitle\n', page)
        assert_in('<div class="section2-subsubtitle">\nA Subsubtitle\n', page)
 
        # A code block is shown at the indent it was written at rather than at the indent it sits at in the xml
        assert_in('<pre class="code-block" tabindex="0">echo one\n  echo two</pre>', page)
 
        # A table says what it is and how each column is lined up
        assert_in('<caption class="table-caption">\nTable 1: Options\n', page)
        assert_in('<th class="table-header-left table-header-fill">', page)
        assert_in('<th class="table-header-right">', page)
        assert_in('<td class="table-data-right">', page)
 
 
####################################################################################################################################
def test_page_execute():
    """A command is shown with what it wrote, with the part the documentation is pointing at marked."""
 
    with tempfile.TemporaryDirectory() as path:
        page = _page(_doc_path(path))
 
        assert_in('<span class="host">repo</span> <b>&#x21d2;</b> Run it', page)
        assert_in(
            '<div class="execute-body-cmd">\n<pre class="execute-cmd" tabindex="0">pgbackrest info</pre>\n'
            '<button class="code-copy" type="button" title="Copy the command" aria-label="Copy the command"></button>',
            page,
        )
        assert_in(
            '<div class="execute-body-output" tabindex="0"><div class="execute-line-list">\n'
            '<pre class="execute-line-highlight">Output suppressed for testing</pre>',
            page,
        )
 
        # A configuration is shown as the file it leaves behind, a line at a time so each line can say what the change did to it
        assert_in('<span class="host">repo</span>:<span class="file">/etc/pgbackrest.conf</span>', page)
        assert_in('<div class="config-line-list">\n<pre class="config-line">Config suppressed for testing</pre>', page)
 
        # Laid out content is separated from what is around it
        assert_in('\n<pre class="execute-cmd" tabindex="0">', page)
 
 
####################################################################################################################################
def test_page_sponsor():
    """A sponsor is a link with a logo for a light page and a logo for a dark one."""
 
    with tempfile.TemporaryDirectory() as path:
        page = _page(_doc_path(path), "index")
 
        # The logo is not a link on the page it would link to, since the reader is already there
        assert_in('<div class="page-header-logo"><span class="page-header-logo-name">\npgBackRest\n', page)
 
        assert_in('<a href="https://one">', page)
        assert_in('<img class="sponsor-img sponsor-img-light" src="sponsor/one.png" alt="One" width="100">', page)
        assert_in('<img class="sponsor-img sponsor-img-dark" src="sponsor/one.png" alt="One" width="100">', page)
 
        # A sponsor with a logo of its own for a dark page
        assert_in('<img class="sponsor-img sponsor-img-dark" src="sponsor/two-dark.png" alt="Two" width="50">', page)
 
        # A page with no contents has no column beside the text to put them in
        assert_in("<body>", page)
        assert_not_in("page-sidebar", page)
 
 
####################################################################################################################################
def test_page_error():
    """A page that cannot be rendered as it is written is reported rather than rendered wrongly."""
 
    with tempfile.TemporaryDirectory() as path:
        # A page can only be sectioned so deep before the numbering runs out of styles
        deep = "<doc title='Deep'><description>D</description>%s%s</doc>" % (
            "".join("<section id='s%d'><title>S%d</title>" % (idx, idx) for idx in range(4)),
            "</section>" * 4,
        )
 
        with assert_raises(ToolError) as raised:
            _page(_doc_path(path, user_guide=deep))
 
        assert_equal(str(raised.exception), "section depth of 4 exceeds maximum")
 
 
####################################################################################################################################
def test_page_no_toc():
    """A document that says it has no table of contents has none, and no column beside the text to put one in."""
 
    with tempfile.TemporaryDirectory() as path:
        guide = "<doc title='G' toc='n'><description>D</description><section id='a'><title>A</title></section></doc>"
        page = _page(_doc_path(path, user_guide=guide))
 
        assert_not_in("page-toc", page)
        assert_not_in("page-sidebar", page)
 
 
####################################################################################################################################
def test_html_render():
    """Every page is rendered, along with everything that goes beside them."""
 
    with tempfile.TemporaryDirectory() as path:
        _doc_path(path)
 
        # Only the header of the card is needed, since that is all that is read of it, and a size of its own shows the page says
        # what the file measures rather than what the tool expects it to
        file_write(
            os.path.join(path, "resource/card.png"),
            b"\x89PNG\r\n\x1a\n" + struct.pack(">I", 13) + b"IHDR" + struct.pack(">II", 400, 200),
        )
        file_write(os.path.join(path, "resource/logo.svg"), "svg")
        file_write(os.path.join(path, "resource/sponsor/one.png"), "png")
 
        manifest = _manifest(path)
        manifest.var_store.add("project-card", "card.png")
        manifest.var_store.add("project-favicon", "logo.svg")
 
        path_out = os.path.join(path, "output/html")
 
        os.makedirs(path_out)
        html_render(manifest, path, path_out, False)
 
        assert_equal(
            sorted(path_list(path_out)),
            ["card.png", "default.css", "default.js", "index.html", "logo.svg", "slogo.svg", "sponsor", "user-guide.html"],
        )
        assert_equal(path_list(os.path.join(path_out, "sponsor")), ["one.png"])
 
        index = file_read(os.path.join(path_out, "index.html"))
 
        assert_in('<meta property="og:image:width" content="400"></meta>', index)
        assert_in('<meta property="og:image:height" content="200"></meta>', index)
 
        # The style and the script carry no comments, since the page carries them for a browser rather than for a reader, but
        # where their lines fall is left alone so one build can still be compared with the next
        assert_equal(file_read(os.path.join(path_out, "default.css")), "body\n{\n    color: black;\n}\n")
        assert_equal(file_read(os.path.join(path_out, "default.js")), "var page = 1;\n")
 
        # The links carry a version of the rendered content, so a comment changes neither
        assert_in('href="default.css?v=%s"' % _resource_version("body\n{\n    color: black;\n}\n"), index)
        assert_in('src="default.js?v=%s"' % _resource_version("var page = 1;\n"), index)
 
 
####################################################################################################################################
def test_html_render_cache_reset():
    """A cache that no longer describes a document is thrown away and the document built again."""
 
    import command.render.execute as execute_module
 
    execute_run_real = execute_module.DocExecute._execute_run
    execute_module.DocExecute._execute_run = lambda self, host_name, command, key, cmd: "ran for real"
 
    try:
        with tempfile.TemporaryDirectory() as path:
            _doc_path(path, user_guide=SIMPLE_GUIDE)
 
            manifest = _manifest(path)
 
            # A cache entry that does not describe the command the page is about to run
            manifest.source_map["user-guide"].cache_list = [{"key": {"host": "other"}, "type": "exe"}]
 
            path_out = os.path.join(path, "output/html")
 
            os.makedirs(path_out)
            html_render(manifest, path, path_out, True)
 
            # The cache was thrown away, so the page rendered from what the command wrote rather than from what was cached
            assert_is_not_none(manifest.source_map["user-guide"].cache_list)
            assert_in("ran for real", file_read(os.path.join(path_out, "user-guide.html")))
    finally:
        execute_module.DocExecute._execute_run = execute_run_real
 
 
####################################################################################################################################
def test_page_highlight_missing():
    """A command whose output does not hold what the documentation is pointing at is reported."""
 
    import command.render.execute as execute_module
 
    execute_run_real = execute_module.DocExecute._execute_run
    execute_module.DocExecute._execute_run = lambda self, host_name, command, key, cmd: "nothing of interest"
 
    try:
        with tempfile.TemporaryDirectory() as path:
            manifest = _manifest(_doc_path(path))
            render = manifest.render_get(RENDER_HTML)
 
            with assert_raises(ToolError) as raised:
                DocHtmlPage(manifest, "user-guide", render.menu, True, "style1", "script1").process()
 
            assert_equal(str(raised.exception), "unable to find a match for highlight: suppressed")
    finally:
        execute_module.DocExecute._execute_run = execute_run_real
 
 
# A manifest where one page is in the menu and the other is not, so the menu is built from what is in it
MANIFEST_MENU = MANIFEST.replace(' menu="Home"', "")
 
# A manifest where no page is in the menu, so there is no menu at all
MANIFEST_NO_MENU = MANIFEST_MENU.replace(' menu="Guide"', "")
 
# A document of the cases the main one does not hold
OTHER_GUIDE = """<doc title="User Guide">
    <description>How to use it.</description>
 
    <section id="start">
        <title>Start</title>
 
        <table>
            <table-data>
                <table-row>
                    <table-cell>one</table-cell>
                </table-row>
            </table-data>
        </table>
 
        <execute-list host="repo" show="n">
            <title>Hidden</title>
 
            <execute><exe-cmd>hidden</exe-cmd></execute>
        </execute-list>
 
        <execute-list host="repo">
            <title>Shown</title>
 
            <execute show="n"><exe-cmd>not shown</exe-cmd></execute>
 
            <execute><exe-cmd>no output</exe-cmd></execute>
 
            <execute output="y">
                <exe-cmd>pgbackrest info</exe-cmd>
                <exe-highlight-type>error</exe-highlight-type>
                <exe-highlight>suppressed</exe-highlight>
            </execute>
        </execute-list>
 
        <backrest-config host="repo" file="/etc/pgbackrest.conf" show="n">
            <title>Hidden</title>
 
            <backrest-config-option section="global" key="a">1</backrest-config-option>
        </backrest-config>
 
        <postgres-config host="repo" file="/pg/postgresql.conf" show="n">
            <title>Hidden</title>
 
            <postgres-config-option key="a">1</postgres-config-option>
        </postgres-config>
    </section>
</doc>
"""
 
 
####################################################################################################################################
def test_page_other():
    """The cases a page holds that the documentation does not use everywhere."""
 
    with tempfile.TemporaryDirectory() as path:
        manifest = _manifest(_doc_path(path, user_guide=OTHER_GUIDE))
 
        render = manifest.render_get(RENDER_HTML)
        page = DocHtmlPage(manifest, "user-guide", render.menu, False, "style1", "script1").process()
 
        # A table with no header lines every column up left
        assert_in('<td class="table-data-left">', page)
        assert_not_in("table-header-row", page)
 
        # A command list that is not shown, and a command of a list that is not shown
        assert_not_in("hidden", page)
        assert_not_in("not shown", page)
 
        # Output the documentation is pointing at as an error looks different from output it is pointing at
        assert_in('<pre class="execute-line-highlight-error">', page)
 
        # A configuration that is not shown
        assert_not_in("config-title", page)
 
 
####################################################################################################################################
def test_page_postgres_config():
    """Every line of a configuration says what the change did to it."""
 
    import command.render.execute as execute_module
 
    line_list = [("same", "archive_mode = on"), ("remove", "wal_level = minimal"), ("add", "wal_level = replica")]
 
    def postgres_config(self, section, config, depth):
        """Stand in for a configuration a section changed."""
 
        return xml_node_attribute(config, "file", True), line_list, True
 
    postgres_real = execute_module.DocExecute.postgres_config
    execute_module.DocExecute.postgres_config = postgres_config
 
    try:
        guide = """<doc title="G"><description>D</description><section id="a"><title>A</title>
            <postgres-config host="repo" file="/pg/x"><title>C</title></postgres-config>
        </section></doc>"""
 
        with tempfile.TemporaryDirectory() as path:
            manifest = _manifest(_doc_path(path, user_guide=guide))
            render = manifest.render_get(RENDER_HTML)
            page = DocHtmlPage(manifest, "user-guide", render.menu, False, "style1", "script1").process()
 
            # The title carries the button that hands over the file rather than the change to it, which the style draws
            assert_in('<div class="config-title"><button class="code-copy" type="button" title="Copy the configuration"', page)
 
            assert_in('<pre class="config-line">archive_mode = on</pre>', page)
            assert_in('<pre class="config-line-remove">wal_level = minimal</pre>', page)
            assert_in('<pre class="config-line-add">wal_level = replica</pre>', page)
    finally:
        execute_module.DocExecute.postgres_config = postgres_real
 
 
####################################################################################################################################
def test_html_render_plain():
    """A build with no card and no sponsors copies only the style."""
 
    with tempfile.TemporaryDirectory() as path:
        _doc_path(path)
 
        # The card is named but turned off, which is how the documentation that ships with the distribution is built
        manifest = _manifest(path)
        manifest.var_store.add("sponsor", "n")
        manifest.var_store.add("card", "n")
        manifest.var_store.add("project-card", "card.png")
 
        path_out = os.path.join(path, "output/html")
 
        os.makedirs(path_out)
        html_render(manifest, path, path_out, False)
 
        assert_equal(sorted(path_list(path_out)), ["default.css", "default.js", "index.html", "slogo.svg", "user-guide.html"])
 
 
####################################################################################################################################
def test_builder_plain():
    """A page that says nothing about itself beyond what it must."""
 
    result = HtmlBuilder("pgBackRest", "Guide", None, None, None, None, "style1", "script1").render()
 
    assert_not_in("og:image", result)
    assert_not_in('name="description"', result)
    assert_not_in('rel="icon"', result)
 
 
####################################################################################################################################
def test_page_menu():
    """A page that is not in the menu is not in it, however it is rendered."""
 
    with tempfile.TemporaryDirectory() as path:
        page = _page(_doc_path(path, MANIFEST_MENU))
 
        # The page being rendered is still marked, so the menu holds no links at all
        assert_not_in("menu-link", page)
        assert_in("menu-current", page)
 
    # A build where no page is in the menu has no menu at all
    with tempfile.TemporaryDirectory() as path:
        assert_not_in("page-menu", _page(_doc_path(path, MANIFEST_NO_MENU)))
 
 
####################################################################################################################################
def test_page_output_run():
    """Runs of output are grouped by whether the documentation is pointing at them, so a run is one block rather than one line."""
 
    import command.render.execute as execute_module
 
    execute_run_real = execute_module.DocExecute._execute_run
    execute_module.DocExecute._execute_run = lambda self, host_name, command, key, cmd: "before\nsuppressed here\nafter"
 
    try:
        with tempfile.TemporaryDirectory() as path:
            manifest = _manifest(
                _doc_path(
                    path,
                    user_guide=SIMPLE_GUIDE.replace(
                        '<execute output="y"><exe-cmd>pgbackrest info</exe-cmd></execute>',
                        '<execute output="y"><exe-cmd>pgbackrest info</exe-cmd><exe-highlight>suppressed</exe-highlight></execute>',
                    ),
                )
            )
            render = manifest.render_get(RENDER_HTML)
            page = DocHtmlPage(manifest, "user-guide", render.menu, True, "style1", "script1").process()
 
            assert_in('<pre class="execute-line">before</pre>', page)
            assert_in('<pre class="execute-line-highlight">suppressed here</pre>', page)
            assert_in('<pre class="execute-line">after</pre>', page)
 
            # Laid out content that follows laid out content is not separated from it again
            assert_in("</pre>\n<pre", page)
    finally:
        execute_module.DocExecute._execute_run = execute_run_real