user_docs 0.0.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67c39c53388cf78f7f03ff632552792d7946a09d990cf7e71ef63e96ebe7d126
4
- data.tar.gz: e1545d408a3d543b43ff274786bfeb7dfa61c46013d9cf9e69f564aacc91c775
3
+ metadata.gz: 8a29682463845307876f721711cc7c35fb66b740b57fa04c7a2aae82972db7d1
4
+ data.tar.gz: 1cb0f5c6697ad276f401968f4b342da581d81e33f92e468c1c40862e8c59d48e
5
5
  SHA512:
6
- metadata.gz: c348ff79b487bd6fa2995555ec2eaac4ff4c10bfe71980463340d8ad335636cd8466848993b0d126612e748e3106dfc30313c345aee714a7c686e0b601cde966
7
- data.tar.gz: 9d650d9b7cea0d59daa4dc4d1ae7ae152001fe85cb1dda66aef591f9a51674347885c45bb55961b1dcb3a7cbd2a574e170d6d4b3cb94e45a0ffa34849a9cdada
6
+ metadata.gz: f3741fb6d581ea85e6ce3f63ae00ba213c2d452a2af19b1a36b2f6c0eba2b09c36cf34ac87d94c75fe94cc451147cf408930ece29024f61f60f45c9f804a7350
7
+ data.tar.gz: ccda61469eaf5bf01c1cbe52c7abbc4aa325a362cd6b5a4ef8351bf1e38da94f75411f820a295eb19565f4022321f3dd8dd04921e1d38ad7e4e09af8da0aca00
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 jtopgi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # UserDocs
2
+ UserDocs is an semi-autonomous way to create end-user documentation for your Rails project.
3
+
4
+ ## Installation
5
+ 0. Ensure you have the VERSION constant defined for your project.
6
+ 1. Add this line to your application's Gemfile:
7
+ ```ruby
8
+ gem 'user_docs'
9
+ ```
10
+ And then execute:
11
+ ```bash
12
+ $ bundle
13
+ ```
14
+ 3. Install the required files:
15
+ ```bash
16
+ $ rails g user_docs:install
17
+ ```
18
+ 4. Include the UserDocs module in your system tests:
19
+ ```ruby
20
+ class ExampleTest < ApplicationSystemTestCase
21
+ include UserDocs
22
+
23
+ test "foo" do
24
+ end
25
+ end
26
+ ```
27
+ 5. Generate documentation by running your system tests:
28
+ ```bash
29
+ $ rails test:system
30
+ ```
31
+ 6. Push changes to master.
32
+ 7. [Enable GitHub Pages docs folder.](https://help.github.com/en/articles/configuring-a-publishing-source-for-github-pages#publishing-your-github-pages-site-from-a-docs-folder-on-your-master-branch)
33
+ 8. Your documentation should be viewable in the given url within a couple minutes.
34
+
35
+ ## Usage
36
+ Here are the following methods you can use to create documentation:
37
+ * `accept_alert`
38
+ * `click_on`
39
+ * `fill_in`
40
+ * `choose`
41
+ * `save_screenshot`
42
+ * `comment`
43
+
44
+ ## License
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "bundler/setup"
5
+ rescue LoadError
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
7
+ end
8
+
9
+ require "rdoc/task"
10
+
11
+ RDoc::Task.new(:rdoc) do |rdoc|
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "UserDocs"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
17
+ end
18
+
19
+ require "bundler/gem_tasks"
20
+
21
+ require "rake/testtask"
22
+
23
+ Rake::TestTask.new(:test) do |t|
24
+ t.libs << "test"
25
+ t.test_files = FileList["test/generators/*_test.rb", "test/integration/*_test.rb", "test/system/*_test.rb"]
26
+ t.verbose = false
27
+ end
28
+
29
+ require "rubocop/rake_task"
30
+ require "bundler/audit/task"
31
+ RuboCop::RakeTask.new
32
+ Bundler::Audit::Task.new
33
+
34
+ task :default do
35
+ Rake::Task[:rubocop].invoke
36
+ Rake::Task["bundle:audit"].invoke
37
+ Rake::Task[:test].invoke
38
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module UserDocs
6
+ # Installs the required files
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("templates", __dir__)
9
+
10
+ def create
11
+ check_for_version
12
+
13
+ template "index", "docs/index.html"
14
+ template "_layouts/default", "docs/_layouts/default.html"
15
+ template "_includes/index", "docs/_includes/index.html"
16
+ empty_directory "docs/_data/versions"
17
+ empty_directory "docs/versions"
18
+ end
19
+
20
+ private
21
+
22
+ def check_for_version
23
+ host_app = Rails.application.class
24
+ return if defined?(host_app.module_parent::VERSION)
25
+
26
+ # :nocov:
27
+ abort "ERROR: version needs to defined as "\
28
+ "#{host_app.module_parent}::VERSION."
29
+ # :nocov:
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ <h1 class="text-center">Features</h1>
2
+
3
+ {% assign version_directory = page.version | default: site.version | replace: '.', '_' %}
4
+ {% for feature in site.data.versions[version_directory] %}
5
+ <h2 class="mt-3">{{feature[0]}}</h2>
6
+
7
+ <div class="accordian" id="{{feature[0]}}">
8
+ {% for methods in feature[1] %}
9
+ <div class="card">
10
+ <button class="btn btn-light btn-lg collapsed text-left" type="button" data-toggle="collapse" data-target="#{{feature[0]}}-collapse-{{forloop.index}}" style="white-space: normal;">{{methods[1].name}}</button>
11
+ <div id="{{feature[0]}}-collapse-{{forloop.index}}" class="collapse" data-parent="#{{feature[0]}}">
12
+ <div class="card-body">
13
+ <ul>
14
+ {% for step in methods[1].steps %}
15
+ <li>{{step | markdownify | remove: '<p>' | remove: '</p>'}}</li>
16
+ {% endfor %}
17
+ </ul>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ {% endfor %}
22
+ </div>
23
+ {% endfor %}
24
+
@@ -0,0 +1,44 @@
1
+ {% assign current_page_version = page.version | default: site.version %}
2
+ <!doctype html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
8
+ <title>End User Documentation</title>
9
+ </head>
10
+
11
+ <body class="container">
12
+ <nav class="navbar navbar-expand-lg navbar-light bg-light rounded">
13
+ <a class="navbar-brand" href="index.html">End User Documentation v{{ current_page_version }}</a>
14
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
15
+ <span class="navbar-toggler-icon"></span>
16
+ </button>
17
+
18
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
19
+ <ul class="navbar-nav ml-auto">
20
+ <li class="nav-item dropdown">
21
+ <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
22
+ Version
23
+ </a>
24
+ <div class="dropdown-menu" aria-labelledby="navbarDropdown">
25
+ {% for version in site.data.versions %}
26
+ {% assign dot_version = version.first | replace: '_', '.' %}
27
+ {% assign version_path = "/versions/" | append: dot_version %}
28
+ {% assign css_class = "" %}
29
+ {% if dot_version == current_page_version %}
30
+ {% assign css_class = " active" %}
31
+ {% endif %}
32
+ <a class="dropdown-item{{ css_class }}" href="{{ version_path | relative_url }}">{{ dot_version }}</a>
33
+ {% endfor %}
34
+ </div>
35
+ </li>
36
+ </ul>
37
+ </div>
38
+ </nav>
39
+ {{ content }}
40
+ <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
41
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
42
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
43
+ </body>
44
+ </html>
@@ -0,0 +1,5 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ {% include index.html %}
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ # desc "Explaining what the task does"
4
+ # task :user_docs do
5
+ # # Task goes here
6
+ # end
data/lib/user_docs.rb CHANGED
@@ -1,10 +1,9 @@
1
- module UserDocs
2
- def self.hi
3
- puts "Hello world!"
4
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "user_docs/railtie"
4
+ require "user_docs/capybara_extension"
5
+ require "webdrivers"
5
6
 
6
- def click_on(link)
7
- super
8
- puts("Click on **#{link}**.")
9
- end
7
+ # User Documentation module
8
+ module UserDocs
10
9
  end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "capybara"
4
+
5
+ # Extends Capybara's Actions to create end user documentation
6
+ module UserDocs
7
+ extend Capybara::Node::Actions
8
+
9
+ def before_setup
10
+ super
11
+
12
+ check_installation
13
+
14
+ @class_name = class_name.chomp("Test")
15
+ @method = name.sub("test_", "")
16
+ make_version_data_directory
17
+ make_version_index
18
+ Capybara.save_path = Rails.root.join("docs", "assets", @class_name, @method)
19
+
20
+ @json = { name: @method.humanize, steps: [] }
21
+ end
22
+
23
+ def before_teardown
24
+ File.write(
25
+ Rails.root.join(
26
+ "docs", "_data", "versions", version_data_directory_name,
27
+ @class_name, "#{@method}.json"
28
+ ), @json.to_json
29
+ )
30
+
31
+ super
32
+ end
33
+
34
+ private
35
+
36
+ def check_installation
37
+ return if Dir.exist?(Rails.root.join("docs"))
38
+
39
+ # :nocov:
40
+ abort("ERROR: Run 'rails g user_docs:install.'")
41
+ # :nocov:
42
+ end
43
+
44
+ def version
45
+ Rails.application.class.module_parent::VERSION
46
+ end
47
+
48
+ def version_data_directory_name
49
+ version.tr(".", "_")
50
+ end
51
+
52
+ def make_version_data_directory
53
+ FileUtils.mkdir_p(
54
+ Rails.root.join("docs", "_data", "versions",
55
+ version_data_directory_name, @class_name)
56
+ )
57
+ end
58
+
59
+ # rubocop:disable Metrics/MethodLength
60
+ def make_version_index
61
+ directory = "#{Rails.root}/docs/versions/#{version}"
62
+ FileUtils.mkdir_p directory
63
+ File.write(
64
+ "#{directory}/index.html",
65
+ <<~HTML
66
+ ---
67
+ layout: default
68
+ version: #{version}
69
+ ---
70
+ {% include index.html %}
71
+ HTML
72
+ )
73
+ end
74
+ # rubocop:enable Metrics/MethodLength
75
+
76
+ def click_on(link)
77
+ super
78
+ @json[:steps] << "Click on **#{link}**."
79
+ end
80
+
81
+ def fill_in(text, with:)
82
+ super
83
+ @json[:steps] << "Fill in **#{text}** with *#{with}*."
84
+ end
85
+
86
+ def choose(label)
87
+ super
88
+ @json[:steps] << "Select radio button with *#{label}*."
89
+ end
90
+
91
+ def accept_alert
92
+ page.accept_alert
93
+ @json[:steps] << "Click **OK**."
94
+ end
95
+
96
+ def save_screenshot(image)
97
+ super
98
+ @json[:steps] <<
99
+ "<img src='assets/#{@class_name}/#{@method}/#{image}' class='img-fluid'>"
100
+ end
101
+
102
+ def comment(string)
103
+ @json[:steps] << string
104
+ end
105
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UserDocs
4
+ class Railtie < ::Rails::Railtie
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module UserDocs
4
+ VERSION = "0.2.0"
5
+ end
metadata CHANGED
@@ -1,41 +1,179 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jeevan Topgi
7
+ - jtopgi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-26 00:00:00.000000000 Z
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 3.32.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: A gem that creates end user documentation, viewable through Github Pages,
28
- through system tests.
29
- email: jeevan-topgi1@northwestern.edu
26
+ version: 3.32.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 6.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 6.0.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: selenium-webdriver
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.142.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.142.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: webdrivers
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler-audit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 11.1.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 11.1.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.81.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.81.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 1.5.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 1.5.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 2.5.2
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 2.5.2
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.18.5
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.18.5
153
+ description:
154
+ email:
155
+ - jtopgi@users.noreply.github.com
30
156
  executables: []
31
157
  extensions: []
32
158
  extra_rdoc_files: []
33
159
  files:
160
+ - MIT-LICENSE
161
+ - README.md
162
+ - Rakefile
163
+ - lib/generators/user_docs/install_generator.rb
164
+ - lib/generators/user_docs/templates/_includes/index.tt
165
+ - lib/generators/user_docs/templates/_layouts/default.tt
166
+ - lib/generators/user_docs/templates/index.tt
167
+ - lib/tasks/user_docs_tasks.rake
34
168
  - lib/user_docs.rb
35
- homepage: http://rubygems.org/gems/user_docs
169
+ - lib/user_docs/capybara_extension.rb
170
+ - lib/user_docs/railtie.rb
171
+ - lib/user_docs/version.rb
172
+ homepage:
36
173
  licenses:
37
174
  - MIT
38
- metadata: {}
175
+ metadata:
176
+ allowed_push_host: https://rubygems.org
39
177
  post_install_message:
40
178
  rdoc_options: []
41
179
  require_paths:
@@ -51,9 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
189
  - !ruby/object:Gem::Version
52
190
  version: '0'
53
191
  requirements: []
54
- rubyforge_project:
55
- rubygems_version: 2.7.7
192
+ rubygems_version: 3.1.2
56
193
  signing_key:
57
194
  specification_version: 4
58
- summary: UserDocs
195
+ summary: Summary of UserDocs.
59
196
  test_files: []