lol

nixos-render-docs: add all-features manpage renderer test

now that the renderer produces the output we want to keep for the future
we can add a test that checks all of its features. this test notably
does not include markdown headings since we don't want to have those in
manpages (at least right now), but tests for other converters may add
headings for themselves.

authored by

pennae and committed by
pennae
702e1fc7 78052a22

+196
+62
pkgs/tools/nix/nixos-render-docs/src/tests/sample_md.py
··· 1 + sample1 = """\ 2 + :::: {.warning} 3 + foo 4 + ::: {.note} 5 + nested 6 + ::: 7 + :::: 8 + 9 + [ 10 + multiline 11 + ](link) 12 + 13 + {manpage}`man(1)` reference 14 + 15 + [some [nested]{#a} anchors]{#b} 16 + 17 + *emph* **strong** *nesting emph **and strong** and `code`* 18 + 19 + - wide bullet 20 + 21 + - list 22 + 23 + 1. wide ordered 24 + 25 + 2. list 26 + 27 + - narrow bullet 28 + - list 29 + 30 + 1. narrow ordered 31 + 2. list 32 + 33 + > quotes 34 + >> with *nesting* 35 + >> 36 + >> nested code block 37 + > 38 + > - and lists 39 + > - ``` 40 + > containing code 41 + > ``` 42 + > 43 + > and more quote 44 + 45 + 100. list starting at 100 46 + 1. goes on 47 + 48 + deflist 49 + : > with a quote 50 + > and stuff 51 + 52 + code block 53 + 54 + ``` 55 + fenced block 56 + ``` 57 + 58 + text 59 + 60 + more stuff in same deflist 61 + : foo 62 + """
+134
pkgs/tools/nix/nixos-render-docs/src/tests/test_manpage.py
··· 1 1 import nixos_render_docs 2 2 3 + from sample_md import sample1 4 + 3 5 from typing import Mapping, Optional 4 6 5 7 import markdown_it ··· 41 43 c._md.renderer.link_footnotes = [] 42 44 assert c._render("[a](link) [b](link)") == "\\fBa\\fR[1]\\fR \\fBb\\fR[1]\\fR" 43 45 assert c._md.renderer.link_footnotes == ['link'] 46 + 47 + def test_full() -> None: 48 + c = Converter({ 'man(1)': 'http://example.org' }) 49 + assert c._render(sample1) == """\ 50 + .sp 51 + .RS 4 52 + \\fBWarning\\fP 53 + .br 54 + foo 55 + .sp 56 + .RS 4 57 + \\fBNote\\fP 58 + .br 59 + nested 60 + .RE 61 + .RE 62 + .sp 63 + \\fBmultiline\\fR 64 + .sp 65 + \\fBman\\fP\\fR(1)\\fP reference 66 + .sp 67 + some nested anchors 68 + .sp 69 + \\fIemph\\fR \\fBstrong\\fR \\fInesting emph \\fBand strong\\fI and \\fR\\(oqcode\\(cq\\fP\\fR 70 + .sp 71 + .RS 4 72 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 73 + wide bullet 74 + .RE 75 + .sp 76 + .RS 4 77 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 78 + list 79 + .RE 80 + .sp 81 + .RS 4 82 + \\h'-3'\\fB1\\&.\\fP\\h'1'\\c 83 + wide ordered 84 + .RE 85 + .sp 86 + .RS 4 87 + \\h'-3'\\fB2\\&.\\fP\\h'1'\\c 88 + list 89 + .RE 90 + .sp 91 + .RS 4 92 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 93 + narrow bullet 94 + .RE 95 + .RS 4 96 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 97 + list 98 + .RE 99 + .sp 100 + .RS 4 101 + \\h'-3'\\fB1\\&.\\fP\\h'1'\\c 102 + narrow ordered 103 + .RE 104 + .RS 4 105 + \\h'-3'\\fB2\\&.\\fP\\h'1'\\c 106 + list 107 + .RE 108 + .sp 109 + .RS 4 110 + \\h'-3'\\fI\\(lq\\(rq\\fP\\h'1'\\c 111 + quotes 112 + .sp 113 + .RS 4 114 + \\h'-3'\\fI\\(lq\\(rq\\fP\\h'1'\\c 115 + with \\fInesting\\fR 116 + .sp 117 + .RS 4 118 + .nf 119 + nested code block 120 + .fi 121 + .RE 122 + .RE 123 + .sp 124 + .RS 4 125 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 126 + and lists 127 + .RE 128 + .RS 4 129 + \\h'-2'\\fB\\[u2022]\\fP\\h'1'\\c 130 + .sp 131 + .RS 4 132 + .nf 133 + containing code 134 + .fi 135 + .RE 136 + .RE 137 + .sp 138 + and more quote 139 + .RE 140 + .sp 141 + .RS 6 142 + \\h'-5'\\fB100\\&.\\fP\\h'1'\\c 143 + list starting at 100 144 + .RE 145 + .RS 6 146 + \\h'-5'\\fB101\\&.\\fP\\h'1'\\c 147 + goes on 148 + .RE 149 + .RS 4 150 + .PP 151 + deflist 152 + .RS 4 153 + .RS 4 154 + \\h'-3'\\fI\\(lq\\(rq\\fP\\h'1'\\c 155 + with a quote and stuff 156 + .RE 157 + .sp 158 + .RS 4 159 + .nf 160 + code block 161 + .fi 162 + .RE 163 + .sp 164 + .RS 4 165 + .nf 166 + fenced block 167 + .fi 168 + .RE 169 + .sp 170 + text 171 + .RE 172 + .PP 173 + more stuff in same deflist 174 + .RS 4 175 + foo 176 + .RE 177 + .RE"""