Skip to content

Commit e336406

Browse files
committed
docs: review, fix link, clarify
1 parent cfe273e commit e336406

18 files changed

+51
-45
lines changed

doc/example.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
= AsciiDoc test-doc-blocks Example
22
:toc:
33

4+
If you are writing your docs in AsciiDoc, read on.
5+
If you are writing your docs in CommonMark, you'll want to read link:/doc/example.md[CommonMark test-doc-blocks Example] instead.
6+
47
Test-doc-blocks will find Clojure source code blocks in your `.adoc` files and generate tests for them.
58

6-
You tell test-doc-blocks which files to scan on the link:/01-user-guide.adoc#command-line[command line].
9+
You tell test-doc-blocks which files to scan on the link:/doc/01-user-guide.adoc#command-line[command line].
710

811
== The Basics
912
Test-doc-blocks generates a test for each Clojure code block.

doc/example.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
CommonMark test-doc-blocks Example
22
==========
33

4+
If you are writing your docs in CommonMark, read on.
5+
If you are writing your docs in AsciiDoc, you'll want to read [AsciiDoc test-doc-blocks Example](/doc/example.adoc) instead.
6+
47
Test-doc-blocks will find Clojure source code blocks in your docstrings and `.md` files and generate tests for them.
58

6-
You tell test-doc-blocks which files to scan on the [command line](/01-user-guide.adoc#command-line).
9+
You tell test-doc-blocks which files to scan on the [command line](/doc/01-user-guide.adoc#command-line).
710

811
The Basics
912
--

test-resources/expected/test-doc-blocks/test/example_adoc_cljs_test.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
(:import goog.events.EventType))
77

88
(clojure.test/deftest block-0001
9-
(clojure.test/testing "doc/example.adoc - line 242 - Specifying The Platform - :platform"
9+
(clojure.test/testing "doc/example.adoc - line 245 - Specifying The Platform - :platform"
1010
;; this code block will generate a test under example-adoc-cljs-test ns to a .cljs file
1111

1212
nil

test-resources/expected/test-doc-blocks/test/example_adoc_inline_ns_test.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
(:import #?@(:clj [java.util.List java.util.Queue java.util.Set] :cljs [goog.math.Long goog.math.Vec2 goog.math.Vec3])))
1111

1212
(clojure.test/deftest block-0001
13-
(clojure.test/testing "doc/example.adoc - line 364 - Inline requires and imports"
13+
(clojure.test/testing "doc/example.adoc - line 367 - Inline requires and imports"
1414
;; Stick the basics for requires, shorthand notation isn't supported
1515

1616
;; Some examples:

test-resources/expected/test-doc-blocks/test/example_adoc_inline_refer_clojure_test.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[clojure.edn :refer [read-string]]))
88

99
(clojure.test/deftest block-0001
10-
(clojure.test/testing "doc/example.adoc - line 394 - Inline refer-clojure"
10+
(clojure.test/testing "doc/example.adoc - line 397 - Inline refer-clojure"
1111
;; a contrived example that uses uses clojure.edn/read-string in place of clojure.core/read-string
1212
;; and excludes clojure.core/for
1313
nil

test-resources/expected/test-doc-blocks/test/example_adoc_new_ns/ns1_test.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[clojure.string :as string]))
77

88
(clojure.test/deftest block-0001
9-
(clojure.test/testing "doc/example.adoc - line 210 - Specifying Test Namespace - :test-ns"
9+
(clojure.test/testing "doc/example.adoc - line 213 - Specifying Test Namespace - :test-ns"
1010
;; this code block will generate tests under example-adoc-new-ns.ns1-test
1111

1212
nil

test-resources/expected/test-doc-blocks/test/example_adoc_new_ns_test.cljc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#?(:clj lread.test-doc-blocks.runtime)))
66

77
(clojure.test/deftest block-0001
8-
(clojure.test/testing "doc/example.adoc - line 194 - Specifying Test Namespace - :test-ns"
8+
(clojure.test/testing "doc/example.adoc - line 197 - Specifying Test Namespace - :test-ns"
99
;; this code block will generate tests under example-adoc-new-ns-test
1010

1111
(clojure.test/is (= '8 (* 2 4)))))

test-resources/expected/test-doc-blocks/test/example_adoc_out_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
lread.test-doc-blocks.runtime))
55

66
(clojure.test/deftest block-0001
7-
(clojure.test/testing "doc/example.adoc - line 61 - The Basics"
7+
(clojure.test/testing "doc/example.adoc - line 64 - The Basics"
88
;; A snippit of Clojure where we check result, stderr and stdout
99
(let [[actual actual-out actual-err] (lread.test-doc-blocks.runtime/eval-capture (do
1010
(println "To out I go")

test-resources/expected/test-doc-blocks/test/example_adoc_out_test.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[lread.test-doc-blocks.runtime :include-macros]))
55

66
(clojure.test/deftest block-0001
7-
(clojure.test/testing "doc/example.adoc - line 74 - The Basics"
7+
(clojure.test/testing "doc/example.adoc - line 77 - The Basics"
88
;; And the same idea for ClojureScript
99
(let [[actual actual-out actual-err] (lread.test-doc-blocks.runtime/eval-capture (do
1010
(println "To out I go")

test-resources/expected/test-doc-blocks/test/example_adoc_test.cljc

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
[clojure.string :as string]))
1010

1111
(clojure.test/deftest block-0001
12-
(clojure.test/testing "doc/example.adoc - line 15 - The Basics"
12+
(clojure.test/testing "doc/example.adoc - line 18 - The Basics"
1313
;; Some valid Clojure code here
1414

1515
; test-doc-blocks dummy assertion to appease tools that fail on no assertions
1616
(clojure.test/is (= '"dummy" "dummy"))))
1717

1818
(clojure.test/deftest block-0002
19-
(clojure.test/testing "doc/example.adoc - line 27 - The Basics"
19+
(clojure.test/testing "doc/example.adoc - line 30 - The Basics"
2020
;; test-doc-block will generate an assertion to verify (+ 1 2 3) evaluates to the expected 6
2121
(clojure.test/is (= '6 (+ 1 2 3)))))
2222

2323
(clojure.test/deftest block-0003
24-
(clojure.test/testing "doc/example.adoc - line 36 - The Basics"
24+
(clojure.test/testing "doc/example.adoc - line 39 - The Basics"
2525
;; test-doc-blocks will generate an assertion to verify (+ 1 2 3 4) evaluates to the expected 10
2626
(clojure.test/is (= '10 (+ 1 2 3 4)))
2727
;; it understands that Clojure and ClojureScript can evaluate differently
@@ -36,7 +36,7 @@
3636
(clojure.test/is (= ["is this right?" "or not?"] (clojure.string/split-lines actual-out))))))
3737

3838
(clojure.test/deftest block-0004
39-
(clojure.test/testing "doc/example.adoc - line 89 - The Basics"
39+
(clojure.test/testing "doc/example.adoc - line 92 - The Basics"
4040
(->> "here we are only checking that our code will run"
4141
reverse
4242
reverse
@@ -46,7 +46,7 @@
4646
(clojure.test/is (= '"dummy" "dummy"))))
4747

4848
(clojure.test/deftest block-0005
49-
(clojure.test/testing "doc/example.adoc - line 151 - Wrap Test in a Reader Conditional - :reader-cond"
49+
(clojure.test/testing "doc/example.adoc - line 154 - Wrap Test in a Reader Conditional - :reader-cond"
5050
#?(:clj
5151
(do
5252
;; This code block will be wrapped in a #?(:clj (do ...))
@@ -59,7 +59,7 @@ nil
5959
(clojure.test/is (= '"dummy" "dummy"))))
6060

6161
(clojure.test/deftest block-0006
62-
(clojure.test/testing "doc/example.adoc - line 163 - Wrap Test in a Reader Conditional - :reader-cond"
62+
(clojure.test/testing "doc/example.adoc - line 166 - Wrap Test in a Reader Conditional - :reader-cond"
6363
#?(:cljs
6464
(do
6565
;; This code block will be wrapped in a #?(:cljs (do ...))
@@ -71,18 +71,18 @@ nil
7171
(clojure.test/is (= '"dummy" "dummy"))))
7272

7373
(clojure.test/deftest block-0007
74-
(clojure.test/testing "doc/example.adoc - line 173 - Wrap Test in a Reader Conditional - :reader-cond"
74+
(clojure.test/testing "doc/example.adoc - line 176 - Wrap Test in a Reader Conditional - :reader-cond"
7575
;; And our generic cljc code:
7676
(clojure.test/is (= '[1 2 3] (read-string "[1 2 3]")))))
7777

7878
(clojure.test/deftest ^:testing-meta123 block-0008
79-
(clojure.test/testing "doc/example.adoc - line 273 - Specifying Metadata - :meta"
79+
(clojure.test/testing "doc/example.adoc - line 276 - Specifying Metadata - :meta"
8080
;; this code block will generate a test with metadata {:testing-meta123 true}
8181

8282
(clojure.test/is (= '[[:a 1]] (into [] {:a 1})))))
8383

8484
(clojure.test/deftest ^{:testing-meta123 "a-specific-value", :testing-meta789 :yip} block-0009
85-
(clojure.test/testing "doc/example.adoc - line 286 - Specifying Metadata - :meta"
85+
(clojure.test/testing "doc/example.adoc - line 289 - Specifying Metadata - :meta"
8686
;; this code block will generate a test with metadata:
8787
;; {:testing-meta123 "a-specific-value" :testing-meta789 :yip}
8888

@@ -93,32 +93,32 @@ nil
9393
["oh" "my" "goodness"])))))
9494

9595
(clojure.test/deftest block-0010
96-
(clojure.test/testing "doc/example.adoc - line 326 - Section Titles"
96+
(clojure.test/testing "doc/example.adoc - line 329 - Section Titles"
9797
nil
9898

9999
(clojure.test/is (= '"well!how!about!that" (string/join "!" ["well" "how" "about" "that"])))))
100100

101101
(clojure.test/deftest block-0011
102-
(clojure.test/testing "doc/example.adoc - line 342 - Support for CommonMark Code Block Syntax"
102+
(clojure.test/testing "doc/example.adoc - line 345 - Support for CommonMark Code Block Syntax"
103103
nil
104104

105105
(clojure.test/is (= '{1 :a, 2 :b} (set/map-invert {:a 1 :b 2})))))
106106

107107
(clojure.test/deftest block-0012
108-
(clojure.test/testing "doc/example.adoc - line 430 - Test Run Order"
108+
(clojure.test/testing "doc/example.adoc - line 433 - Test Run Order"
109109
(defn fn-block1 [] (+ 1 2 3))
110110

111111
; test-doc-blocks dummy assertion to appease tools that fail on no assertions
112112
(clojure.test/is (= '"dummy" "dummy"))))
113113

114114
(clojure.test/deftest block-0013
115-
(clojure.test/testing "doc/example.adoc - line 436 - Test Run Order"
115+
(clojure.test/testing "doc/example.adoc - line 439 - Test Run Order"
116116
(def var-block2 (+ 4 5 6))
117117

118118
(clojure.test/is (= '21 (+ (fn-block1) var-block2)))))
119119

120120
(clojure.test/deftest block-0014
121-
(clojure.test/testing "doc/example.adoc - line 445 - Test Run Order"
121+
(clojure.test/testing "doc/example.adoc - line 448 - Test Run Order"
122122
(clojure.test/is (= '100 (+ (fn-block1) var-block2 79)))))
123123

124124
(defn test-ns-hook [] (block-0001) (block-0002) (block-0003) (block-0004) (block-0005) (block-0006) (block-0007) (block-0008) (block-0009) (block-0010) (block-0011) (block-0012) (block-0013) (block-0014))

0 commit comments

Comments
 (0)