Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/devmanual:master commit in: /
Date: Mon, 24 Jan 2022 18:16:46
Message-Id: 1643048170.6ef11f64a2d763360542bd6a3c74da46f15dfa23.ulm@gentoo
1 commit: 6ef11f64a2d763360542bd6a3c74da46f15dfa23
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jan 16 21:59:15 2022 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 24 18:16:10 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=6ef11f64
7
8 devbook.rnc: Change from DTD to RELAX NG compact schema
9
10 The currently used DTD format has several limitations. It does not
11 support data types, and it is not expressive enough for some element
12 syntax used in the devmanual. For example, it cannot accurately
13 describe the uri element which comes in two alternative forms
14 (namely, with the link in its body text or as an attribute).
15
16 RELAX NG is chosen because it has a variant with a compact and very
17 readable non-XML syntax, and it is well supported both as an input and
18 as an output format by conversion tools like app-text/trang. Also, we
19 need RNC for app-emacs/nxml-gentoo-schemas anyway.
20
21 devbook.rnc is the source file, but the generated devbook.rng is also
22 committed to the repository, in order to avoid an additional
23 dependency on trang or rnc2rng.
24
25 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
26
27 Makefile | 10 +-
28 devbook.dtd | 94 ---------------
29 devbook.rnc | 113 ++++++++++++++++++
30 devbook.rng | 391 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31 4 files changed, 512 insertions(+), 96 deletions(-)
32
33 diff --git a/Makefile b/Makefile
34 index 2c7952a..cbb31e7 100644
35 --- a/Makefile
36 +++ b/Makefile
37 @@ -82,10 +82,16 @@ install: all
38 install -m 644 $(JS_FILES) "$(DESTDIR)$(htmldir)"/; \
39 fi
40
41 -validate:
42 - @xmllint --noout --dtdvalid devbook.dtd $(XMLS)
43 +# Not all versions of xmllint support --quiet, so test for it first
44 +validate: devbook.rng
45 + @opt=--quiet; xmllint --help 2>&1 | grep -q -- --quiet || opt=; \
46 + xmllint --noout $${opt} --relaxng $< $(XMLS)
47 @echo "xmllint validation successful"
48
49 +%.rng: %.rnc
50 + trang $< $@
51 + sed -i -e '2s/^/<!-- Auto-generated from $<; do not edit! -->\n/' $@
52 +
53 # Run app-text/htmltidy on the output to detect mistakes.
54 # We have to loop through them because otherwise tidy won't
55 # tell you which file contains a mistake.
56
57 diff --git a/devbook.dtd b/devbook.dtd
58 deleted file mode 100644
59 index 77ba737..0000000
60 --- a/devbook.dtd
61 +++ /dev/null
62 @@ -1,94 +0,0 @@
63 -<!-- Copyright 2019-2021 Gentoo Authors -->
64 -<!-- Distributed under the terms of the MIT/X11 license
65 - or the CC-BY-SA-4.0 license (dual-licensed) -->
66 -
67 -<!-- Document Type Definition for the Gentoo Devmanual -->
68 -<!-- Based on common.dtd from GuideXML -->
69 -
70 -<!ENTITY % block.class "p|pre|codesample|note|important|warning|todo
71 - |figure|table|ul|ol|dl">
72 -<!ENTITY % attrib.class "b|c|e">
73 -<!ENTITY % inline.class "%attrib.class;|d|uri">
74 -<!ENTITY % all.class "%block.class;|%inline.class;">
75 -
76 -<!ELEMENT guide (chapter, include*)>
77 -<!ATTLIST guide root (true) #IMPLIED
78 - self CDATA #IMPLIED>
79 -
80 -<!ELEMENT include EMPTY>
81 -<!ATTLIST include href CDATA #REQUIRED>
82 -
83 -<!ELEMENT chapter (title, (body|section), section*)>
84 -<!ELEMENT section (title, (body|subsection), subsection*)>
85 -<!ELEMENT subsection (title, (body|subsubsection), subsubsection*)>
86 -<!ELEMENT subsubsection (title, body)>
87 -
88 -<!-- Title texts are used as anchors, so allow only text attributes -->
89 -<!ELEMENT title (#PCDATA|%attrib.class;)*>
90 -
91 -<!ELEMENT body (authors|contentsTree|%block.class;)+>
92 -
93 -<!ELEMENT authors (author+|authorlist+)>
94 -<!ELEMENT author (#PCDATA|%inline.class;)*>
95 -<!ATTLIST author name CDATA #REQUIRED
96 - email CDATA #IMPLIED>
97 -<!ELEMENT authorlist EMPTY>
98 -<!ATTLIST authorlist title CDATA #REQUIRED
99 - href CDATA #REQUIRED>
100 -
101 -<!ELEMENT contentsTree EMPTY>
102 -<!ATTLIST contentsTree maxdepth CDATA #IMPLIED
103 - root CDATA #IMPLIED
104 - extraction CDATA #IMPLIED>
105 -
106 -<!ELEMENT p (#PCDATA|%inline.class;)*>
107 -
108 -<!ELEMENT pre (#PCDATA)>
109 -
110 -<!ELEMENT codesample (#PCDATA)>
111 -<!ATTLIST codesample lang (c|ebuild|make|m4|sgml) #REQUIRED
112 - numbering (lines) #IMPLIED>
113 -
114 -<!ELEMENT note (#PCDATA|%inline.class;)*>
115 -<!ELEMENT important (#PCDATA|%inline.class;)*>
116 -<!ELEMENT warning (#PCDATA|%inline.class;)*>
117 -<!ELEMENT todo (#PCDATA|%inline.class;)*>
118 -
119 -<!ELEMENT figure EMPTY>
120 -<!ATTLIST figure link CDATA #REQUIRED
121 - short CDATA #IMPLIED
122 - caption CDATA #IMPLIED>
123 -
124 -<!ELEMENT table (tr)+>
125 -
126 -<!ELEMENT tr (th|ti)+>
127 -
128 -<!ELEMENT th (#PCDATA|%inline.class;)*>
129 -<!ATTLIST th colspan CDATA #IMPLIED
130 - rowspan CDATA #IMPLIED
131 - align (left|center|right) "left">
132 -
133 -<!ELEMENT ti (#PCDATA|%all.class;)*>
134 -<!ATTLIST ti colspan CDATA #IMPLIED
135 - rowspan CDATA #IMPLIED
136 - nowrap CDATA #IMPLIED
137 - align (left|center|right) "left">
138 -
139 -<!ELEMENT ul (li)+>
140 -<!ATTLIST ul class CDATA #IMPLIED>
141 -
142 -<!ELEMENT ol (li)+>
143 -
144 -<!ELEMENT li (#PCDATA|%all.class;)*>
145 -
146 -<!ELEMENT dl (dt|dd)+>
147 -<!ELEMENT dt (#PCDATA|%inline.class;)*>
148 -<!ELEMENT dd (#PCDATA|%all.class;)*>
149 -
150 -<!ELEMENT b (#PCDATA|%inline.class;)*>
151 -<!ELEMENT c (#PCDATA|%inline.class;)*>
152 -<!ELEMENT e (#PCDATA|%inline.class;)*>
153 -<!ELEMENT d EMPTY>
154 -
155 -<!ELEMENT uri (#PCDATA|%inline.class;)*>
156 -<!ATTLIST uri link CDATA #IMPLIED>
157
158 diff --git a/devbook.rnc b/devbook.rnc
159 new file mode 100644
160 index 0000000..4ca931d
161 --- /dev/null
162 +++ b/devbook.rnc
163 @@ -0,0 +1,113 @@
164 +# Copyright 2022 Gentoo Authors
165 +# Distributed under the terms of the MIT license
166 +# or the CC-BY-SA-4.0 license (dual-licensed)
167 +
168 +# RELAX NG schema for the Gentoo Devmanual
169 +# Based on common.dtd from GuideXML
170 +
171 +block.class = p | pre | codesample | note | important | warning | todo
172 +| figure | table | ul | ol | dl
173 +attrib.class = text | b | c | e
174 +inline.class = attrib.class | d | uri
175 +
176 +attrib = attrib.class*
177 +inline = inline.class*
178 +all = (block.class | inline.class)*
179 +
180 +start = guide
181 +
182 +guide = element guide {
183 + (attribute root { "true" } | attribute self { text }),
184 + chapter,
185 + \include*
186 +}
187 +
188 +\include = element include { attribute href { text } }
189 +
190 +chapter = element chapter { title, (body | section), section* }
191 +section = element section { title, (body | subsection), subsection* }
192 +subsection =
193 + element subsection { title, (body | subsubsection), subsubsection* }
194 +subsubsection = element subsubsection { title, body }
195 +
196 +# Title texts are used as anchors, so allow only text attributes
197 +title = element title { attrib }
198 +
199 +body = element body { (authors | contentsTree | block.class)+ }
200 +
201 +authors = element authors { author+ | authorlist+ }
202 +
203 +author = element author {
204 + attribute name { text },
205 + attribute email { text }?,
206 + inline
207 +}
208 +
209 +authorlist = element authorlist {
210 + attribute title { text },
211 + attribute href { text }
212 +}
213 +
214 +contentsTree = element contentsTree {
215 + attribute maxdepth { xsd:unsignedInt }?,
216 + attribute root { text }?,
217 + attribute extraction { text }?
218 +}
219 +
220 +p = element p { inline }
221 +
222 +pre = element pre { text }
223 +
224 +codesample = element codesample {
225 + attribute lang { "c" | "ebuild" | "make" | "m4" | "sgml" },
226 + attribute numbering { "lines" }?,
227 + text
228 +}
229 +
230 +note = element note { inline }
231 +important = element important { inline }
232 +warning = element warning { inline }
233 +todo = element todo { inline }
234 +
235 +figure = element figure {
236 + attribute link { text },
237 + attribute short { text }?,
238 + attribute caption { text }?
239 +}
240 +
241 +table = element table { tr+ }
242 +tr = element tr { (th | ti)+ }
243 +
244 +th = element th {
245 + attribute colspan { xsd:unsignedInt }?,
246 + attribute rowspan { xsd:unsignedInt }?,
247 + attribute align { "left" | "center" | "right" }?,
248 + inline
249 +}
250 +
251 +ti = element ti {
252 + attribute colspan { xsd:unsignedInt }?,
253 + attribute rowspan { xsd:unsignedInt }?,
254 + attribute nowrap { "nowrap" }?,
255 + attribute align { "left" | "center" | "right" }?,
256 + all
257 +}
258 +
259 +ul = element ul { attribute class { "list-group" }?, li+ }
260 +ol = element ol { li+ }
261 +li = element li { all }
262 +
263 +dl = element dl { (dt | dd)+ }
264 +dt = element dt { inline }
265 +dd = element dd { all }
266 +
267 +b = element b { inline }
268 +c = element c { inline }
269 +e = element e { inline }
270 +d = element d { empty }
271 +
272 +uri = element uri {
273 + # uri can have either an URI in the body text or a link attribute
274 + xsd:anyURI
275 + | (attribute link { text }, inline)
276 +}
277
278 diff --git a/devbook.rng b/devbook.rng
279 new file mode 100644
280 index 0000000..660e4d2
281 --- /dev/null
282 +++ b/devbook.rng
283 @@ -0,0 +1,391 @@
284 +<?xml version="1.0" encoding="UTF-8"?>
285 +<!-- Auto-generated from devbook.rnc; do not edit! -->
286 +<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
287 + <!--
288 + Copyright 2022 Gentoo Authors
289 + Distributed under the terms of the MIT license
290 + or the CC-BY-SA-4.0 license (dual-licensed)
291 + -->
292 + <!--
293 + RELAX NG schema for the Gentoo Devmanual
294 + Based on common.dtd from GuideXML
295 + -->
296 + <define name="block.class">
297 + <choice>
298 + <ref name="p"/>
299 + <ref name="pre"/>
300 + <ref name="codesample"/>
301 + <ref name="note"/>
302 + <ref name="important"/>
303 + <ref name="warning"/>
304 + <ref name="todo"/>
305 + <ref name="figure"/>
306 + <ref name="table"/>
307 + <ref name="ul"/>
308 + <ref name="ol"/>
309 + <ref name="dl"/>
310 + </choice>
311 + </define>
312 + <define name="attrib.class">
313 + <choice>
314 + <text/>
315 + <ref name="b"/>
316 + <ref name="c"/>
317 + <ref name="e"/>
318 + </choice>
319 + </define>
320 + <define name="inline.class">
321 + <choice>
322 + <ref name="attrib.class"/>
323 + <ref name="d"/>
324 + <ref name="uri"/>
325 + </choice>
326 + </define>
327 + <define name="attrib">
328 + <zeroOrMore>
329 + <ref name="attrib.class"/>
330 + </zeroOrMore>
331 + </define>
332 + <define name="inline">
333 + <zeroOrMore>
334 + <ref name="inline.class"/>
335 + </zeroOrMore>
336 + </define>
337 + <define name="all">
338 + <zeroOrMore>
339 + <choice>
340 + <ref name="block.class"/>
341 + <ref name="inline.class"/>
342 + </choice>
343 + </zeroOrMore>
344 + </define>
345 + <start>
346 + <ref name="guide"/>
347 + </start>
348 + <define name="guide">
349 + <element name="guide">
350 + <choice>
351 + <attribute name="root">
352 + <value>true</value>
353 + </attribute>
354 + <attribute name="self"/>
355 + </choice>
356 + <ref name="chapter"/>
357 + <zeroOrMore>
358 + <ref name="include"/>
359 + </zeroOrMore>
360 + </element>
361 + </define>
362 + <define name="include">
363 + <element name="include">
364 + <attribute name="href"/>
365 + </element>
366 + </define>
367 + <define name="chapter">
368 + <element name="chapter">
369 + <ref name="title"/>
370 + <choice>
371 + <ref name="body"/>
372 + <ref name="section"/>
373 + </choice>
374 + <zeroOrMore>
375 + <ref name="section"/>
376 + </zeroOrMore>
377 + </element>
378 + </define>
379 + <define name="section">
380 + <element name="section">
381 + <ref name="title"/>
382 + <choice>
383 + <ref name="body"/>
384 + <ref name="subsection"/>
385 + </choice>
386 + <zeroOrMore>
387 + <ref name="subsection"/>
388 + </zeroOrMore>
389 + </element>
390 + </define>
391 + <define name="subsection">
392 + <element name="subsection">
393 + <ref name="title"/>
394 + <choice>
395 + <ref name="body"/>
396 + <ref name="subsubsection"/>
397 + </choice>
398 + <zeroOrMore>
399 + <ref name="subsubsection"/>
400 + </zeroOrMore>
401 + </element>
402 + </define>
403 + <define name="subsubsection">
404 + <element name="subsubsection">
405 + <ref name="title"/>
406 + <ref name="body"/>
407 + </element>
408 + </define>
409 + <!-- Title texts are used as anchors, so allow only text attributes -->
410 + <define name="title">
411 + <element name="title">
412 + <ref name="attrib"/>
413 + </element>
414 + </define>
415 + <define name="body">
416 + <element name="body">
417 + <oneOrMore>
418 + <choice>
419 + <ref name="authors"/>
420 + <ref name="contentsTree"/>
421 + <ref name="block.class"/>
422 + </choice>
423 + </oneOrMore>
424 + </element>
425 + </define>
426 + <define name="authors">
427 + <element name="authors">
428 + <choice>
429 + <oneOrMore>
430 + <ref name="author"/>
431 + </oneOrMore>
432 + <oneOrMore>
433 + <ref name="authorlist"/>
434 + </oneOrMore>
435 + </choice>
436 + </element>
437 + </define>
438 + <define name="author">
439 + <element name="author">
440 + <attribute name="name"/>
441 + <optional>
442 + <attribute name="email"/>
443 + </optional>
444 + <ref name="inline"/>
445 + </element>
446 + </define>
447 + <define name="authorlist">
448 + <element name="authorlist">
449 + <attribute name="title"/>
450 + <attribute name="href"/>
451 + </element>
452 + </define>
453 + <define name="contentsTree">
454 + <element name="contentsTree">
455 + <optional>
456 + <attribute name="maxdepth">
457 + <data type="unsignedInt"/>
458 + </attribute>
459 + </optional>
460 + <optional>
461 + <attribute name="root"/>
462 + </optional>
463 + <optional>
464 + <attribute name="extraction"/>
465 + </optional>
466 + </element>
467 + </define>
468 + <define name="p">
469 + <element name="p">
470 + <ref name="inline"/>
471 + </element>
472 + </define>
473 + <define name="pre">
474 + <element name="pre">
475 + <text/>
476 + </element>
477 + </define>
478 + <define name="codesample">
479 + <element name="codesample">
480 + <attribute name="lang">
481 + <choice>
482 + <value>c</value>
483 + <value>ebuild</value>
484 + <value>make</value>
485 + <value>m4</value>
486 + <value>sgml</value>
487 + </choice>
488 + </attribute>
489 + <optional>
490 + <attribute name="numbering">
491 + <value>lines</value>
492 + </attribute>
493 + </optional>
494 + <text/>
495 + </element>
496 + </define>
497 + <define name="note">
498 + <element name="note">
499 + <ref name="inline"/>
500 + </element>
501 + </define>
502 + <define name="important">
503 + <element name="important">
504 + <ref name="inline"/>
505 + </element>
506 + </define>
507 + <define name="warning">
508 + <element name="warning">
509 + <ref name="inline"/>
510 + </element>
511 + </define>
512 + <define name="todo">
513 + <element name="todo">
514 + <ref name="inline"/>
515 + </element>
516 + </define>
517 + <define name="figure">
518 + <element name="figure">
519 + <attribute name="link"/>
520 + <optional>
521 + <attribute name="short"/>
522 + </optional>
523 + <optional>
524 + <attribute name="caption"/>
525 + </optional>
526 + </element>
527 + </define>
528 + <define name="table">
529 + <element name="table">
530 + <oneOrMore>
531 + <ref name="tr"/>
532 + </oneOrMore>
533 + </element>
534 + </define>
535 + <define name="tr">
536 + <element name="tr">
537 + <oneOrMore>
538 + <choice>
539 + <ref name="th"/>
540 + <ref name="ti"/>
541 + </choice>
542 + </oneOrMore>
543 + </element>
544 + </define>
545 + <define name="th">
546 + <element name="th">
547 + <optional>
548 + <attribute name="colspan">
549 + <data type="unsignedInt"/>
550 + </attribute>
551 + </optional>
552 + <optional>
553 + <attribute name="rowspan">
554 + <data type="unsignedInt"/>
555 + </attribute>
556 + </optional>
557 + <optional>
558 + <attribute name="align">
559 + <choice>
560 + <value>left</value>
561 + <value>center</value>
562 + <value>right</value>
563 + </choice>
564 + </attribute>
565 + </optional>
566 + <ref name="inline"/>
567 + </element>
568 + </define>
569 + <define name="ti">
570 + <element name="ti">
571 + <optional>
572 + <attribute name="colspan">
573 + <data type="unsignedInt"/>
574 + </attribute>
575 + </optional>
576 + <optional>
577 + <attribute name="rowspan">
578 + <data type="unsignedInt"/>
579 + </attribute>
580 + </optional>
581 + <optional>
582 + <attribute name="nowrap">
583 + <value>nowrap</value>
584 + </attribute>
585 + </optional>
586 + <optional>
587 + <attribute name="align">
588 + <choice>
589 + <value>left</value>
590 + <value>center</value>
591 + <value>right</value>
592 + </choice>
593 + </attribute>
594 + </optional>
595 + <ref name="all"/>
596 + </element>
597 + </define>
598 + <define name="ul">
599 + <element name="ul">
600 + <optional>
601 + <attribute name="class">
602 + <value>list-group</value>
603 + </attribute>
604 + </optional>
605 + <oneOrMore>
606 + <ref name="li"/>
607 + </oneOrMore>
608 + </element>
609 + </define>
610 + <define name="ol">
611 + <element name="ol">
612 + <oneOrMore>
613 + <ref name="li"/>
614 + </oneOrMore>
615 + </element>
616 + </define>
617 + <define name="li">
618 + <element name="li">
619 + <ref name="all"/>
620 + </element>
621 + </define>
622 + <define name="dl">
623 + <element name="dl">
624 + <oneOrMore>
625 + <choice>
626 + <ref name="dt"/>
627 + <ref name="dd"/>
628 + </choice>
629 + </oneOrMore>
630 + </element>
631 + </define>
632 + <define name="dt">
633 + <element name="dt">
634 + <ref name="inline"/>
635 + </element>
636 + </define>
637 + <define name="dd">
638 + <element name="dd">
639 + <ref name="all"/>
640 + </element>
641 + </define>
642 + <define name="b">
643 + <element name="b">
644 + <ref name="inline"/>
645 + </element>
646 + </define>
647 + <define name="c">
648 + <element name="c">
649 + <ref name="inline"/>
650 + </element>
651 + </define>
652 + <define name="e">
653 + <element name="e">
654 + <ref name="inline"/>
655 + </element>
656 + </define>
657 + <define name="d">
658 + <element name="d">
659 + <empty/>
660 + </element>
661 + </define>
662 + <define name="uri">
663 + <element name="uri">
664 + <choice>
665 + <!-- uri can have either an URI in the body text or a link attribute -->
666 + <data type="anyURI"/>
667 + <group>
668 + <attribute name="link"/>
669 + <ref name="inline"/>
670 + </group>
671 + </choice>
672 + </element>
673 + </define>
674 +</grammar>