yard-lucid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +87 -0
  9. data/Rakefile +6 -0
  10. data/bin/console +13 -0
  11. data/bin/setup +8 -0
  12. data/lib/docserver/default/fulldoc/html/js/lucid.js +69 -0
  13. data/lib/docserver/default/layout/html/headers.erb +13 -0
  14. data/lib/docserver/doc_server/full_list/html/full_list.erb +37 -0
  15. data/lib/docserver/doc_server/full_list/html/setup.rb +19 -0
  16. data/lib/lucid/gherkin_repr.rb +307 -0
  17. data/lib/templates/default/feature/html/docstring.erb +3 -0
  18. data/lib/templates/default/feature/html/feature.erb +39 -0
  19. data/lib/templates/default/feature/html/no_steps_defined.erb +1 -0
  20. data/lib/templates/default/feature/html/outline.erb +52 -0
  21. data/lib/templates/default/feature/html/scenario.erb +52 -0
  22. data/lib/templates/default/feature/html/setup.rb +51 -0
  23. data/lib/templates/default/feature/html/steps.erb +37 -0
  24. data/lib/templates/default/feature/html/table.erb +19 -0
  25. data/lib/templates/default/featuredirectory/html/alpha_table.erb +30 -0
  26. data/lib/templates/default/featuredirectory/html/directory.erb +30 -0
  27. data/lib/templates/default/featuredirectory/html/setup.rb +41 -0
  28. data/lib/templates/default/featuretags/html/namespace.erb +127 -0
  29. data/lib/templates/default/featuretags/html/setup.rb +33 -0
  30. data/lib/templates/default/fulldoc/html/css/lucid.css +224 -0
  31. data/lib/templates/default/fulldoc/html/directories.erb +27 -0
  32. data/lib/templates/default/fulldoc/html/full_list_featuredirectories.erb +11 -0
  33. data/lib/templates/default/fulldoc/html/full_list_features.erb +36 -0
  34. data/lib/templates/default/fulldoc/html/full_list_stepdefinitions.erb +20 -0
  35. data/lib/templates/default/fulldoc/html/full_list_steps.erb +20 -0
  36. data/lib/templates/default/fulldoc/html/full_list_tags.erb +16 -0
  37. data/lib/templates/default/fulldoc/html/js/lucid.js +284 -0
  38. data/lib/templates/default/fulldoc/html/setup.rb +199 -0
  39. data/lib/templates/default/layout/html/setup.rb +111 -0
  40. data/lib/templates/default/specifications/html/alpha_table.erb +26 -0
  41. data/lib/templates/default/specifications/html/setup.rb +49 -0
  42. data/lib/templates/default/specifications/html/specifications.erb +46 -0
  43. data/lib/templates/default/steptransformers/html/header.erb +12 -0
  44. data/lib/templates/default/steptransformers/html/index.erb +9 -0
  45. data/lib/templates/default/steptransformers/html/setup.rb +92 -0
  46. data/lib/templates/default/steptransformers/html/transformers.erb +74 -0
  47. data/lib/templates/default/steptransformers/html/undefinedsteps.erb +26 -0
  48. data/lib/templates/default/tag/html/alpha_table.erb +32 -0
  49. data/lib/templates/default/tag/html/setup.rb +26 -0
  50. data/lib/templates/default/tag/html/tag.erb +31 -0
  51. data/lib/yard/code_objects/lucid/base.rb +23 -0
  52. data/lib/yard/code_objects/lucid/feature.rb +12 -0
  53. data/lib/yard/code_objects/lucid/namespace_object.rb +43 -0
  54. data/lib/yard/code_objects/lucid/scenario.rb +20 -0
  55. data/lib/yard/code_objects/lucid/scenario_outline.rb +66 -0
  56. data/lib/yard/code_objects/lucid/step.rb +32 -0
  57. data/lib/yard/code_objects/lucid/tag.rb +21 -0
  58. data/lib/yard/code_objects/step_definition.rb +3 -0
  59. data/lib/yard/code_objects/step_transform.rb +3 -0
  60. data/lib/yard/code_objects/step_transformer.rb +85 -0
  61. data/lib/yard/handlers/lucid/base.rb +19 -0
  62. data/lib/yard/handlers/lucid/feature_handler.rb +102 -0
  63. data/lib/yard/handlers/step_definition_handler.rb +67 -0
  64. data/lib/yard/handlers/step_transform_handler.rb +28 -0
  65. data/lib/yard/parser/lucid/feature.rb +58 -0
  66. data/lib/yard/server/adapter.rb +32 -0
  67. data/lib/yard/server/commands/list_command.rb +25 -0
  68. data/lib/yard/server/router.rb +23 -0
  69. data/lib/yard/templates/helpers/base_helper.rb +22 -0
  70. data/lib/yard-lucid/version.rb +3 -0
  71. data/lib/yard-lucid.rb +36 -0
  72. data/yard-lucid.gemspec +38 -0
  73. metadata +215 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08c7f6d439f619b3b01a3d229184f5b8db4cc8bc
