@@ -102,31 +102,35 @@ It is sometimes just nice to know that your code snippet will run without except
102102== Inline Options
103103You can, to some limited extent, communicate your intent to test-doc-blocks.
104104
105- Test-doc-blocks will look for AsciiDoc comments that begin with `:test-doc-blocks`.
105+ Test-doc-blocks will look for AsciiDoc `:test-doc-blocks` comment lines .
106106
107107It currently understands the following options:
108108
109- * `:test-doc-blocks/apply` - controls to what code blocks options are applied
110109* `:test-doc-blocks/skip` - skips the next code block
111110* `:test-doc-blocks/reader-cond` - wraps your code block in a reader conditional
112111* `:test-doc-blocks/test-ns` - specifies the output test namespace
113112* `:test-doc-blocks/platform` - specifies Clojure file type to generate for test ns
114113* `:test-doc-blocks/meta` - attach metadata to generated tests
114+ * `:test-doc-blocks/apply` - controls to what code blocks options are applied
115115
116- === Applying Options - :apply
117-
118- By default, test-doc-blocks will create tests for all Clojure code blocks it finds in the files you specified.
116+ === Skipping Code Blocks - :skip
119117
120- You can change this by including the `:test-doc- blocks/apply` option:
118+ By default, test-doc-blocks will create tests for all Clojure code blocks it finds.
121119
122- * `:next` - default - applies new options to next Clojure code block only
123- * `:all-next` - applies new options to all subsequent code blocks in the document until specifically overridden with new opts
120+ Tell test-doc-blocks to skip the next Clojure code block via `//#:test-doc-blocks {:skip true}`:
124121
125- === Skipping Code Blocks - :skip
122+ [source,asciidoc]
123+ ....
124+ //#:test-doc-blocks {:skip true}
125+ [source,clojure]
126+ ----
127+ ;; no tests will be generated for this code Clojure code block
126128
127- By default, test-doc-blocks will create tests for all Clojure code blocks it finds.
129+ (something we don't want to test...
130+ ----
131+ ....
128132
129- Tell test-doc-blocks to skip the next Clojure code block via the following AsciiDoc comment :
133+ Because `: skip` is a boolean, you can use the shorter `//:test-doc-blocks/skip` :
130134
131135[source,asciidoc]
132136....
@@ -135,7 +139,7 @@ Tell test-doc-blocks to skip the next Clojure code block via the following Ascii
135139----
136140;; no tests will be generated for this code Clojure code block
137141
138- (something we don't want to test)
142+ (something we don't want to test...
139143----
140144....
141145
@@ -188,7 +192,8 @@ Test-doc-blocks does no special checking, but `:reader-cond` only makes sense fo
188192=== Specifying Test Namespace - :test-ns
189193
190194By default, test-doc-blocks will generate tests to namespaces based on document filenames.
191- This file is named `example.adoc`. Test-doc-blocks, up to this point, has been generating tests to the `example-adoc-test` namespace.
195+ This file you are reading now is named `example.adoc`.
196+ Test-doc-blocks, up to this point, has been generating tests to the `example-adoc-test` namespace.
192197
193198If this does not work for you, you can override this default via an AsciiDoc comment:
194199
@@ -238,7 +243,7 @@ When specifying the platform, remember that:
238243* For Clojure `my-ns-file.clj` will be picked over `my-ns-file.cljc`
239244* For ClojureScript `my-ns-file.cljs` will be picked over `my-ns-file.cljc`
240245
241- So if you are generating mixed platforms, you might want to specify the test-ns as well.
246+ So if you are generating mixed platforms, you might want to specify the test-ns as well:
242247
243248[source,asciidoc]
244249....
@@ -301,6 +306,62 @@ user=> (into [] {:a 1})
301306----
302307....
303308
309+ === Applying Options - :apply
310+
311+ Use the `:test-doc-blocks/apply` option to control which code blocks your specified option(s) apply to:
312+
313+ * `:next` - default - applies new options to next Clojure code block only
314+ * `:all-next` - applies new options to all subsequent code blocks in the document until specifically overridden with new opts
315+
316+ For example, maybe you want test-doc-blocks to skip code blocks by default:
317+
318+ [source,asciidoc]
319+ ....
320+ //#:test-doc-blocks{:skip true :apply :all-next}
321+ ....
322+
323+ All subsequent code blocks would be skipped.
324+
325+ [source,asciidoc]
326+ ....
327+ [source,clojure]
328+ ----
329+ ;; I am a code block that is skipped by test-doc-blocks
330+ (maybe some code that won't compile ...
331+ ----
332+ ....
333+
334+ Then you could choose to not skip a code block like so:
335+ [source,asciidoc]
336+ ....
337+ //#:test-doc-blocks{:skip false}
338+ [source,clojure]
339+ ----
340+ ;; A test will be generated for this code block
341+ (apply str (interpose " " ["don't" "skip" "me!"]))
342+ ;; => "don't skip me!"
343+ ----
344+ ....
345+
346+ To have test-doc-blocks stop skipping code blocks by default:
347+
348+ [source,asciidoc]
349+ ....
350+ //#:test-doc-blocks{:skip false :apply :all-next}
351+ ....
352+
353+ And now test-doc-blocks will generate tests for subsequent code blocks.
354+
355+ [source,asciidoc]
356+ ....
357+ [source,clojure]
358+ ----
359+ ;; A test will be generated for this code block
360+ (apply str (interpose " " ["test" "me" "by" "default"]))
361+ ;; => "test me by default"
362+ ----
363+ ....
364+
304365// Notice the use of CommonMark syntax for section title here, we test that we recognize this syntax
305366## Section Titles
306367Test-doc-blocks will try to give each test block some context by including its filename, section title and starting line number.
@@ -324,7 +385,7 @@ And this level 2 type
324385---------------------
325386----
326387
327- This code block should include "Section Titles" as part of the context for its generated test.
388+ This code block should include "Section Titles" (the actual title of this section) as part of the context for its generated test.
328389
329390[source,markdown]
330391....
0 commit comments