rspec-documentation 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -0
  3. data/Gemfile.lock +3 -3
  4. data/Makefile +9 -0
  5. data/README.md +17 -21
  6. data/exe/rspec-documentation +5 -1
  7. data/lib/rspec/documentation/version.rb +1 -1
  8. data/lib/rspec/documentation.rb +1 -51
  9. data/lib/rspec_documentation/configuration.rb +17 -4
  10. data/lib/rspec_documentation/document.rb +17 -5
  11. data/lib/rspec_documentation/documentation.rb +85 -0
  12. data/lib/rspec_documentation/formatters/ansi.rb +44 -0
  13. data/lib/rspec_documentation/formatters/html.rb +31 -0
  14. data/lib/rspec_documentation/formatters/json.rb +32 -0
  15. data/lib/rspec_documentation/formatters/ruby.rb +31 -0
  16. data/lib/rspec_documentation/formatters/yaml.rb +36 -0
  17. data/lib/rspec_documentation/formatters.rb +20 -0
  18. data/lib/rspec_documentation/html_element.rb +21 -18
  19. data/lib/rspec_documentation/javascript_bundle.rb +17 -0
  20. data/lib/rspec_documentation/page_collection.rb +24 -9
  21. data/lib/rspec_documentation/page_tree.rb +16 -8
  22. data/lib/rspec_documentation/page_tree_element.rb +31 -9
  23. data/lib/rspec_documentation/parsed_document.rb +5 -3
  24. data/lib/rspec_documentation/project_initialization.rb +52 -0
  25. data/lib/rspec_documentation/rspec/failure.rb +20 -5
  26. data/lib/rspec_documentation/rspec.rb +0 -2
  27. data/lib/rspec_documentation/spec.rb +58 -12
  28. data/lib/rspec_documentation/stylesheet_bundle.rb +17 -0
  29. data/lib/rspec_documentation/summary.rb +87 -0
  30. data/lib/rspec_documentation/util.rb +12 -0
  31. data/lib/rspec_documentation.rb +16 -3
  32. data/lib/templates/000-Introduction.md.erb +35 -0
  33. data/lib/templates/010-Usage.md.erb +3 -0
  34. data/lib/templates/500-License.md.erb +3 -0
  35. data/lib/templates/bootstrap.js.erb +7 -0
  36. data/lib/templates/footer.html.erb +5 -0
  37. data/lib/templates/header.html.erb +16 -3
  38. data/lib/templates/layout.css.erb +381 -2
  39. data/lib/templates/layout.html.erb +13 -82
  40. data/lib/templates/layout.js.erb +67 -0
  41. data/lib/templates/modal_spec.html.erb +51 -0
  42. data/lib/templates/moon.svg.erb +1 -0
  43. data/lib/templates/script_tags.html.erb +1 -0
  44. data/lib/templates/stylesheet_links.html.erb +1 -0
  45. data/lib/templates/sun.svg.erb +1 -0
  46. data/lib/templates/tabbed_spec.html.erb +12 -49
  47. data/lib/templates/themes/bootstrap.min.css +11 -0
  48. data/lib/templates/themes/cerulean.css +5 -6
  49. data/lib/templates/themes/cosmo.css +5 -6
  50. data/lib/templates/themes/cyborg.css +5 -6
  51. data/lib/templates/themes/darkly.css +5 -6
  52. data/lib/templates/themes/flatly.css +5 -6
  53. data/lib/templates/themes/journal.css +5 -6
  54. data/lib/templates/themes/litera.css +5 -6
  55. data/lib/templates/themes/lumen.css +5 -6
  56. data/lib/templates/themes/lux.css +5 -6
  57. data/lib/templates/themes/materia.css +5 -6
  58. data/lib/templates/themes/minty.css +5 -6
  59. data/lib/templates/themes/morph.css +5 -6
  60. data/lib/templates/themes/pulse.css +5 -6
  61. data/lib/templates/themes/quartz.css +5 -6
  62. data/lib/templates/themes/sandstone.css +5 -6
  63. data/lib/templates/themes/simplex.css +5 -6
  64. data/lib/templates/themes/sketchy.css +5 -6
  65. data/lib/templates/themes/slate.css +5 -6
  66. data/lib/templates/themes/solar.css +5 -6
  67. data/lib/templates/themes/spacelab.css +5 -6
  68. data/lib/templates/themes/superhero.css +5 -6
  69. data/lib/templates/themes/united.css +5 -6
  70. data/lib/templates/themes/vapor.css +5 -6
  71. data/lib/templates/themes/yeti.css +5 -6
  72. data/lib/templates/themes/zephyr.css +5 -6
  73. data/rspec-documentation/pages/000-Introduction/000-Quickstart.md +17 -0
  74. data/rspec-documentation/pages/000-Introduction.md +14 -30
  75. data/rspec-documentation/pages/010-File System/000-Ordering.md +1 -1
  76. data/rspec-documentation/pages/010-File System/010-Documentation Bundle.md +9 -0
  77. data/rspec-documentation/pages/010-File System.md +1 -1
  78. data/rspec-documentation/pages/020-Running Tests.md +41 -0
  79. data/rspec-documentation/pages/030-Examples/010-Basic.md +51 -0
  80. data/rspec-documentation/pages/030-Examples/020-HTML.md +45 -0
  81. data/rspec-documentation/pages/030-Examples/030-ANSI.md +33 -0
  82. data/rspec-documentation/pages/030-Examples/040-JSON.md +39 -0
  83. data/rspec-documentation/pages/030-Examples/050-YAML.md +40 -0
  84. data/rspec-documentation/pages/030-Examples.md +7 -0
  85. data/rspec-documentation/pages/040-Spec Helper.md +11 -0
  86. data/rspec-documentation/pages/050-Linking.md +20 -0
  87. data/rspec-documentation/pages/060-Configuration/010-Context.md +26 -0
  88. data/rspec-documentation/pages/060-Configuration/020-Build Paths.md +33 -0
  89. data/rspec-documentation/pages/060-Configuration/030-Attribution.md +23 -0
  90. data/rspec-documentation/pages/060-Configuration.md +13 -0
  91. data/rspec-documentation/pages/070-Publishing.md +13 -0
  92. data/rspec-documentation/pages/500-License.md +11 -0
  93. data/rspec-documentation/spec_helper.rb +8 -0
  94. data/rspec-documentation.gemspec +2 -1
  95. metadata +46 -12
  96. data/lib/rspec_documentation/ansi_html.rb +0 -28
  97. data/lib/rspec_documentation/context.rb +0 -44
  98. data/lib/rspec_documentation/rspec/example_group.rb +0 -26
  99. data/lib/rspec_documentation/rspec/reporter.rb +0 -45
  100. data/rspec-documentation/pages/010-File System/010-Standalone Directories.md +0 -17
  101. data/rspec-documentation/pages/010-File System/020-Standalone Directory/Example Page.md +0 -3
  102. data/rspec-documentation/pages/020-Running Specs.md +0 -11
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.2
4
+ version: 0.0.4
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-05-26 00:00:00.000000000 Z
11
+ date: 2023-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlbeautifier
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.1
61
+ version: 0.1.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.1.1
68
+ version: 0.1.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +128,46 @@ files:
128
128
  - lib/rspec/documentation.rb