4
+ data.tar.gz: 467656c8cdc9fd50cbd6634e3fd5d59728ef8d20
5
+ SHA512:
6
+ metadata.gz: fd30a4ebd5c804ecb919757c2e51a55b60fa0dcd794eb11ec3cde282d8b0c61ecb57667682e89b59869d9ff528b29d69117baa2630782dd2d72dbc9c96704bb6
7
+ data.tar.gz: a72c6c29ba127364f97349e9f1300c7ed6821de1375ce9b1a2af7118717cf8f7b0f0aaa92f5abc74c469ee5f5130b7e00bdcf435de56b6c0ef8f8d557906b3ab
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jeff.nyman@sproutsocial.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in yard-lucid.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Jeff Nyman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # Lucid Yard
2
+
3
+ The Lucid Yard gem acts as a YARD extension to process Gherkin-style feature files.
4
+
5
+ The gem itself is called `yard-lucid` (rather than `lucid-yard`) because the YARD tool provides built-in support for gems being used as plugins. In order for that to work, the gems in question must have the prefix `yard-`.
6
+
7
+ Gherkin objects like features, backgrounds, scenarios, tags, steps, step definitions, and transforms are integrated into a YARD template.
8
+
9
+ Lucid Yard provides a parser component, which is the first component in YARD's processing pipeline. This parser runs before any handling is done on the source itself. Lucid Yard provides a hook into the Gherkin parser rather than attempting to recreate the parser.
10
+
11
+ The parser translates the source into a set of statements that can be understood by the handlers that run immediately afterward. Handling is done after parsing to abstract away the implementation details of lexical and semantic analysis on the source and to only deal with the logic regarding recognizing source statements as particular types of code objects. Lucid Yard provides handlers that recognize the base level constructs of a Gherkin-style document. In other words, Gherkin feature files are being treated as a form of source code.
12
+
13
+ The handler is taking parsed statements, processing them, and in that action, creating what are called code objects. Code objects are Ruby objects that describe the code being documented. Lucid Yard provides a specific set of code objects that match any constructs that can be found in a Gherkin feature file. These code objects in turn create tags (essentially, metadata) that are attached to the objects.
14
+
15
+ These code objects are then added to an internal registry, which is a data store component.
16
+
17
+ The final act of this is the processing of objects from the registry via a templating engine, which is what allows output to be generated.
18
+
19
+ ## Installation
20
+
21
+ To get the latest stable release, add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'yard-lucid'
25
+ ```
26
+
27
+ To get the latest code:
28
+
29
+ ```ruby
30
+ gem 'yard-lucid', git: 'https://github.com/jeffnyman/yard-lucid'
31
+ ```
32
+
33
+ After doing one of the above, execute the following command:
34
+
35
+ $ bundle
36
+
37
+ You can also install Lucid Yard just as you would any other gem:
38
+
39
+ $ gem install yard-lucid
40
+
41
+ ## Usage
42
+
43
+ Since `yard-lucid` is acting as an extension to YARD, you have to enable the automatic loading of such extensions by YARD. The easiest way to do this is:
44
+
45
+ ```bash
46
+ $ mkdir ~/.yard
47
+ $ yard config load_plugins true
48
+ ```
49
+
50
+ Once that is done, you can run YARD as you normally would and have your Gherkin repository captured as a YARD documentation artifact.
51
+
52
+ ```bash
53
+ $ yardoc 'features/**/*.feature' 'steps/**/*.rb'
54
+ ```
55
+
56
+ ## Development
57
+
58
+ After checking out the repo, run `bin/setup` to install dependencies. Given the nature of Lucid Yard, it's difficult to provide unit tests for it, so you won't find a great deal of them. In fact, you'll find basically none.
59
+
60
+ To install this gem onto your local machine, run `bundle exec rake install`.
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/jeffnyman/yard-lucid](https://github.com/jeffnyman/yard-lucid). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another test-supporting tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
65
+
66
+ The Lucid Yard gems follows [semantic versioning](http://semver.org).
67
+
68
+ To contribute to Lucid Yard:
69
+
70
+ 1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
71
+ 2. Create your feature branch. (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes. (`git commit -am 'new feature'`)
73
+ 4. Push the branch. (`git push origin my-new-feature`)
74
+ 5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
75
+
76
+ ## Author
77
+
78
+ * [Jeff Nyman](http://testerstories.com)
79
+
80
+ ## Credits
81
+
82
+ This code is based upon the [Yard-Cucumber](https://github.com/burtlo/yard-cucumber) gem. The reason for this approach rather than a fork is that I wanted to clean up a lot of the code decisions made by the original author. I also wanted to move away from a strict Cucumber terminology. Finally, the original author hasn't necessarily been as responsive to pull requests which I felt would limit my options.
83
+
84
+ ## License
85
+
86
+ Lucid Yard is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
87
+ See the [LICENSE](https://github.com/jeffnyman/yard-lucid/blob/master/LICENSE.md) file for details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "yard/lucid"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require "pry"
10
+ Pry.start
11
+
12
+ # require "irb"
13
+ # IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,69 @@
1
+ function lucidSearchFrameLinks() {
2
+ $('#feature_list_link').click(function() {
3
+ toggleSearchFrame(this, '/' + library + '/features');
4
+ });
5
+ $('#tag_list_link').click(function() {
6
+ toggleSearchFrame(this, '/' + library + '/tags');
7
+ });
8
+ }
9
+
10
+ $(lucidSearchFrameLinks);
11
+
12
+ function toggleScenarioExample(id,example) {
13
+ var element = $("#" + id + "Example" + example + "Steps")[0];
14
+
15
+ $('#' + id + ' tr').each(function(index) {
16
+ this.style.backgroundColor = (index % 2 == 0 ? '#FFFFFF' : '#F0F6F9' );
17
+ });
18
+
19
+ if (element.style.display != 'none') {
20
+ element = $("#" + id + "Steps")[0];
21
+ } else {
22
+ $('#' + id + ' .outline * tr')[example].style.backgroundColor = '#FFCC80';
23
+ }
24
+
25
+ $('#' + id + ' .steps').each(function(index) {
26
+ this.style.display = 'none';
27
+ });
28
+
29
+ element.style.display = 'block';
30
+ }
31
+
32
+ function determine_tags_used_in_formula(tag_string) {
33
+ tag_string = tag_string.replace(/^(\s+)|(\s+)$/,'').replace(/\s{2,}/,' ');
34
+
35
+ var tags = tag_string.match(/@\w+/g);
36
+ var return_tags = [];
37
+
38
+ if (tags != null) {
39
+ tags.forEach(function(tag, index, array) {
40
+ //$("#tag_debug")[0].innerHTML += tag + " ";
41
+ if (tag_list.indexOf(tag) != -1) { return_tags.push(tag); }
42
+ });
43
+ }
44
+ return return_tags;
45
+ }
46
+
47
+ function display_example_command_line(tags) {
48
+ $("#command_example")[0].innerHTML = "cucumber ";
49
+
50
+ if (tags.length > 0) {
51
+ $("#command_example")[0].innerHTML += "--tags " + tags.join(" --tags ");
52
+ }
53
+ }
54
+
55
+ function display_qualifying_features_and_scenarios(tags) {
56
+ if (tags.length > 0) {
57
+ $(".feature,.scenario").each(function(feature){
58
+ this.style.display = "none";
59
+ });
60
+
61
+ $(".feature.\\" + tags.join(".\\") + ",.scenario.\\" + tags.join(".\\")).each(function(feature) {
62
+ this.style.display = "block";
63
+ });
64
+ } else {
65
+ $(".feature,.scenario").each(function(feature){
66
+ this.style.display = "block";
67
+ });
68
+ }
69
+ }
@@ -0,0 +1,13 @@
1
+ <meta name="Content-Type" content="text/html; charset=UTF-8" />
2
+ <title><%= @page_title %></title>
3
+ <link rel="stylesheet" href="/css/style.css" type="text/css" media="screen" charset="utf-8" />
4
+ <link rel="stylesheet" href="/css/custom.css" type="text/css" media="screen" charset="utf-8" />
5
+ <link rel="stylesheet" href="/css/common.css" type="text/css" media="screen" charset="utf-8" />
6
+ <link rel="stylesheet" href="/css/lucid.css" type="text/css" media="screen" charset="utf-8" />
7
+ <script type="text/javascript" charset="utf-8" src="/js/jquery.js"></script>
8
+ <script type="text/javascript" charset="utf-8" src="/js/autocomplete.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="/js/app.js"></script>
10
+ <script type="text/javascript" charset="utf-8" src="/js/lucid.js"></script>
11
+ <script type="text/javascript" charset="utf-8">
12
+ library = '<%= base_path(router.list_prefix) %>';
13
+ </script>
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="Content-Type" content="text/html; charset=<%= charset %>" />
5
+ <link rel="stylesheet" href="/css/full_list.css" type="text/css" media="screen" charset="utf-8" />
6
+ <link rel="stylesheet" href="/css/common.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="/css/lucid.css" type="text/css" media="screen" charset="utf-8" />
8
+ <script type="text/javascript" charset="utf-8" src="/js/jquery.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="/js/full_list.js"></script>
10
+ <script type="text/javascript" charset="utf-8" src="/js/lucid.js"></script>
11
+ <base id="base_target" target="_parent" />
12
+ </head>
13
+ <body>
14
+ <script>
15
+ if (window.top.frames.main) {
16
+ document.getElementById('base_target').target = 'main';
17
+ document.body.className = 'frames';
18
+ }
19
+ </script>
20
+ <div id="content">
21
+ <h1 id="full_list_header"><%= @list_title %></h1>
22
+ <div id="nav">
23
+ <a target="_self" href="/<%= base_path(router.list_prefix) %>/features">Features</a> |
24
+ <a target="_self" href="/<%= base_path(router.list_prefix) %>/tags">Tags</a> |
25
+ <a target="_self" href="/<%= base_path(router.list_prefix) %>/class">Classes</a> |
26
+ <a target="_self" href="/<%= base_path(router.list_prefix) %>/methods">Methods</a> |
27
+ <a target="_self" href="/<%= base_path(router.list_prefix) %>/files">Files</a>
28
+ </div>
29
+
30
+ <div id="search">Search: <input type="text" /></div>
31
+
32
+ <ul id="full_list" class="<%= @list_class || @list_type %>">
33
+ <%= erb "full_list_#{@list_type}" %>
34
+ </ul>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,19 @@
1
+ include T('default/fulldoc/html')
2
+
3
+ def init
4
+ # This is the css class type; defaulting to class.
5
+ @list_class = "class"
6
+
7
+ case @list_type.to_sym
8
+ when :features; @list_title = "Features"
9
+ when :tags; @list_title = "Tags"
10
+ when :class; @list_title = "Class List"
11
+ when :methods; @list_title = "Method List"
12
+ when :files; @list_title = "File List"
13
+ end
14
+ sections :full_list
15
+ end
16
+
17
+ def all_features_link
18
+ linkify YARD::CodeObjects::Lucid::LUCID_NAMESPACE, "All Features"
19
+ end