Skip to content

Commit 02657fe

Browse files
committed
test: add an end-to-end fixture for a data-driven generator
This adds a fixture under test-files/template-only-generators/mock-md that ships its own mock "Markdown-like" generator via an addon-local `addons-supplemental`: a one-line layout that emits the symbol name, plus a single escape rule mapping `_` to `\_`.
1 parent 25d6c78 commit 02657fe

7 files changed

Lines changed: 60 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,44 @@ if (MRDOCS_BUILD_TESTS)
553553
)
554554
endforeach ()
555555

556+
#-------------------------------------------------
557+
# Template-only generators
558+
#
559+
# Fixtures under test-files/template-only-generators/<id> ship an
560+
# addon defining their own Handlebars generator. They live outside
561+
# test-files/golden-tests so the xml/adoc/html runs do not walk
562+
# into them and demand expected files in their own formats.
563+
#-------------------------------------------------
564+
set(MRDOCS_TEMPLATE_ONLY_ROOT "${PROJECT_SOURCE_DIR}/test-files/template-only-generators")
565+
add_test(NAME mrdocs-golden-tests-mock-md
566+
COMMAND
567+
mrdocs-test
568+
--unit=false
569+
--action=test
570+
"${MRDOCS_TEMPLATE_ONLY_ROOT}/mock-md"
571+
"--addons=${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
572+
--generator=mock-md
573+
"--stdlib-includes=${LIBCXX_DIR}"
574+
"--libc-includes=${CMAKE_SOURCE_DIR}/share/mrdocs/headers/libc-stubs"
575+
--log-level=warn
576+
)
577+
foreach (action IN ITEMS test create update)
578+
add_custom_target(
579+
mrdocs-${action}-test-fixtures-mock-md
580+
COMMAND
581+
mrdocs-test
582+
--unit=false
583+
--action=${action}
584+
"${MRDOCS_TEMPLATE_ONLY_ROOT}/mock-md"
585+
"--addons=${CMAKE_SOURCE_DIR}/share/mrdocs/addons"
586+
--generator=mock-md
587+
"--stdlib-includes=${LIBCXX_DIR}"
588+
"--libc-includes=${CMAKE_SOURCE_DIR}/share/mrdocs/headers/libc-stubs"
589+
--log-level=warn
590+
DEPENDS mrdocs-test
591+
)
592+
endforeach ()
593+
556594
#-------------------------------------------------
557595
# Self-documentation test (warn-as-error toggled by strict flag)
558596
#-------------------------------------------------
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{symbol.name}}: {{#each symbol.doc.brief.children}}{{literal}}{{/each}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{{contents}}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
escape:
2+
'_': '\_'
3+
'TODO': '[!]'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
addons-supplemental:
2+
- addons
3+
generator: mock-md
4+
multipage: false
5+
show-namespaces: false
6+
warn-if-undocumented: false
7+
source-root: .
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// A trivial input that exercises the addon-defined mock-md generator.
2+
// The function name contains an underscore so the single-byte escape
3+
// rule '_' -> '\_' fires on it; the doc-comment's brief begins with
4+
// the literal token TODO so the multi-byte rule 'TODO' -> '[!]' fires
5+
// there during rendering.
6+
7+
/// TODO write me
8+
void my_function();
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
my\_function: [!] write me
2+

0 commit comments

Comments
 (0)