129
129
  - lib/rspec/documentation/version.rb
130
130
  - lib/rspec_documentation.rb
131
- - lib/rspec_documentation/ansi_html.rb
132
131
  - lib/rspec_documentation/configuration.rb
133
- - lib/rspec_documentation/context.rb
134
132
  - lib/rspec_documentation/document.rb
133
+ - lib/rspec_documentation/documentation.rb
134
+ - lib/rspec_documentation/formatters.rb
135
+ - lib/rspec_documentation/formatters/ansi.rb
136
+ - lib/rspec_documentation/formatters/html.rb
137
+ - lib/rspec_documentation/formatters/json.rb
138
+ - lib/rspec_documentation/formatters/ruby.rb
139
+ - lib/rspec_documentation/formatters/yaml.rb
135
140
  - lib/rspec_documentation/html_element.rb
141
+ - lib/rspec_documentation/javascript_bundle.rb
136
142
  - lib/rspec_documentation/markdown_renderer.rb
137
143
  - lib/rspec_documentation/page_collection.rb
138
144
  - lib/rspec_documentation/page_tree.rb
139
145
  - lib/rspec_documentation/page_tree_element.rb
140
146
  - lib/rspec_documentation/parsed_document.rb
147
+ - lib/rspec_documentation/project_initialization.rb
141
148
  - lib/rspec_documentation/rspec.rb
142
- - lib/rspec_documentation/rspec/example_group.rb
143
149
  - lib/rspec_documentation/rspec/failure.rb
