apress-documentation 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.drone.yml +28 -0
  3. data/.gitignore +10 -0
  4. data/Appraisals +30 -0
  5. data/CHANGELOG.md +34 -0
  6. data/Gemfile +4 -0
  7. data/README.md +101 -0
  8. data/Rakefile +6 -0
  9. data/app/assets/javascripts/package/documentation.js +18 -0
  10. data/app/assets/javascripts/shared/dependency_switcher.js +10 -0
  11. data/app/assets/javascripts/swagger_binder.js +19 -0
  12. data/app/assets/javascripts/swagger_ui.js +24 -0
  13. data/app/assets/javascripts/templates/document.hamlbars +25 -0
  14. data/app/assets/stylesheets/document/base.scss +112 -0
  15. data/app/assets/stylesheets/document/document.scss +19 -0
  16. data/app/assets/stylesheets/document/layout.scss +9 -0
  17. data/app/assets/stylesheets/document/sidebar.scss +19 -0
  18. data/app/assets/stylesheets/document/swagger.scss +3 -0
  19. data/app/assets/stylesheets/document/switch.scss +46 -0
  20. data/app/assets/stylesheets/document/variables.scss +26 -0
  21. data/app/assets/stylesheets/package/documentation.css +9 -0
  22. data/app/assets/stylesheets/package/swagger_print.css +4 -0
  23. data/app/assets/stylesheets/package/swagger_screen.css +4 -0
  24. data/app/controllers/apress/documentation/documents_controller.rb +14 -0
  25. data/app/controllers/apress/documentation/swagger_controller.rb +22 -0
  26. data/app/controllers/apress/documentation/swagger_ui_controller.rb +11 -0
  27. data/app/controllers/concerns/apress/documentation/preload_docs.rb +20 -0
  28. data/app/helpers/apress/documentation/documents_helper.rb +14 -0
  29. data/app/presenters/apress/documentation/dependency_presenter.rb +75 -0
  30. data/app/services/apress/documentation/swagger_json_builder.rb +22 -0
  31. data/app/views/apress/documentation/documents/_document.html.haml +32 -0
  32. data/app/views/apress/documentation/documents/_swagger.html.haml +10 -0
  33. data/app/views/apress/documentation/documents/show.html.haml +13 -0
  34. data/app/views/apress/documentation/presenters/dependency_presenter/_dependencies.html.haml +21 -0
  35. data/app/views/apress/documentation/presenters/dependency_presenter/_links.html.haml +17 -0
  36. data/app/views/apress/documentation/swagger_ui/show.html.haml +26 -0
  37. data/app/views/layouts/apress/documentation/_menu.html.haml +6 -0
  38. data/app/views/layouts/apress/documentation/_menu_item.html.haml +7 -0
  39. data/app/views/layouts/apress/documentation/_sidebar.html.haml +2 -0
  40. data/app/views/layouts/documentation.html.haml +17 -0
  41. data/apress-documentation.gemspec +35 -0
  42. data/config/routes.rb +16 -0
  43. data/dip.yml +48 -0
  44. data/docker-compose.development.yml +18 -0
  45. data/docker-compose.drone.yml +7 -0
  46. data/docker-compose.yml +10 -0
  47. data/lib/apress/documentation.rb +48 -0
  48. data/lib/apress/documentation/dsl/compilers/base_compiler.rb +32 -0
  49. data/lib/apress/documentation/dsl/compilers/document_compiler.rb +111 -0
  50. data/lib/apress/documentation/dsl/compilers/mixins/dependable.rb +31 -0
  51. data/lib/apress/documentation/dsl/compilers/mixins/publicity.rb +34 -0
  52. data/lib/apress/documentation/dsl/compilers/swagger_compiler.rb +25 -0
  53. data/lib/apress/documentation/dsl/document.rb +14 -0
  54. data/lib/apress/documentation/dsl/modules.rb +40 -0
  55. data/lib/apress/documentation/dsl/swagger_document.rb +14 -0
  56. data/lib/apress/documentation/dsl/utils/swagger_bind_point_extractor.rb +37 -0
  57. data/lib/apress/documentation/engine.rb +16 -0
  58. data/lib/apress/documentation/extensions/rgl/adjacency.rb +18 -0
  59. data/lib/apress/documentation/storage/base_storage.rb +88 -0
  60. data/lib/apress/documentation/storage/dependency_graph.rb +96 -0
  61. data/lib/apress/documentation/storage/document.rb +52 -0
  62. data/lib/apress/documentation/storage/modules.rb +83 -0
  63. data/lib/apress/documentation/storage/swagger_document.rb +62 -0
  64. data/lib/apress/documentation/swagger/schema.rb +39 -0
  65. data/lib/apress/documentation/version.rb +5 -0
  66. data/spec/app/controllers/documents_controller_spec.rb +42 -0
  67. data/spec/app/controllers/swagger_controller_spec.rb +46 -0
  68. data/spec/app/controllers/swagger_ui_controller_spec.rb +11 -0
  69. data/spec/app/services/swagger_json_builder_spec.rb +41 -0
  70. data/spec/apress/documentation_spec.rb +342 -0
  71. data/spec/helpers/apress/documentation/documents_helper_spec.rb +17 -0
  72. data/spec/internal/app/docs/swagger/root.rb +7 -0
  73. data/spec/internal/config/database.yml +7 -0
  74. data/spec/internal/config/environments/test.rb +1 -0
  75. data/spec/internal/config/hosts.rb +1 -0
  76. data/spec/internal/config/routes.rb +3 -0
  77. data/spec/internal/lib/stub_docs/module.rb +3 -0
  78. data/spec/internal/lib/stub_docs/module/document/child_document.rb +7 -0
  79. data/spec/internal/log/.gitignore +1 -0
  80. data/spec/presenters/apress/documentation/dependency_presenter_spec.rb +139 -0
  81. data/spec/spec_helper.rb +27 -0
  82. metadata +335 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3884b3865d68ccbb735759200cfc3833e7747c5
