Skip to content

Commit d8ac598

Browse files
klemens-morgensternvinniefalco
authored andcommitted
mrdox has a rng schema & test to verify.
close 132, close 136
1 parent 1229e4b commit d8ac598

29 files changed

+692
-9
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
# - { name: "GCC 10 - C++20", os: ubuntu-22.04, cc: gcc-10, cxx: g++-10, cxxstd: 20, install: g++-10 }
2929
# - { name: "GCC 9 - C++20", os: ubuntu-22.04, cc: gcc-9, cxx: g++-9, cxxstd: 20, install: g++-9 }
3030

31-
- { name: "Clang 15 - C++20", os: ubuntu-22.04, cc: clang-15, cxx: clang++-15, cxxstd: 20, install: clang-15 }
31+
- { name: "Clang 15 - C++20", os: ubuntu-22.04, cc: clang-15, cxx: clang++-15, cxxstd: 20, install: "clang-15 libxml2-utils" }
3232

3333
# no <source_location>
3434
# - { name: "Clang 14 - C++20", os: ubuntu-22.04, cc: clang-14, cxx: clang++-14, cxxstd: 20, install: clang-14 }

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ if (MRDOX_BUILD_TESTS)
219219
add_custom_target(reference_adoc DEPENDS reference.adoc)
220220
add_custom_target(reference_xml DEPENDS reference.xml)
221221
endif()
222+
223+
find_package(LibXml2)
224+
if (LibXml2_FOUND)
225+
file(GLOB_RECURSE XML_SOURCES CONFIGURE_DEPENDS test-files/*.xml)
226+
227+
add_test(NAME xml-lint
228+
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --dropdtd
229+
--relaxng ${CMAKE_CURRENT_SOURCE_DIR}/mrdox.rng ${XML_SOURCES}
230+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
231+
endif()
222232
endif()
223233

224234
#-------------------------------------------------

mrdox.dtd

Lines changed: 0 additions & 5 deletions
This file was deleted.

mrdox.rnc

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# convert to mrdox.rng with trang.jar (https://relaxng.org/jclark/trang.html)
2+
# when commiting beacuse xmllint doesn't understand the compact format
3+
4+
namespace xsi= "http://www.w3.org/2001/XMLSchema-instance"
5+
6+
grammar {
7+
start = element mrdox {
8+
attribute xsi:noNamespaceSchemaLocation {text}?,
9+
NamespaceInfo
10+
}
11+
Id = attribute id { text }
12+
Name = attribute name { text }
13+
Attr = element attr { Id, Name ?, attribute value { text } ?}
14+
15+
NamespaceInfo = element namespace {
16+
Name,
17+
Id?,
18+
Info,
19+
Javadoc?,
20+
Scope
21+
}
22+
23+
Symbol = (
24+
attribute Tag { text },
25+
attribute Name { text },
26+
Id
27+
)
28+
29+
Symbols = element symbols {
30+
element symbol { Symbol }
31+
}*
32+
33+
SymbolInfo = (
34+
Info,
35+
Location *
36+
)
37+
38+
TemplateParamInfo = element tparam { attribute decl { text } }
39+
40+
BaseRecordinfo = element base {
41+
Name, Access, attribute modifier { "virtual" } ?, Id
42+
}
43+
44+
RecordInfoContent = (Name,
45+
Id,
46+
(SymbolInfo |
47+
Attr |
48+
TemplateParamInfo |
49+
BaseRecordinfo |
50+
MemberTypeInfo |
51+
element friend { Id } |
52+
Javadoc? |
53+
Scope)*)
54+
55+
RecordInfo =
56+
element class { RecordInfoContent } |
57+
element struct { RecordInfoContent } |
58+
element union { RecordInfoContent }
59+
60+
FunctionInfo = element function {
61+
Name,
62+
Access?,
63+
Id,
64+
(SymbolInfo |
65+
Attr* |
66+
element return { attribute type { text }, Id? } |
67+
element param {
68+
Name?,
69+
attribute type { text },
70+
attribute default { text } ?,
71+
Id?
72+
}* |
73+
TemplateParamInfo* |
74+
Javadoc?)*
75+
}
76+
77+
TypedefInfo = element using
78+
{
79+
Name, Id,
80+
SymbolInfo,
81+
element type { Name, Id? }
82+
} | element typedef
83+
{
84+
Name, Id,
85+
SymbolInfo,
86+
element type { Name, Id? }
87+
}
88+
89+
90+
EnumInfo = element enum {
91+
Name,
92+
attribute class {"scoped"} ?,
93+
attribute type { text } ?,
94+
Id,
95+
SymbolInfo,
96+
element \element {
97+
Name,
98+
attribute Value { text }
99+
}*,
100+
Javadoc?
101+
}
102+
103+
VariableInfo = element variable {
104+
Name,
105+
Id,
106+
(Location &
107+
Attr* &
108+
element type { Name, Id? } &
109+
Javadoc?)
110+
}
111+
112+
Info = empty
113+
114+
Location = element file {
115+
attribute path {text},
116+
attribute line {text},
117+
attribute class {"def"}?,
118+
empty}
119+
120+
BaseRecordInfo = element base {
121+
Name,
122+
Access,
123+
attribute modifier {"virtual"} ?,
124+
Id
125+
}
126+
127+
Access = attribute access { "public"|"private"|"protected" }
128+
129+
MemberTypeInfo = element data {
130+
Name,
131+
attribute type { text },
132+
attribute value { text } ?,
133+
Access,
134+
Id?
135+
}
136+
137+
StorageClass = (
138+
element extern {empty} |
139+
element static {empty} |
140+
element private-extern {empty} |
141+
element sc-auto {empty} |
142+
element sc-register {empty}
143+
)
144+
145+
Scope = (
146+
NamespaceInfo |
147+
RecordInfo |
148+
FunctionInfo |
149+
TypedefInfo |
150+
EnumInfo |
151+
VariableInfo)*
152+
153+
# JavaDoc not in a nested grammar , so we can convert it to a XSD
154+
155+
Javadoc = element doc {Brief ?, Node* }
156+
Text = element text { text }
157+
Brief = element brief { Node * }
158+
Node = (Text | Styled | Paragraph | Brief | Admonition | Code | Param | TParam | Returns)
159+
Styled = (
160+
element none { text } |
161+
element mono { text } |
162+
element bold { text } |
163+
element italic { text })
164+
Paragraph = element para {
165+
attribute class { text } ?,
166+
Node*
167+
}
168+
169+
Admonition = Paragraph
170+
Code = element code { Node * }
171+
Param = element param {
172+
attribute name { text } ?,
173+
Node*
174+
}
175+
176+
TParam = element tparam {
177+
attribute name { text } ?,
178+
Node*
179+
}
180+
Returns = element returns { Node * }
181+
182+
}

0 commit comments

Comments
 (0)