144
- - lib/rspec_documentation/rspec/reporter.rb
145
150
  - lib/rspec_documentation/spec.rb
151
+ - lib/rspec_documentation/stylesheet_bundle.rb
152
+ - lib/rspec_documentation/summary.rb
146
153
  - lib/rspec_documentation/util.rb
147
154
  - lib/tasks/rspec/documentation/generate.rake
155
+ - lib/templates/000-Introduction.md.erb
156
+ - lib/templates/010-Usage.md.erb
157
+ - lib/templates/500-License.md.erb
158
+ - lib/templates/bootstrap.js.erb
148
159
  - lib/templates/footer.html.erb
149
160
  - lib/templates/header.html.erb
150
161
  - lib/templates/layout.css.erb
151
162
  - lib/templates/layout.html.erb
163
+ - lib/templates/layout.js.erb
164
+ - lib/templates/modal_spec.html.erb
165
+ - lib/templates/moon.svg.erb
166
+ - lib/templates/script_tags.html.erb
167
+ - lib/templates/stylesheet_links.html.erb
168
+ - lib/templates/sun.svg.erb
152
169
  - lib/templates/tabbed_spec.html.erb
170
+ - lib/templates/themes/bootstrap.min.css
153
171
  - lib/templates/themes/cerulean.css
154
172
  - lib/templates/themes/cosmo.css
155
173
  - lib/templates/themes/cyborg.css
@@ -178,14 +196,30 @@ files:
178
196
  - rspec-documentation-0.1.0.gem
179
197
  - rspec-documentation.gemspec
180
198
  - rspec-documentation/pages/000-Introduction.md
199
+ - rspec-documentation/pages/000-Introduction/000-Quickstart.md
181
200
  - rspec-documentation/pages/010-File System.md
182
201
  - rspec-documentation/pages/010-File System/000-Ordering.md
183
- - rspec-documentation/pages/010-File System/010-Standalone Directories.md
184
- - rspec-documentation/pages/010-File System/020-Standalone Directory/Example Page.md
185
- - rspec-documentation/pages/020-Running Specs.md
202
+ - rspec-documentation/pages/010-File System/010-Documentation Bundle.md
203
+ - rspec-documentation/pages/020-Running Tests.md
204
+ - rspec-documentation/pages/030-Examples.md
205
+ - rspec-documentation/pages/030-Examples/010-Basic.md
206
+ - rspec-documentation/pages/030-Examples/020-HTML.md
207
+ - rspec-documentation/pages/030-Examples/030-ANSI.md
208
+ - rspec-documentation/pages/030-Examples/040-JSON.md
209
+ - rspec-documentation/pages/030-Examples/050-YAML.md
210
+ - rspec-documentation/pages/040-Spec Helper.md
211
+ - rspec-documentation/pages/050-Linking.md
212
+ - rspec-documentation/pages/060-Configuration.md
213
+ - rspec-documentation/pages/060-Configuration/010-Context.md
214
+ - rspec-documentation/pages/060-Configuration/020-Build Paths.md
215
+ - rspec-documentation/pages/060-Configuration/030-Attribution.md
216
+ - rspec-documentation/pages/070-Publishing.md
217
+ - rspec-documentation/pages/500-License.md
218
+ - rspec-documentation/spec_helper.rb
186
219
  - sig/rspec/documentation.rbs
187
220
  homepage: https://github.com/bobf/rspec-documentation
188
- licenses: []
221
+ licenses:
222
+ - MIT
189
223
  metadata:
190
224
  homepage_uri: https://github.com/bobf/rspec-documentation
