rspec-documentation 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eb4258635900a3617ddf6ab4cdfb7fe1d1cba62fbd8231f11437cf9b9734c6b
4
- data.tar.gz: f5db6165cfd08d759765d4e50a0398bfdb0ab99dee84567fd535bd97cd30f0a4
3
+ metadata.gz: da04d0bb8e452ebcf2858bff1c50b704099bd28ef683e4bd18759952195b8543
4
+ data.tar.gz: db7bb967b2c35fd6b972f3ff295561e1731ade67d07c9d6132f797504d855cc3
5
5
  SHA512:
6
- metadata.gz: e25685a33fb2cc2bace75aa20c72f2b33407f2edec5a14840163cced2662fd852d3c87f8e4b31741b15825311365348f22cf5754b1850ddec1196bba64181a02
7
- data.tar.gz: 3678422ca81bc09c5cd68db061b6a81746d21fb848824e229369721e727ac01f4fa4e517263ef9d47b8f1457f336d7dd6a0fdea0ee6ed63e498d62995f7c4102
6
+ metadata.gz: 733742f420606fab2d6cb27ab9c180e2c30260184e903314337ae994453de0d3863e00df34407f613103d9bef55697fea044fde7e436018e50fdf39a68f41e02
7
+ data.tar.gz: 4271936018c835d3e6af24d8a1f5329a3b229b89528d53e04cba2a44e42b459f49a4fde648820a9e1e9a0710fe692db891ecc866d5a5a9767f7ad9098c30f330
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-documentation (0.0.6)
4
+ rspec-documentation (0.0.7)
5
5
  htmlbeautifier (~> 1.4)
6
6
  kramdown (~> 2.4)
7
7
  kramdown-parser-gfm (~> 1.1)
data/README.md CHANGED
@@ -13,7 +13,7 @@ There is no _DSL_ to learn and vanilla _RSpec_ examples are used to generate inp
13
13
 
14
14
  The following is an example _Markdown_ file.
15
15
 
16
- ````console
16
+ ````markdown
17
17
  # An example test
18
18
 
19
19
  This is a very simple test:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Documentation
5
- VERSION = '0.0.6'
5
+ VERSION = '0.0.7'
6
6
  end
7
7
  end
@@ -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
- break failures << spec.failure unless spec.failure.nil?
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
- .take_while { |line| line.start_with?(Dir.pwd) }
43
- .map { |line| paintbrush { red " #{line.sub("#{Dir.pwd}/", '')}" } }
44
- .join("\n")
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: 30rem;
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.6
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-10 00:00:00.000000000 Z
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