4
+ data.tar.gz: b03241bacd2cd463a790e214d689cebdfc4b2044
5
+ SHA512:
6
+ metadata.gz: fa018cf839ed6b3d33d78af959ac566b12804560d46f61a2f08cec83477599d1f41def643de73b3a025ff28150bdef6b06567dfbb070ef54a53f78cf4449668a
7
+ data.tar.gz: 296e6b6572a6325fb1ff9b7650225c69d86cda31d2de703721084f5527b78d2883f44dae2a7cc36ff9cbcb6c49455577373077b4029f6db70f31ef7973c89a20
@@ -0,0 +1,28 @@
1
+ build:
2
+ test:
3
+ image: abakpress/dind-testing
4
+ pull: true
5
+ privileged: true
6
+ volumes:
7
+ - /home/data/drone/images:/images
8
+ - /home/data/drone/gems:/bundle
9
+ environment:
10
+ - COMPOSE_FILE_EXT=drone
11
+ - RUBY_IMAGE_TAG=2.2-latest
12
+ commands:
13
+ - wrapdocker docker -v
14
+
15
+ - fetch-images --image abakpress/ruby-app:$RUBY_IMAGE_TAG
16
+ - dip provision
17
+ - dip rspec
18
+
19
+ release:
20
+ image: abakpress/gem-publication
21
+ pull: true
22
+ when:
23
+ event: push
24
+ branch: master
25
+ volumes:
26
+ - /home/data/drone/rubygems:/root/.gem
27
+ commands:
28
+ - release-gem --public
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /Gemfile.lock
3
+ /coverage/
4
+ /doc/
5
+ /spec/reports/
6
+ /tmp/
7
+ /gemfiles/
8
+
9
+ # rspec failure tracking
10
+ .rspec_status
@@ -0,0 +1,30 @@
1
+ appraise 'rails3.2' do
2
+ gem 'rails', '>= 3.2', '< 4.0'
3
+ end
4
+
5
+ appraise 'rails4.0' do
6
+ gem 'rails', '>= 4.0', '< 4.1'
7
+ end
8
+
9
+ appraise 'rails4.1' do
10
+ gem 'rails', '>= 4.1', '< 4.2'
11
+ end
12
+
13
+ appraise 'rails4.2' do
14
+ gem 'rails', '>= 4.2', '< 5.0'
15
+ end
16
+
17
+ appraise 'rails5.0' do
18
+ gem 'rails', '>= 5.0', '< 5.1'
19
+ gem 'rails-controller-testing'
20
+ end
21
+
22
+ appraise 'rails5.1' do
23
+ gem 'rails', '~> 5.1.0'
24
+ gem 'rails-controller-testing'
25
+ end
26
+
27
+ appraise 'rails5.2' do
28
+ gem 'rails', '~> 5.2.0'
29
+ gem 'rails-controller-testing'
30
+ end
@@ -0,0 +1,34 @@
1
+ # v0.4.0
2
+
3
+ * 2018-08-22 [2d3b37b](../../commit/2d3b37b) - __(Artem Napolskih)__ chore: Add automatic publication
4
+ * 2018-08-21 [c419339](../../commit/c419339) - __(Artem Napolskih)__ fix: removes dependence on abak domain system
5
+ * 2018-08-21 [dddd8ea](../../commit/dddd8ea) - __(Artem Napolskih)__ feature: rails 5.x support added
6
+
7
+ # v0.3.0
8
+
9
+ * 2018-06-06 [386ff0e](../../commit/386ff0e) - __(Maxim Tretyakov)__ feat: route scope option
10
+ https://jira.railsc.ru/browse/ORDERS-1786
11
+
12
+ # v0.2.1
13
+
14
+ * 2017-09-27 [beec36c](../../commit/beec36c) - __(Denis Korobicyn)__ fix: proper cache key
15
+
16
+ # v0.2.0
17
+
18
+ * 2017-07-31 [ad4e903](../../commit/ad4e903) - __(Denis Korobicyn)__ fix: dependencies for swagger documents
19
+ https://jira.railsc.ru/browse/PC4-19812
20
+
21
+ * 2017-05-19 [6b3e186](../../commit/6b3e186) - __(Denis Korobicyn)__ feature: modules connections
22
+ https://jira.railsc.ru/browse/PC4-19783
23
+
24
+ * 2017-05-12 [9064dc6](../../commit/9064dc6) - __(Denis Korobicyn)__ fix: assets compilation
25
+ https://jira.railsc.ru/browse/PC4-19468
26
+
27
+ * 2017-05-10 [62fe08a](../../commit/62fe08a) - __(Denis Korobicyn)__ chore: add missing load_hook for documents_controller
28
+ * 2017-05-04 [fd80fa6](../../commit/fd80fa6) - __(Denis Korobicyn)__ chore: add load_docs_for method
29
+ * 2017-05-03 [87005d6](../../commit/87005d6) - __(Denis Korobicyn)__ fix: repo url in gemspec and repo name in readme
30
+
31
+ # v0.1.0
32
+
33
+ * 2017-04-21 [3c66be9](../../commit/3c66be9) - __(Denis Korobicyn)__ Initial commit
34
+ * 2017-04-21 [db97835](../../commit/db97835) - __(Mamedaliev Kirill)__ Initial commit
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in apress-documenation.gemspec
4
+ gemspec
@@ -0,0 +1,101 @@
1
+ # Apress::Documentation
2
+
3
+
4
+ ## Установка
5
+
6
+ ```ruby
7
+ gem 'apress-documentation'
8
+ ```
9
+
10
+ ## Использвание
11
+
12
+ Описание любого компонена задается с помощью вызова метода build на главном модуле `Apress::Documentation` и передаче ему блока. Например,
13
+ ```
14
+ Apress::Documentation.build(:module_name, title: 'название модуля') do
15
+ document(:component, title: 'Название компонента') do
16
+ description 'test'
17
+ end
18
+ end
19
+ ```
20
+
21
+ в самом блоке могут быть вызваны методы document, name, description, business_desc, consumers, publicity, tests, swagger_bind.
22
+
23
+ #### Описания методов
24
+ `document` определеяет весь документ, является частью построения меню (на каждый документ создается ссылка), данный метод можно вызвать друг друге, например:
25
+ ```ruby
26
+ Apress::Documentation.build(:module_name, title: 'название модуля') do
27
+ document(:component, title: 'Название компонента') do
28
+ description 'test'
29
+
30
+ document(:nested_component, title: 'Вложенный документ') do
31
+ description 'test here'
32
+ publicity 'Закрытый'
33
+ end
34
+ end
35
+ end
36
+ ```
37
+
38
+ также `document` можно вызывать без блока, если нет неообходимости:
39
+ ```ruby
40
+ Apress::Documentation.build(:module_name, title: 'название модуля') do
41
+ document(:component, title: 'Простой компонент соящий упоминания')
42
+ end
43
+ ```
44
+
45
+ `title` - имя компонента.
46
+
47
+ `description` - описание компонента.
48
+
49
+ `business_desc` - бизнес-описание компонента, заполняется менеджером.
50
+
51
+ `consumers` - перечесление модулей-потребителей.
52
+
53
+ `tests` - есть ли тесты на компонент, когда были написаны, в рамках какой задачи.
54
+
55
+ `publicity` - публичность компонента, возможность использования его в других местах, рекомендованные значения -
56
+ "Защищеный", "Публичный".
57
+
58
+ `swagger_bind` реализует возможность дополнить swagger-ui.
59
+ разрешенные методы - business_desc, consumers, tests и publicity.
60
+ Пример использования:
61
+ ```ruby
62
+ Apress::Documentation.build(:module_name, title: 'название модуля') do
63
+ document(:http_api, title: 'HTTP API') do
64
+ # аргумент id HTML блока в который будет ставлена доп. инфа
65
+ swagger_bind('module_operationID_content') do
66
+ description 'Это апи нужно для того-то'
67
+
68
+ consumers 'Other module'
69
+
70
+ # тут обычное swagger описание
71
+ swagger_path('some/path/here') do
72
+ operation :get do
73
+ # важно чтобы operation_id и tags совпадали в аргументе swagger_bind
74
+ key :operationId, 'operationID'
75
+ key :tags, ['module']
76
+
77
+ ...
78
+ end
79
+ end
80
+ end
81
+
82
+ # также аргумент HTML id можно опускать, если operationId и tags заданы
83
+ swagger_bind do
84
+ description 'Это апи нужно для того-то'
85
+
86
+ consumers 'Other module'
87
+
88
+ # тут обычное swagger описание
89
+ swagger_path('some/path/here') do
90
+ operation :get do
91
+ # Автоматически поддянет значения и создат HTML id - module_operationID_content
92
+ key :operationId, 'operationID'
93
+ key :tags, ['module']
94
+
95
+ ...
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ ```
@@ -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
@@ -0,0 +1,18 @@
1
+ //= require swagger-ui/lib/jquery-1.8.0.min.js
2
+ //= require swagger-ui/lib/jquery.slideto.min.js
3
+ //= require swagger-ui/lib/jquery.wiggle.min.js
4
+ //= require swagger-ui/lib/jquery.ba-bbq.min.js
5
+ //= require swagger-ui/lib/handlebars-2.0.0.js
6
+ //= require swagger-ui/lib/underscore-min.js
7
+ //= require swagger-ui/lib/backbone-min.js
8
+ //= require swagger-ui/lib/jsoneditor.min.js
9
+ //= require swagger-ui/lib/highlight.7.3.pack.js
10
+ //= require swagger-ui/lib/marked.js
11
+ //= require swagger-ui/lib/swagger-oauth.js
12
+ //= require swagger-ui/swagger-ui.js
13
+ //= require swagger_ui.js
14
+ //= require_tree ../templates
15
+ //= require shared/dependency_switcher.js
16
+ //= require swagger_binder.js
17
+
18
+ DependencySwitcher.switchBind();
@@ -0,0 +1,10 @@
1
+ var DependencySwitcher = (function(self) {
2
+ self.switchBind = function() {
3
+ $('.js-dependency-switch', '.js-dependencies-container').change(function() {
4
+ $('.js-all-dependencies', '.js-dependencies-container').toggle();
5
+ $('.js-dependencies', '.js-dependencies-container').toggle();
6
+ });
7
+ };
8
+
9
+ return self;
10
+ })(DependencySwitcher || {});
@@ -0,0 +1,19 @@
1
+ $(function () {
2
+ Handlebars.registerHelper('fetch', function (value, def) {
3
+ return value || def;
4
+ });
5
+
6
+ $(document).on('swaggerBind', function(event) {
7
+ event.preventDefault();
8
+
9
+ if(!app.extensions) {
10
+ return;
11
+ }
12
+
13
+ for(var ext in app.extensions) {
14
+ $('#' + ext + '_content').prepend(HandlebarsTemplates['document']({document: app.extensions[ext]}));
15
+ }
16
+
17
+ DependencySwitcher.switchBind();
18
+ });
19
+ });
@@ -0,0 +1,24 @@
1
+ $(function () {
2
+ if(app.swagger) {
3
+ window.swaggerUi = new SwaggerUi({
4
+ url: app.swagger.docsUrl,
5
+ dom_id: 'swagger-ui-container',
6
+ supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
7
+ onComplete: function() {
8
+ $('pre code').each(function(i, e) {
9
+ hljs.highlightBlock(e);
10
+ });
11
+
12
+ $(document).trigger('swaggerBind');
13
+ },
14
+ onFailure: function() {
15
+ console.log('Unable to Load SwaggerUI');
16
+ },
17
+ docExpansion: (app.swagger.docsExpansion || 'none'),
18
+ jsonEditor: true,
19
+ defaultModelRendering: 'schema',
20
+ showRequestHeaders: true
21
+ });
22
+ window.swaggerUi.load();
23
+ }
24
+ });
@@ -0,0 +1,25 @@
1
+ %h4 Бизнесс описание
2
+ %span
3
+ {{fetch document.business_desc "Нет данных"}}
4
+
5
+ %h4 Публичность
6
+ %span
7
+ {{fetch document.publicity "Нет данных"}}
8
+
9
+ %h4 Тесты
10
+ %span
11
+ {{fetch document.tests "Нет данных"}}
12
+
13
+ %h4 Зависимости
14
+ .js-dependencies-container
15
+ .switch
16
+ %input.switch-checkbox.js-dependency-switch{type: "checkbox", id: "doc-switch-{{document.slug}}"}
17
+ %label.switch-label{for: "doc-switch-{{document.slug}}"}
18
+ %span.switch-inner
19
+ %span.switch-switch
20
+
21
+ %h5 Зависит от
22
+ {{{fetch document.depends_on "Нет данных"}}}
23
+
24
+ %h5 Используется в
25
+ {{{fetch document.consumers "Нет данных"}}}
@@ -0,0 +1,112 @@
1
+ @import 'variables';
2
+
3
+ * {
4
+ -webkit-font-smoothing: antialiased;
5
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
6
+ -moz-osx-font-smoothing: grayscale;
7
+ box-sizing: border-box;
8
+
9
+ &:focus,
10
+ &:active {
11
+ outline: none;
12
+ }
13
+ }
14
+
15
+ body {
16
+ background-color: $body-bg;
17
+ color: $text-color;
18
+ font-family: $font-family;
19
+ font-size: $font-size;
20
+ line-height: $line-height;
21
+ }
22
+
23
+ h1,
24
+ h2,
25
+ h3,
26
+ h4,
27
+ h5,
28
+ h6 {
29
+ font-family: $font-family-headings;
30
+ font-weight: $headings-font-weight;
31
+ color: $heading-color;
32
+ line-height: $heading-line-heading;
33
+ margin: 1.6em 0 .8em;
34
+ }
35
+
36
+ h1 {
37
+ font-size: 1.5em;
38
+ border-bottom: 1px solid lighten($border-accent-color, 1%);
39
+ padding-bottom: .6em;
40
+
41
+ & > a {
42
+ & > img {
43
+ vertical-align: middle;
44
+ position: relative;
45
+ top: -2px;
46
+ margin-left: 1px;
47
+ height: 18px;
48
+
49
+ @media(max-width: $screen-sm-max) {
50
+ display: none;
51
+ }
52
+ }
53
+
54
+ &:first-child {
55
+ & > img {
56
+ margin-left: 15px;
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ h2 { font-size: 1.3em; }
63
+ h3 { font-size: 1.1em; }
64
+ h4 { font-size: 1em; }
65
+ h5 { font-size: .9em; }
66
+ h6 { font-size: .8em; }
67
+
68
+ p {
69
+ margin: 0 0 .8em;
70
+ }
71
+
72
+ a {
73
+ color: $link-color;
74
+
75
+ &:hover {
76
+ color: darken($link-color, 10%);
77
+ }
78
+
79
+ &,
80
+ &:hover {
81
+ text-decoration: none;
82
+ }
83
+
84
+ &[name] {
85
+ display: block;
86
+ padding-top: 15px;
87
+ }
88
+ }
89
+
90
+ .content {
91
+ *:not(a) {
92
+ & > img:not([class]) {
93
+ border: 1px solid $border-accent-color;
94
+ padding: 4px;
95
+ background-color: #fff;
96
+ border-radius: 2px;
97
+ display: block;
98
+ max-width: 100%;
99
+ height: auto;
100
+ }
101
+ }
102
+
103
+ ul:not([class]) {
104
+ li {
105
+ padding-bottom: 5px;
106
+ }
107
+ }
108
+ }
109
+
110
+ .hidden {
111
+ display: none;
112
+ }