191
225
  source_code_uri: https://github.com/bobf/rspec-documentation
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpecDocumentation
4
- # Outputs a string containing ANSI color code escape sequences into HTML with attached classes
5
- # for each matched color code. Cleans any remaining escape codes.
6
- class AnsiHTML
7
- COLOR_CODES = [0, 1, 2, 3, 4, 5, 6, 7, 9].freeze
8
-
9
- def initialize(content)
10
- @content = content
11
- end
12
-
13
- def render
14
- "<div class='ansi-html border m-1 p-4'><span>#{subbed_content}</span></div>"
15
- end
16
-
17
- private
18
-
19
- attr_reader :content
20
-
21
- def subbed_content
22
- COLOR_CODES.reduce(content) do |string, color_code|
23
- string.gsub("\e[3#{color_code}m", "</span><span class='ansi-color-#{color_code}'>")
24
- .gsub("\e[0m", "</span><span class='ansi-color-reset'>")
25
- end.gsub(/\e\[[0-9]+m/, '')
26
- end
27
- end
28
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpecDocumentation
4
- # Used to fetch missing methods called in examples, provides a context available to all
5
- # examples to avoid repeated setup in each example. Usage:
6
- #
7
- # ```ruby
8
- # RSpec::Documentation.configure do |config|
9
- # config.context do |context|
10
- # context.my_value = 'example value'
11
- # end
12
- # end
13
- # ```
14
- #
15
- # `my_value` will now be available in every example.
16
- class Context
17
- def initialize
18
- @context = {}
19
- end
20
-
21
- private
22
-
23
- def method_missing(key, *args, &block)
24
- return _assign(key, *args, &block) if key.to_s.end_with?('=')
25
- return super unless @context.key?(key)
26
-
27
- @context.fetch(key)
28
- end
29
-
30
- def respond_to_missing?(_key, *_)
31
- true
32
- end
33
-
34
- def _assign(key, *args, &block)
35
- key = key.to_s.rpartition('=').first.to_sym
36
-
37
- @context[key] = if block_given?
38
- block
39
- else
40
- args.first
41
- end
42
- end
43
- end
44
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpecDocumentation
4
- module RSpec
5
- # Replicates behaviour of a regular RSpec example group but also defines `it_documents` as an
6
- # alias for `it`.
7
- class ExampleGroup < ::RSpec::Core::ExampleGroup
8
- def self.it_documents(described_object, &block)
9
- raise Error, 'Must pass an example object to `it_documents`' if described_object.nil?
10
-
11
- metadata = { described_object: described_object }
12
- ::RSpec::Core::Example.new(self, 'documentation', metadata, block)
13
- end
14
-
15
- class << self
16
- def method_missing(...)
17
- RSpecDocumentation.context.public_send(...)
18
- end
19
-
20
- def respond_to_missing?(*args)
21
- RSpecDocumentation.context.respond_to_missing?(*args)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RSpecDocumentation
4
- module RSpec
5
- # RSpec reporter, compliant with RSpec::Core::Reporter. Stores outcomes of specs.
6
- class Reporter
7
- attr_reader :passed_examples, :failed_examples
8
-
9
- def initialize
10
- @passed_examples = []
11
- @failed_examples = []
12
- end
13
-
14
- def described_object
15
- raise Error, 'Code block did not contain an example.' if passed_examples.empty? && failed_examples.empty?
16
-
17
- passed_examples&.first&.metadata&.fetch(:described_object)
18
- end
19
-
20
- def report(*_); end
21
-
22
- def finish(*_); end
23
-
24
- def example_passed(example)
25
- raise Error, 'Cannot define more than one example per code block.' if passed_examples.size >= 1
26
-
27
- passed_examples << example
28
- end
29
-
30
- def example_group_started(*_); end
31
-
32
- def example_group_finished(*_); end
33
-
34
- def example_started(*_); end
35
-
36
- def example_finished(*_); end
37
-
38
- def example_failed(example)
39
- failed_examples << example
40
- end
41
-
42
- def fail_fast_limit_met?(*_); end
43
- end
44
- end
45
- end
@@ -1,17 +0,0 @@
1
- # Standalone Directories
2
-
3
- In most cases you will likely want each node on the tree to link to some content, but if you simply want to add a node to group together some other pages then create a directory without adding a matching _Markdown_ `.md` file.
4
-
5
- ```
6
- rspec-documentation/
7
- └── pages/
8
- ├── 000-Introduction.md
9
- ├── 010-File System/
10
- │   ├── 000-Ordering.md
11
- │   ├── 010-Standalone Directories.md
12
- │   └── 020-Standalone Directory/
13
- │   └── Example Page.md
14
- └── 010-File System.md
15
- ```
16
-
17
- You can see this example standalone directory in the documentation tree on this page.
@@ -1,3 +0,0 @@
1
- # Example Page
2
-
3
- Demonstrating standalone directories containing more `.md` files.
@@ -1,11 +0,0 @@
1
- # Running Specs
2
-
3
- To run your test suite, just call the provided `rspec-documentation` command from your project directory:
4
-
5
- ```console
6
- $ exe/rspec-documentation
7
-
8
- Created 5 pages.
9
-
10
- View your documentation here: /home/bob/dev/rspec-documentation/rspec-documentation/bundle/introduction.html
11
- ```