qed 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.md +11 -0
- data/demo/14_comment_mode.md +26 -0
- data/demo/samples/yard.rb +19 -0
- data/lib/qed/cli/qed.rb +1 -1
- data/lib/qed/parser.rb +31 -1
- data/lib/qed/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0919807f2f9306df109a4e07d4a8af55e2189c2ffa9aa4c28e0ca3d522e53699'
|
|
4
|
+
data.tar.gz: 3c3a57484b48d528a7a92d9d51c6fb2b1bdffffb979be268479503cdec7f5fb4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ef62a1cca8766764df08ebc9ed14841d4171768ff3d59fb072ebaf7c491860da59f681911a051b9bbd39d02282a2f704988533759ec2fe904dbd698a857e725
|
|
7
|
+
data.tar.gz: 903f2cfabdbbbfb9aae12251d1a2a84c44a34b6d46e2fd651a2b94841a27ca48ae56e7da697e3bf4e7ce6eee1e40b993bcec8998f96ace011e540b37b8c22302
|
data/HISTORY.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# RELEASE HISTORY
|
|
2
2
|
|
|
3
|
+
## 3.0.1 | 2026-11-13
|
|
4
|
+
|
|
5
|
+
Bug Fixes:
|
|
6
|
+
|
|
7
|
+
* In comment mode (`--comment`), the indented lines that continue a YARD
|
|
8
|
+
tag, such as the second line of a `@deprecated` or `@return`, are now
|
|
9
|
+
read as the tag's text instead of being run as example code. The code
|
|
10
|
+
under an `@example` tag still runs.
|
|
11
|
+
* Each `-I` option now adds to the load path. Before, only the last one
|
|
12
|
+
took effect, so `-Ilib/core -Ilib/standard` lost `lib/core`.
|
|
13
|
+
|
|
3
14
|
## 3.0.0 | 2026-03-31
|
|
4
15
|
|
|
5
16
|
Major modernization release after a long hiatus.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Comment Mode
|
|
2
|
+
|
|
3
|
+
With the `--comment` option, QED runs the examples in the comments of
|
|
4
|
+
a Ruby script, the indented lines, as it would a demo's.
|
|
5
|
+
|
|
6
|
+
sample = File.dirname(__FILE__) + '/samples/yard.rb'
|
|
7
|
+
demo = QED::Demo.new(sample, :mode=>:comment)
|
|
8
|
+
code = demo.steps.select(&:code?).map { |step| step.code.strip }
|
|
9
|
+
|
|
10
|
+
A plain example runs, and so does the code under an `@example` tag.
|
|
11
|
+
|
|
12
|
+
code.assert.include?("YardSample.double(2).must_return(4)")
|
|
13
|
+
code.assert.include?("YardSample.double(1.5).must_return(3.0)")
|
|
14
|
+
|
|
15
|
+
## YARD Tags
|
|
16
|
+
|
|
17
|
+
YARD continues a tag's text on the indented lines after it. Those
|
|
18
|
+
lines are part of the tag, not example code, so they don't run.
|
|
19
|
+
|
|
20
|
+
code.grep(/Scheduled/).assert.empty?
|
|
21
|
+
code.grep(/times two/).assert.empty?
|
|
22
|
+
|
|
23
|
+
The tag's text is kept with the explanation instead.
|
|
24
|
+
|
|
25
|
+
text = demo.steps.map(&:explain).join
|
|
26
|
+
text.assert.include?("Scheduled for removal next year.")
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module YardSample
|
|
2
|
+
|
|
3
|
+
# Doubles a number.
|
|
4
|
+
#
|
|
5
|
+
# YardSample.double(2) #=> 4
|
|
6
|
+
#
|
|
7
|
+
# @deprecated Use #twice instead.
|
|
8
|
+
# Scheduled for removal next year.
|
|
9
|
+
#
|
|
10
|
+
# @example Doubling a float
|
|
11
|
+
# YardSample.double(1.5) #=> 3.0
|
|
12
|
+
#
|
|
13
|
+
# @return [Numeric] The number,
|
|
14
|
+
# times two.
|
|
15
|
+
def self.double(n)
|
|
16
|
+
n * 2
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
data/lib/qed/cli/qed.rb
CHANGED
|
@@ -105,7 +105,7 @@ module QED
|
|
|
105
105
|
options[:mode] = :comment
|
|
106
106
|
end
|
|
107
107
|
opt.on('--loadpath', "-I PATH", "add paths to $LOAD_PATH") do |paths|
|
|
108
|
-
options[:loadpath] = paths.split(/[:;]/).map{|d| File.expand_path(d)}
|
|
108
|
+
options[:loadpath] = (options[:loadpath] || []) + paths.split(/[:;]/).map{|d| File.expand_path(d)}
|
|
109
109
|
end
|
|
110
110
|
opt.on('--require', "-r LIB", "require feature (immediately)") do |paths|
|
|
111
111
|
requires = paths.split(/[:;]/)
|
data/lib/qed/parser.rb
CHANGED
|
@@ -62,10 +62,15 @@ module QED
|
|
|
62
62
|
# TODO: It would be nice if we could get ther require statement for the
|
|
63
63
|
# comment mode to be relative to an actual loadpath.
|
|
64
64
|
|
|
65
|
+
# A YARD tag or directive at the start of a comment, as in
|
|
66
|
+
# `# @deprecated Use #bar instead.`
|
|
67
|
+
YARD_TAG = /\A@!?((?:\w\.?)+)/
|
|
68
|
+
|
|
65
69
|
# Parse comment lines into a format that the parse method can use.
|
|
66
70
|
def parse_comment_lines
|
|
67
71
|
ruby_omit = false
|
|
68
72
|
rdoc_omit = false
|
|
73
|
+
yard_tag = nil
|
|
69
74
|
lines = [
|
|
70
75
|
[0, "Load #{File.basename(file)} script.\n"],
|
|
71
76
|
[0, "\n"],
|
|
@@ -87,8 +92,12 @@ module QED
|
|
|
87
92
|
when /^\s*##/
|
|
88
93
|
## skip internal comments
|
|
89
94
|
when /^\s*\#/
|
|
90
|
-
|
|
95
|
+
unless (ruby_omit or rdoc_omit)
|
|
96
|
+
text, yard_tag = yard_comment(l.lstrip.sub(/^\#\ ?/, ''), yard_tag)
|
|
97
|
+
lines << [index, text]
|
|
98
|
+
end
|
|
91
99
|
else
|
|
100
|
+
yard_tag = nil
|
|
92
101
|
lines << [index, "\n"] unless lines.last[1] == "\n" unless (ruby_omit or rdoc_omit)
|
|
93
102
|
end
|
|
94
103
|
index += 1
|
|
@@ -96,6 +105,27 @@ module QED
|
|
|
96
105
|
lines
|
|
97
106
|
end
|
|
98
107
|
|
|
108
|
+
# YARD continues a tag's text on the indented lines after it, across
|
|
109
|
+
# blank lines, until a line that is not indented. Those lines are part
|
|
110
|
+
# of the tag, not example code, so they are passed on unindented. The
|
|
111
|
+
# exception is `@example`, whose lines are code.
|
|
112
|
+
#
|
|
113
|
+
# @return [Array(String, String)] The comment text, and the name of the
|
|
114
|
+
# tag it belongs to, if any.
|
|
115
|
+
def yard_comment(text, tag)
|
|
116
|
+
if md = YARD_TAG.match(text)
|
|
117
|
+
[text, md[1]]
|
|
118
|
+
elsif tag.nil? || text.strip.empty?
|
|
119
|
+
[text, tag]
|
|
120
|
+
elsif !text.start_with?(' ', "\t")
|
|
121
|
+
[text, nil]
|
|
122
|
+
elsif tag == 'example'
|
|
123
|
+
[text, tag]
|
|
124
|
+
else
|
|
125
|
+
[text.lstrip, tag]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
99
129
|
# Parse demo file into steps.
|
|
100
130
|
def parse
|
|
101
131
|
steps = []
|
data/lib/qed/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: qed
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- trans
|
|
@@ -92,6 +92,7 @@ files:
|
|
|
92
92
|
- demo/10_constant_lookup.md
|
|
93
93
|
- demo/11_embedded_rules.md
|
|
94
94
|
- demo/13_fenced_code_blocks.md
|
|
95
|
+
- demo/14_comment_mode.md
|
|
95
96
|
- demo/99_issues/02_topcode.md
|
|
96
97
|
- demo/applique/ae.rb
|
|
97
98
|
- demo/applique/constant.rb
|
|
@@ -104,6 +105,7 @@ files:
|
|
|
104
105
|
- demo/helpers/toplevel.rb
|
|
105
106
|
- demo/samples/data.txt
|
|
106
107
|
- demo/samples/table.yml
|
|
108
|
+
- demo/samples/yard.rb
|
|
107
109
|
- lib/qed.rb
|
|
108
110
|
- lib/qed/applique.rb
|
|
109
111
|
- lib/qed/cli.rb
|