Skip to content

Commit 411272c

Browse files
committed
build: commit mrdocs.rng and mrdocs-dom-schema.json, with two verification targets
Both schema files are now committed under docs/, parallel to the existing docs/mrdocs.schema.json (the YAML config schema) and are exposed to the Antora docs site as downloadable attachments. Two new CTest targets, `rng-schema-check` and `dom-schema-check`, run `cmake -E compare_files` between the freshly-generated schemas in the build tree and the checked-in copies; drift fails the test. The schemas custom_command is lifted out of the LibXml2 conditional so the freshness checks run independently of whether libxml2 is available. .gitattributes pins the two schema files to LF line endings, because --schemas emits LF line endings and we do a byte-for-byte comparison.
1 parent 0461119 commit 411272c

7 files changed

Lines changed: 7679 additions & 8 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
test-files/**/*.xml binary
22
test-files/golden-tests/** text eol=lf
33
**.sh text eol=lf
4+
docs/mrdocs.rng text eol=lf
5+
docs/mrdocs-dom-schema.json text eol=lf

CMakeLists.txt

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -553,19 +553,37 @@ if (MRDOCS_BUILD_TESTS)
553553
)
554554
endif()
555555

556+
#-------------------------------------------------
557+
# Schemas
558+
#-------------------------------------------------
559+
# Generate mrdocs.rng and mrdocs-dom-schema.json via --schemas.
560+
add_custom_command(
561+
COMMAND mrdocs --schemas=${CMAKE_CURRENT_BINARY_DIR}
562+
OUTPUT
563+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
564+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs-dom-schema.json
565+
DEPENDS mrdocs
566+
COMMENT "Generating schemas via --schemas")
567+
add_custom_target(mrdocs_schemas ALL DEPENDS
568+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
569+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs-dom-schema.json)
570+
571+
# Freshness checks: the regenerated schemas must match the
572+
# copies checked in under docs/.
573+
add_test(NAME rng-schema-check
574+
COMMAND ${CMAKE_COMMAND} -E compare_files
575+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
576+
${CMAKE_CURRENT_SOURCE_DIR}/docs/mrdocs.rng)
577+
add_test(NAME dom-schema-check
578+
COMMAND ${CMAKE_COMMAND} -E compare_files
579+
${CMAKE_CURRENT_BINARY_DIR}/mrdocs-dom-schema.json
580+
${CMAKE_CURRENT_SOURCE_DIR}/docs/mrdocs-dom-schema.json)
581+
556582
#-------------------------------------------------
557583
# XML lint
558584
#-------------------------------------------------
559585
find_package(LibXml2 ${REQUIRED_IF_STRICT})
560586
if (LibXml2_FOUND)
561-
# Generate mrdocs.rng via the --schemas option.
562-
add_custom_command(
563-
COMMAND mrdocs --schemas=${CMAKE_CURRENT_BINARY_DIR}
564-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng
565-
DEPENDS mrdocs
566-
COMMENT "Generating mrdocs.rng from --schemas")
567-
add_custom_target(mrdocs_rng ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mrdocs.rng)
568-
569587
file(GLOB_RECURSE XML_SOURCES CONFIGURE_DEPENDS test-files/golden-tests/*.xml)
570588
add_test(NAME xml-lint
571589
COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --dropdtd --noout
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../mrdocs-dom-schema.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../mrdocs.rng

docs/modules/ROOT/pages/schemas.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ The target directory is created if it doesn't already exist.
2626

2727
`--schemas` doesn't read your configuration file or your source tree. It runs the schema generator and exits — you can invoke it on a checkout that has never been pointed at a real codebase.
2828

29+
The same files ship with this site:
30+
31+
* xref:attachment$mrdocs.rng[mrdocs.rng]
32+
* xref:attachment$mrdocs-dom-schema.json[mrdocs-dom-schema.json]
33+
34+
They track the published version of MrDocs.
35+
2936
== Validating XML output
3037

3138
[source,bash]

0 commit comments

Comments
 (0)