]> Lady’s Gitweb - Codemark/blob - xslt/documentation.xslt
Initial commit
[Codemark] / xslt / documentation.xslt
1 <?xml version="1.0"?>
2 <!--
3 SPDX-FileCopyrightText: 2025, 2026 Lady <https://www.ladys.computer/about/#lady>
4 SPDX-License-Identifier: MPL-2.0
5 -->
6 <!-->
7 ⋯ 🧮🖍 Codemark ∷ xslt ∷ documentation.xslt
8
9 ⁌ Documentation transform
10
11 ] © 2025–2026 Lady [@ Ladys Computer].
12 ]
13 ] This Source Code Form is subject to the terms of the Mozilla Public
14 ] License, version 2.0.
15 ] If a copy of the M·P·L was not distributed with this file, You can
16 ] obtain one at {🔗<https://mozilla.org/MPL/2.0/>}.
17 <-->
18 <!DOCTYPE transform [
19 <!ENTITY xhtml 'http://www.w3.org/1999/xhtml'>
20 ]>
21 <transform
22 xmlns="http://www.w3.org/1999/XSL/Transform"
23 xmlns:exsl="http://exslt.org/common"
24 xmlns:html="&xhtml;"
25 extension-element-prefixes="exsl"
26 version="1.0"
27 >
28 <param name="DOCDIR" select="'../@documentation.tmp'"/>
29 <param name="PROJECT_NAME" select="''"/>
30 <include href="../@modules.tmp/%F0%9F%92%84%F0%9F%93%9D/parser.xslt"/>
31 <template match="/">
32 <variable name="result-fragment">
33 <apply-templates/>
34 </variable>
35 <variable name="result" select="exsl:node-set($result-fragment)/*"/>
36 <element name="html" namespace="&xhtml;">
37 <attribute name="lang">
38 <text>en</text>
39 </attribute>
40 <attribute name="xml:lang">
41 <text>en</text>
42 </attribute>
43 <element name="head" namespace="&xhtml;">
44 <element name="title" namespace="&xhtml;">
45 <for-each select="$result//html:h1//text()">
46 <value-of select="."/>
47 </for-each>
48 <if test="$PROJECT_NAME!=''">
49 <text> | </text>
50 <value-of select="$PROJECT_NAME"/>
51 <text> Documentation</text>
52 </if>
53 </element>
54 <element name="style" namespace="&xhtml;">
55 <text><![CDATA[@charset "UTF-8";
56 @namespace "http://www.w3.org/1999/xhtml";
57 html{ Color-Scheme: Light Dark }
58 article{ Box-Sizing: Border-Box; Margin: Auto; Padding-Inline: 2REM; Inline-Size: Min-Content; Max-Inline-Size: 100%; Line-Height: 1.2 }
59 article::after{ Display: Block; Inline-Size: 31REM; Max-Inline-Size: 100%; Min-Inline-Size: 100%; Content: "" }
60 blockquote>pre{ Margin: Auto; Inline-Size: 71CH; Max-Inline-Size: 100%; White-Space: Pre-Wrap }
61 blockquote>pre+pre{ Margin-Top: 1LH }
62 h1,h2,h3{ Margin-Inline: -1REM; Border-Block-End: Thin Solid; Padding-Block: .25EM; Padding-Inline: 1REM; Font-Weight: Inherit }
63 h1{ Font-Size: XX-Large }
64 h2{ Font-Size: X-Large }
65 h3{ Font-Size: Large }
66 hr{ Margin-Inline: -1REM }
67 pre{ Line-Height: 1.8 }
68 code small{ Color: RGB(From CurrentColor R G B / .5); Font-Size: Inherit }
69 code i{ Color: Light-Dark(OKLch(From AccentColor 55% .2 H), OKLch(From AccentColor 85% .2 H)); Font: Inherit }
70 ]]></text>
71 </element>
72 </element>
73 <element name="body" namespace="&xhtml;">
74 <element name="article" namespace="&xhtml;">
75 <apply-templates select="$result//html:div[@class='body']"/>
76 </element>
77 </element>
78 </element>
79 </template>
80 <template match="html:ul[ancestor::html:*/@data-lesml-profile='urn:fdc:ladys.computer:20260226:Codemark:pf:index']">
81 <variable name="self" select="."/>
82 <variable name="subdirs-fragment">
83 <for-each select=".//html:a[contains(substring-after(substring-after(., '/'), '/'), '/')]">
84 <html:span data-kind-dir="{substring-before(substring-after(., '/'), '/')}" data-category-dir="{substring-before(substring-after(substring-after(., '/'), '/'), '/')}"/>
85 </for-each>
86 </variable>
87 <variable name="subdirs" select="exsl:node-set($subdirs-fragment)/*"/>
88 <copy-of select="$subdirs"/>
89 <element name="ul" namespace="&xhtml;">
90 <for-each select=".//html:a[not(contains(substring-after(substring-after(., '/'), '/'), '/'))]">
91 <sort select="@href" lang="zxx" case-order="upper-first"/>
92 <element name="li" namespace="&xhtml;">
93 <if test="contains(@href, 'README.xhtml') and substring-after(@href, 'README.xhtml')=''">
94 <element name="strong" namespace="&xhtml;">
95 <text>README:</text>
96 </element>
97 <text> </text>
98 </if>
99 <copy>
100 <copy-of select="@href"/>
101 <copy-of select="document(concat($DOCDIR, '/', substring-after(@href, './')))//html:h1/node()"/>
102 </copy>
103 </element>
104 </for-each>
105 </element>
106 <for-each select="$subdirs/@data-kind-dir">
107 <sort select="." lang="zxx" case-order="upper-first"/>
108 <variable name="kind" select="string()"/>
109 <if test="not(preceding::*[@data-kind-dir=$kind])">
110 <element name="section" namespace="&xhtml;">
111 <element name="h2" namespace="&xhtml;">
112 <element name="code" namespace="&xhtml;">
113 <text>.</text>
114 <value-of select="$kind"/>
115 </element>
116 <text> files</text>
117 </element>
118 <for-each select="$subdirs[@data-kind-dir=$kind]/@data-category-dir">
119 <sort select="." lang="zxx" case-order="upper-first"/>
120 <variable name="category" select="string()"/>
121 <if test="not(preceding::*[@data-category-dir=$category])">
122 <element name="section" namespace="&xhtml;">
123 <element name="h3" namespace="&xhtml;">
124 <value-of select="translate(substring($category, 1, 1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
125 <value-of select="substring($category, 2)"/>
126 </element>
127 <element name="ul" namespace="&xhtml;">
128 <for-each select="$self//html:a[starts-with(., concat('./', $kind, '/', $category, '/'))]">
129 <sort select="@href" lang="zxx" case-order="upper-first"/>
130 <element name="li" namespace="&xhtml;">
131 <if test="contains(@href, 'README.xhtml') and substring-after(@href, 'README.xhtml')=''">
132 <element name="strong" namespace="&xhtml;">
133 <text>README:</text>
134 </element>
135 <text> </text>
136 </if>
137 <copy>
138 <copy-of select="@href"/>
139 <copy-of select="document(concat($DOCDIR, '/', substring-after(@href, './')))//html:h1/node()"/>
140 </copy>
141 </element>
142 </for-each>
143 </element>
144 </element>
145 </if>
146 </for-each>
147 </element>
148 </if>
149 </for-each>
150 </template>
151 <template match="html:pre">
152 <copy>
153 <apply-templates select="@*"/>
154 <element name="html:code">
155 <apply-templates select="node()"/>
156 </element>
157 </copy>
158 </template>
159 <template match="html:pre//html:cite">
160 <element name="html:strong">
161 <apply-templates select="@*|node()"/>
162 </element>
163 </template>
164 <template match="html:pre//html:u">
165 <element name="html:var">
166 <apply-templates select="@*|node()"/>
167 </element>
168 </template>
169 <template match="comment()" priority="-1"/>
170 <template match="@*|node()" priority="-1">
171 <copy>
172 <apply-templates select="@*|node()"/>
173 </copy>
174 </template>
175 <output method="xml" encoding="UTF-8" standalone="yes" cdata-section-elements="html:script html:style html:textarea"/>
176 </transform>
This page took 0.052438 seconds and 5 git commands to generate.