mount_doc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +16 -0
  3. data/Guardfile +33 -0
  4. data/LICENSE +22 -0
  5. data/README.md +49 -0
  6. data/Rakefile +2 -0
  7. data/app/assets/stylesheets/mount_doc.css.scss +148 -0
  8. data/app/controllers/mount_doc/application_controller.rb +6 -0
  9. data/app/controllers/mount_doc/mount_doc_controller.rb +77 -0
  10. data/app/helpers/mount_doc/mount_doc_helper.rb +104 -0
  11. data/app/views/layouts/mount_doc.slim +55 -0
  12. data/app/views/mount_doc/mount_doc/action_doc.slim +57 -0
  13. data/app/views/mount_doc/mount_doc/controller_doc.slim +14 -0
  14. data/app/views/mount_doc/mount_doc/index.slim +1 -0
  15. data/app/views/mount_doc/mount_doc/not_found.slim +3 -0
  16. data/config/routes.rb +7 -0
  17. data/lib/mount_doc.rb +11 -0
  18. data/lib/mount_doc/config.rb +74 -0
  19. data/lib/mount_doc/document.rb +38 -0
  20. data/lib/mount_doc/rails.rb +6 -0
  21. data/lib/mount_doc/rails/engine.rb +10 -0
  22. data/lib/mount_doc/rails/generators.rb +5 -0
  23. data/lib/mount_doc/rails/generators/initialize_generator.rb +5 -0
  24. data/lib/mount_doc/rails/route_set.rb +19 -0
  25. data/lib/mount_doc/string_patch.rb +1 -0
  26. data/lib/mount_doc/version.rb +3 -0
  27. data/mount_doc.gemspec +23 -0
  28. data/spec/lib/mount_doc/config_spec.rb +73 -0
  29. data/spec/lib/mount_doc/document_spec.rb +17 -0
  30. data/spec/lib/mount_doc/rails/engine_spec.rb +7 -0
  31. data/spec/lib/mount_doc/rails/route_set_spec.rb +16 -0
  32. data/spec/lib/mount_doc/rails_spec.rb +16 -0
  33. data/spec/mock/rails_3.2.3/.gitignore +15 -0
  34. data/spec/mock/rails_3.2.3/Gemfile +40 -0
  35. data/spec/mock/rails_3.2.3/README.rdoc +261 -0
  36. data/spec/mock/rails_3.2.3/Rakefile +7 -0
  37. data/spec/mock/rails_3.2.3/app/assets/images/rails.png +0 -0
  38. data/spec/mock/rails_3.2.3/app/assets/javascripts/api/documents.js.coffee +3 -0
  39. data/spec/mock/rails_3.2.3/app/assets/javascripts/application.js +15 -0
  40. data/spec/mock/rails_3.2.3/app/assets/javascripts/users.js.coffee +3 -0
  41. data/spec/mock/rails_3.2.3/app/assets/stylesheets/api/documents.css.scss +3 -0
  42. data/spec/mock/rails_3.2.3/app/assets/stylesheets/application.css +13 -0
  43. data/spec/mock/rails_3.2.3/app/assets/stylesheets/scaffolds.css.scss +56 -0
  44. data/spec/mock/rails_3.2.3/app/assets/stylesheets/users.css.scss +3 -0
  45. data/spec/mock/rails_3.2.3/app/controllers/api/documents_controller.rb +121 -0
  46. data/spec/mock/rails_3.2.3/app/controllers/application_controller.rb +3 -0
  47. data/spec/mock/rails_3.2.3/app/controllers/users_controller.rb +83 -0
  48. data/spec/mock/rails_3.2.3/app/helpers/api/documents_helper.rb +2 -0
  49. data/spec/mock/rails_3.2.3/app/helpers/application_helper.rb +2 -0
  50. data/spec/mock/rails_3.2.3/app/helpers/users_helper.rb +2 -0
  51. data/spec/mock/rails_3.2.3/app/mailers/.gitkeep +0 -0
  52. data/spec/mock/rails_3.2.3/app/models/.gitkeep +0 -0
  53. data/spec/mock/rails_3.2.3/app/models/api.rb +5 -0
  54. data/spec/mock/rails_3.2.3/app/models/api/document.rb +3 -0
  55. data/spec/mock/rails_3.2.3/app/models/user.rb +3 -0
  56. data/spec/mock/rails_3.2.3/app/views/api/documents/_form.html.erb +17 -0
  57. data/spec/mock/rails_3.2.3/app/views/api/documents/edit.html.erb +6 -0
  58. data/spec/mock/rails_3.2.3/app/views/api/documents/index.html.erb +21 -0
  59. data/spec/mock/rails_3.2.3/app/views/api/documents/new.html.erb +5 -0
  60. data/spec/mock/rails_3.2.3/app/views/api/documents/show.html.erb +5 -0
  61. data/spec/mock/rails_3.2.3/app/views/layouts/application.html.erb +14 -0
  62. data/spec/mock/rails_3.2.3/app/views/users/_form.html.erb +17 -0
  63. data/spec/mock/rails_3.2.3/app/views/users/edit.html.erb +6 -0
  64. data/spec/mock/rails_3.2.3/app/views/users/index.html.erb +21 -0
  65. data/spec/mock/rails_3.2.3/app/views/users/new.html.erb +5 -0
  66. data/spec/mock/rails_3.2.3/app/views/users/show.html.erb +5 -0
  67. data/spec/mock/rails_3.2.3/config.ru +4 -0
  68. data/spec/mock/rails_3.2.3/config/application.rb +65 -0
  69. data/spec/mock/rails_3.2.3/config/boot.rb +6 -0
  70. data/spec/mock/rails_3.2.3/config/database.yml +25 -0
  71. data/spec/mock/rails_3.2.3/config/environment.rb +5 -0
  72. data/spec/mock/rails_3.2.3/config/environments/development.rb +38 -0
  73. data/spec/mock/rails_3.2.3/config/environments/production.rb +67 -0
  74. data/spec/mock/rails_3.2.3/config/environments/test.rb +37 -0
  75. data/spec/mock/rails_3.2.3/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/mock/rails_3.2.3/config/initializers/inflections.rb +15 -0
  77. data/spec/mock/rails_3.2.3/config/initializers/mime_types.rb +5 -0
  78. data/spec/mock/rails_3.2.3/config/initializers/secret_token.rb +7 -0
  79. data/spec/mock/rails_3.2.3/config/initializers/session_store.rb +8 -0
  80. data/spec/mock/rails_3.2.3/config/initializers/wrap_parameters.rb +14 -0
  81. data/spec/mock/rails_3.2.3/config/locales/en.yml +5 -0
  82. data/spec/mock/rails_3.2.3/config/routes.rb +63 -0
  83. data/spec/mock/rails_3.2.3/db/migrate/20120423193431_create_users.rb +8 -0
  84. data/spec/mock/rails_3.2.3/db/migrate/20120426181820_create_api_documents.rb +8 -0
  85. data/spec/mock/rails_3.2.3/db/schema.rb +21 -0
  86. data/spec/mock/rails_3.2.3/db/seeds.rb +7 -0
  87. data/spec/mock/rails_3.2.3/doc/README_FOR_APP +2 -0
  88. data/spec/mock/rails_3.2.3/doc//343/201/206/343/202/223/343/201/223/343/201/227/343/201/237/343/201/204.rdoc +3 -0
  89. data/spec/mock/rails_3.2.3/lib/assets/.gitkeep +0 -0
  90. data/spec/mock/rails_3.2.3/lib/tasks/.gitkeep +0 -0
  91. data/spec/mock/rails_3.2.3/log/.gitkeep +0 -0
  92. data/spec/mock/rails_3.2.3/public/404.html +26 -0
  93. data/spec/mock/rails_3.2.3/public/422.html +26 -0
  94. data/spec/mock/rails_3.2.3/public/500.html +25 -0
  95. data/spec/mock/rails_3.2.3/public/favicon.ico +0 -0
  96. data/spec/mock/rails_3.2.3/public/index.html +241 -0
  97. data/spec/mock/rails_3.2.3/public/robots.txt +5 -0
  98. data/spec/mock/rails_3.2.3/script/rails +6 -0
  99. data/spec/mock/rails_3.2.3/vendor/assets/javascripts/.gitkeep +0 -0
  100. data/spec/mock/rails_3.2.3/vendor/assets/stylesheets/.gitkeep +0 -0
  101. data/spec/mock/rails_3.2.3/vendor/plugins/.gitkeep +0 -0
  102. data/spec/requests/mount_doc_request_spec.rb +34 -0
  103. data/spec/requests/users_request_spec.rb +10 -0
  104. data/spec/spec_helper.rb +34 -0
  105. metadata +313 -0
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ !spec/mock/rails*/doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in mount_doc.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'test-unit', require: 'test/unit'
8
+ gem 'rails'
9
+ gem 'rspec-rails'
10
+ gem 'sqlite3'
11
+ gem 'guard-rspec'
12
+ gem 'guard-spork'
13
+ gem 'guard-bundler'
14
+ gem 'growl', require: false
15
+ gem 'rb-readline'
16
+ end
@@ -0,0 +1,33 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'bundler' do
5
+ watch('Gemfile')
6
+ watch(/^.+\.gemspec/)
7
+ end
8
+
9
+ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
10
+ watch(%r{spec/mock/rails_.*?/config/application.rb})
11
+ watch(%r{spec/mock/rails_.*?/config/environment.rb})
12
+ watch(%r{^spec/mock/rails_.*?/config/environments/.+\.rb$})
13
+ watch(%r{^spec/mock/rails_.*?/config/initializers/.+\.rb$})
14
+ watch('Gemfile')
15
+ watch('Gemfile.lock')
16
+ watch('spec/spec_helper.rb') { :rspec }
17
+ watch(%r{features/support/}) { :cucumber }
18
+ end
19
+
20
+ guard 'rspec', version: 2, cli: '--color -f doc --drb --fail-fast', all_after_pass: false, all_on_start: false do
21
+ watch(%r{^spec/.+_spec\.rb$})
22
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
23
+ watch('spec/spec_helper.rb') { "spec" }
24
+
25
+ # Rails example
26
+ watch(%r{^spec/mock/rails_.*?/app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ watch(%r{^spec/mock/rails_.*?/app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
28
+ watch(%r{^spec/mock/rails_.*?/app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
29
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
30
+ watch(%r{spec/mock/rails_.*?/config/routes.rb}) { "spec/routing" }
31
+ watch(%r{spec/mock/rails_.*?/app/controllers/application_controller.rb}) { "spec/controllers" }
32
+ end
33
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sho Kusano
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # MountDoc
2
+
3
+ Railsアプリケーション組み込み型ドキュメント生成ツール
4
+
5
+ ## Configure
6
+
7
+ `MountDoc::Config`に書き込み
8
+
9
+ - `auto_mount`: 自動でマウントするか否か(default: false)
10
+ - `auto_mount_path`: 自動でマウントする先のパス(default: /doc)
11
+ - `visible_components`: インデックスに表示する種類(default: [:files, :urls, :controllers])
12
+ - `doc_file_path`: 静的ドキュメントファイルがあるパス(default: doc)
13
+ - `markup`: コメントサマリの書式(default: rdoc)
14
+ - 違うものを指定する場合はそれに応じたgemの導入が必要
15
+ - `markdown`: gem install github-markdown
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ gem 'mount_doc'
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install mount_doc
30
+
31
+ And added config/routes.rb
32
+
33
+ mount MountDoc::Engine => '/prefix'
34
+
35
+ access to http://localhost:3000/prefix !
36
+
37
+ ## Usage
38
+
39
+ 1. Installation
40
+ 2. Mount
41
+ 3. Configure
42
+
43
+ ## Contributing
44
+
45
+ 1. Fork it
46
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
47
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
48
+ 4. Push to the branch (`git push origin my-new-feature`)
49
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,148 @@
1
+ body {
2
+ padding-left: 400px;
3
+ font-size: 14px;
4
+ }
5
+
6
+ #main {
7
+ padding: 20px 30px;
8
+ }
9
+
10
+ #side-index {
11
+ position: fixed;
12
+ top: 0;
13
+ left: 0;
14
+ margin: 0;
15
+ padding: 0;
16
+ width: 400px;
17
+ height: 100%;
18
+ background-color: #e8ecef;
19
+ box-shadow: 0 0 10px rgba(0,0,0,0.4);
20
+ overflow-y: scroll;
21
+ }
22
+
23
+ #side-index > div {
24
+ padding: 0 20px;
25
+ margin: 20px 0;
26
+
27
+ h6 {
28
+ text-align: center;
29
+ font-size: 15px;
30
+ }
31
+ }
32
+
33
+ #side-index ul {
34
+ margin: 0;
35
+ padding: 0;
36
+ line-height: 1.5;
37
+ }
38
+
39
+ #side-index li {
40
+ list-style: none outside;
41
+ }
42
+
43
+ #side-index a {
44
+ display: block;
45
+ margin-left: 3.5em;
46
+ text-decoration: none;
47
+ }
48
+
49
+ span.method {
50
+ display: inline-block;
51
+ margin-left: -3.5em;
52
+ margin-right: 0.5em;
53
+ font-family: Ricty, Inconsolata, Menlo, Courier, monospace;
54
+ width: 3em;
55
+ text-align: right;
56
+ }
57
+
58
+ #search {
59
+ input {
60
+ display: inline-block;
61
+ border: none;
62
+ line-height: 1.5;
63
+ font-size: 13px;
64
+ margin: 0;
65
+ padding: 3px 5px;
66
+ border: 1px solid #9ea1a3;
67
+ border-radius: 4px;
68
+ width: 358px;
69
+ }
70
+ }
71
+
72
+ h2 {
73
+ font-size: 120%;
74
+ margin-top: 2em;
75
+ margin-bottom: 0;
76
+ }
77
+
78
+ h3 {
79
+ font-size: 100%;
80
+ }
81
+
82
+ ul.urls {
83
+ margin: 0;
84
+ padding: 0;
85
+ font-size: 13px;
86
+
87
+ li {
88
+ padding: 0;
89
+ list-style: none outside;
90
+
91
+ span.method {
92
+ margin-left: 0;
93
+ text-align: center;
94
+ background-color: #e8ecef;
95
+ width: 4em;
96
+ border: 1px solid gray;
97
+ border-radius: 3px;
98
+ }
99
+ }
100
+ }
101
+
102
+ p.deprecated {
103
+ margin: 0;
104
+ font-size: 80%;
105
+ color: #c9171e;
106
+ font-weight: bold;
107
+ }
108
+ p.deprecated + * {
109
+ margin-top: 0;
110
+ }
111
+
112
+ pre {
113
+ position: relative;
114
+ padding: 0.5em;
115
+ background-color: #e8ecef;
116
+ border-radius: 4px;
117
+ overflow: auto;
118
+
119
+ .type {
120
+ display: block;
121
+ padding: 5px 10px;
122
+ position: absolute;
123
+ top: 0;
124
+ right: 0;
125
+ font-size: 12px;
126
+ background-color: rgba(0, 0, 0, 0.4);
127
+ border-radius: 0 4px 0 4px;
128
+ color: white;
129
+ }
130
+ }
131
+
132
+ ul ul {
133
+ padding-left: 1em;
134
+ }
135
+
136
+ .line-numbers {
137
+ display: inline-block;
138
+ margin-right: 0.5em;
139
+ padding-right: 0.3em;
140
+ width: 2em;
141
+ text-align: right;
142
+ border-right: 3px solid #999;
143
+
144
+ a {
145
+ color: #666;
146
+ text-decoration: none;
147
+ }
148
+ }
@@ -0,0 +1,6 @@
1
+ require 'mount_doc'
2
+
3
+ module MountDoc
4
+ class ApplicationController < ActionController::Base
5
+ end
6
+ end
@@ -0,0 +1,77 @@
1
+ require 'mount_doc'
2
+ require 'slim'
3
+ require 'github/markup'
4
+
5
+ module MountDoc
6
+ class MountDocController < ApplicationController
7
+ include MountDocHelper
8
+
9
+ layout 'mount_doc'
10
+
11
+ def index
12
+ @page_title = 'Index'
13
+
14
+ readme_file = Dir[File.join(::Rails.root, '/README.*')].first
15
+
16
+ render text: GitHub::Markup.render(readme_file), layout: true
17
+ end
18
+
19
+ def controller_doc
20
+ @controller_name = params[:id]
21
+
22
+ file_name = File.join(::Rails.root, 'app/controllers', "#{@controller_name.gsub('::', '/')}_controller.rb")
23
+ unless File.exists?(file_name)
24
+ not_found
25
+ return
26
+ end
27
+
28
+ @document = MountDoc::Document.new(:controller, @controller_name).doc_object
29
+ @page_title = @controller_name.gsub('::', '/').camelize
30
+ end
31
+
32
+ def action_doc
33
+ @controller_name = params[:ctrl_id]
34
+ @action_name = params[:id]
35
+
36
+ file_name = File.join(::Rails.root, 'app/controllers', "#{@controller_name.gsub('::', '/')}_controller.rb")
37
+ unless File.exists?(file_name)
38
+ not_found
39
+ return
40
+ end
41
+
42
+ @controller_document = MountDoc::Document.new(:controller, @controller_name).doc_object
43
+ @document = @controller_document.meths.select{|meth| meth.name.to_s == @action_name.to_s }.first
44
+
45
+ unless @document
46
+ not_found
47
+ return
48
+ end
49
+
50
+ @page_title = @controller_name.gsub('::', '/').camelize + '#' + @action_name
51
+ end
52
+
53
+ def model_doc
54
+
55
+ end
56
+
57
+ def file_doc
58
+ file_name = params[:id]
59
+ file_name += '.' + params[:format] if params.has_key?(:format)
60
+ file_name = File.join(::Rails.root, MountDoc::Config.doc_file_path, file_name)
61
+
62
+ if File.exists?(file_name)
63
+ @page_title = File.basename(file_name)
64
+ render text: GitHub::Markup.render(file_name), layout: true
65
+ else
66
+ not_found
67
+ return
68
+ end
69
+
70
+ end
71
+
72
+ private
73
+ def not_found
74
+ render :not_found, status: 404
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,104 @@
1
+ require 'mount_doc'
2
+ require 'coderay'
3
+
4
+ module MountDoc
5
+ module MountDocHelper
6
+ extend ::Rails.application.routes.url_helpers
7
+ extend ::Rails.application.routes.mounted_helpers
8
+
9
+ def mount_doc_config
10
+ MountDoc::Config
11
+ end
12
+
13
+ def doc_dir
14
+ @doc_dir ||= File.expand_path(mount_doc_config.doc_file_path, ::Rails.application.root)
15
+ end
16
+
17
+ def files
18
+ @files ||= Dir[File.join(doc_dir, '**/*')].reject { |fn|
19
+ File.directory?(fn)
20
+ }.map { |fn|
21
+ fn.sub(%r{^#{doc_dir}/},'').force_encoding('utf-8')
22
+ }
23
+ end
24
+
25
+ HTTP_Methods = [
26
+ :GET,
27
+ :POST,
28
+ :PUT,
29
+ :DELETE
30
+ ].join("\n")
31
+ def routes
32
+ @routes ||= ::Rails.application.routes.routes.to_a.select { |route|
33
+ controllers.include?(route.defaults[:controller].to_s)
34
+ }.map {|route|
35
+ method = HTTP_Methods.match(route.verb).to_s
36
+ method = 'ANY' if method.empty?
37
+ {
38
+ method: method,
39
+ path: route.path.spec
40
+ }.merge(route.defaults)
41
+ }
42
+ end
43
+
44
+ def routes_for(controller, action)
45
+ puts "#{controller}##{action}"
46
+ _routes = routes.dup.select{ |route|
47
+ route[:controller].to_s.to_sym == controller.to_s.to_sym && route[:action].to_s.to_sym == action.to_s.to_sym
48
+ }
49
+ _routes
50
+ end
51
+
52
+ def controllers
53
+ @controllers ||= begin
54
+ Dir[File.join(::Rails.application.root, 'app/controllers/**/*_controller.rb')].map { |cn|
55
+ cn.sub(%r{_controller\.rb$}, '').sub(%r{^#{::Rails.application.root}/app/controllers/}, '')
56
+ }
57
+ end
58
+ end
59
+
60
+ def models
61
+ @models ||= begin
62
+ Dir[File.join(::Rails.application.root, 'app/models/**/*.rb')].map { |cn|
63
+ cn.sub(%r{\.rb$}, '').sub(%r{^#{::Rails.application.root}/app/models/}, '')
64
+ }
65
+ end
66
+ end
67
+
68
+ def actions(class_doc)
69
+ class_doc.meths.select{ |meth|
70
+ meth.scope == :instance
71
+ }.map{ |meth|
72
+ { method: meth,
73
+ routes: routes_for(@controller_name.gsub('::', '/'), meth.name)
74
+ }
75
+ }.select { |hash|
76
+ hash[:routes].size > 0
77
+ }
78
+ end
79
+
80
+ def markup(text)
81
+ case MountDoc::Config.markup
82
+ when :markdown
83
+ markdown(text)
84
+ else
85
+ rdoc(text)
86
+ end
87
+ end
88
+
89
+ def markdown(text)
90
+ GitHub::Markup.render('tmp.markdown', text)
91
+ end
92
+
93
+ def rdoc(text)
94
+ RDoc::Markup::ToHtml.new.convert(text)
95
+ end
96
+
97
+ def syntaxhighlight(lang, text)
98
+ CodeRay.scan(text, lang.to_s.downcase.to_sym).html({
99
+ css: :style,
100
+ line_numbers: :inline
101
+ })
102
+ end
103
+ end
104
+ end