rspec-documentation 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/rspec/documentation/version.rb +1 -1
- data/lib/rspec_documentation/configuration.rb +3 -0
- data/lib/rspec_documentation/formatters/html.rb +3 -1
- data/lib/rspec_documentation/parsed_document.rb +1 -1
- data/lib/rspec_documentation/rspec/failure.rb +3 -3
- data/lib/templates/layout.css.erb +3 -1
- data/rspec-documentation/pages/060-Configuration/050-Consistent Height.md +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da04d0bb8e452ebcf2858bff1c50b704099bd28ef683e4bd18759952195b8543
|
4
|
+
data.tar.gz: db7bb967b2c35fd6b972f3ff295561e1731ade67d07c9d6132f797504d855cc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 733742f420606fab2d6cb27ab9c180e2c30260184e903314337ae994453de0d3863e00df34407f613103d9bef55697fea044fde7e436018e50fdf39a68f41e02
|
7
|
+
data.tar.gz: 4271936018c835d3e6af24d8a1f5329a3b229b89528d53e04cba2a44e42b459f49a4fde648820a9e1e9a0710fe692db891ecc866d5a5a9767f7ad9098c30f330
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,9 +4,12 @@ module RSpecDocumentation
|
|
4
4
|
# Configures the rspec-documentation gem, allows setting a context that makes values available to each example.
|
5
5
|
class Configuration
|
6
6
|
attr_reader :hooks
|
7
|
+
attr_accessor :consistent_height, :max_height
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@context_defined = false
|
11
|
+
@consistent_height = false
|
12
|
+
@max_height = '30rem'
|
10
13
|
@hooks = {}
|
11
14
|
end
|
12
15
|
|
@@ -5,6 +5,8 @@ module RSpecDocumentation
|
|
5
5
|
# Beautifies HTML received from a `subject`, renders the raw subject to be inserted directly
|
6
6
|
# into the output document.
|
7
7
|
class Html
|
8
|
+
DOCTYPE_TAG = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ' \
|
9
|
+
'"http://www.w3.org/TR/REC-html40/loose.dtd">'
|
8
10
|
def initialize(subject:)
|
9
11
|
@subject = subject
|
10
12
|
end
|
@@ -16,7 +18,7 @@ module RSpecDocumentation
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def rendered_output
|
19
|
-
subject
|
21
|
+
subject&.to_s&.sub(DOCTYPE_TAG, '')
|
20
22
|
end
|
21
23
|
|
22
24
|
def render_raw?
|
@@ -18,7 +18,7 @@ module RSpecDocumentation
|
|
18
18
|
def execute_and_substitute_examples!
|
19
19
|
specs.each do |spec|
|
20
20
|
spec.run
|
21
|
-
|
21
|
+
next failures << spec.failure unless spec.failure.nil?
|
22
22
|
|
23
23
|
spec.parent.children[spec.index] = spec_element(spec)
|
24
24
|
end
|
@@ -39,9 +39,9 @@ module RSpecDocumentation
|
|
39
39
|
|
40
40
|
def formatted_backtrace
|
41
41
|
cause.backtrace
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
&.take_while { |line| line.start_with?(Dir.pwd) }
|
43
|
+
&.map { |line| paintbrush { red " #{line.sub("#{Dir.pwd}/", '')}" } }
|
44
|
+
&.join("\n")
|
45
45
|
end
|
46
46
|
|
47
47
|
def indented(text)
|
@@ -7,6 +7,7 @@
|
|
7
7
|
MonokaiSublime, Pastie, ThankfulEyes, Tulip */
|
8
8
|
<%= Rouge::Theme.find('molokai').render(scope: '.highlight') %>
|
9
9
|
|
10
|
+
<% if RSpecDocumentation.configuration.consistent_height %>
|
10
11
|
/* https://stackoverflow.com/a/61587938 */
|
11
12
|
.consistent-height .tab-content {
|
12
13
|
display: flex;
|
@@ -22,6 +23,7 @@
|
|
22
23
|
.consistent-height .tab-content > .active {
|
23
24
|
visibility: visible;
|
24
25
|
}
|
26
|
+
<% end %>
|
25
27
|
|
26
28
|
@keyframes fade-in {
|
27
29
|
from {
|
@@ -88,7 +90,7 @@ h1.title a {
|
|
88
90
|
|
89
91
|
.code {
|
90
92
|
font-family: monospace;
|
91
|
-
max-height:
|
93
|
+
max-height: <%= RSpecDocumentation.configuration.max_height %>;
|
92
94
|
overflow-y: auto;
|
93
95
|
}
|
94
96
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Consistent Height
|
2
|
+
|
3
|
+
Depending on your preferences, you may want to force a consistent height for tab content in each rendered example. To configure this option, set `config.consistent_height` to `true` or `false`. The default is `false`.
|
4
|
+
|
5
|
+
Setting a consistent height on output prevents content from jumping when each tab is opened but it can also result in quite large gaps beneath examples.
|
6
|
+
|
7
|
+
The max height for each example can also be configured by setting `config.max_height`, with the default being `30rem`.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# rspec-documentation/spec_helper.rb
|
11
|
+
|
12
|
+
RSpec::Documentation.conifgure do |config|
|
13
|
+
config.consistent_height = true # Default: false
|
14
|
+
config.max_height = '20rem' # Default: 30rem
|
15
|
+
end
|
16
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-documentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlbeautifier
|
@@ -233,6 +233,7 @@ files:
|
|
233
233
|
- rspec-documentation/pages/060-Configuration/020-Build Paths.md
|
234
234
|
- rspec-documentation/pages/060-Configuration/030-Attribution.md
|
235
235
|
- rspec-documentation/pages/060-Configuration/040-Hooks.md
|
236
|
+
- rspec-documentation/pages/060-Configuration/050-Consistent Height.md
|
236
237
|
- rspec-documentation/pages/070-Publishing.md
|
237
238
|
- rspec-documentation/pages/500-License.md
|
238
239
|
- rspec-documentation/spec_helper.rb
|