hyper-pro-gem 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. checksums.yaml +7 -0
  2. data/hyper-pro-gem.gemspec +12 -0
  3. data/yard-0.9.44/CHANGELOG.md +983 -0
  4. data/yard-0.9.44/LEGAL +94 -0
  5. data/yard-0.9.44/LICENSE +22 -0
  6. data/yard-0.9.44/README.md +329 -0
  7. data/yard-0.9.44/bin/yard +13 -0
  8. data/yard-0.9.44/bin/yardoc +13 -0
  9. data/yard-0.9.44/bin/yri +13 -0
  10. data/yard-0.9.44/docs/CodeObjects.md +115 -0
  11. data/yard-0.9.44/docs/GettingStarted.md +705 -0
  12. data/yard-0.9.44/docs/Handlers.md +152 -0
  13. data/yard-0.9.44/docs/Overview.md +61 -0
  14. data/yard-0.9.44/docs/Parser.md +166 -0
  15. data/yard-0.9.44/docs/Tags.md +304 -0
  16. data/yard-0.9.44/docs/TagsArch.md +123 -0
  17. data/yard-0.9.44/docs/Templates.md +497 -0
  18. data/yard-0.9.44/docs/WhatsNew.md +1297 -0
  19. data/yard-0.9.44/docs/images/code-objects-class-diagram.png +0 -0
  20. data/yard-0.9.44/docs/images/handlers-class-diagram.png +0 -0
  21. data/yard-0.9.44/docs/images/overview-class-diagram.png +0 -0
  22. data/yard-0.9.44/docs/images/parser-class-diagram.png +0 -0
  23. data/yard-0.9.44/docs/images/tags-class-diagram.png +0 -0
  24. data/yard-0.9.44/docs/templates/default/fulldoc/html/full_list_tag.erb +9 -0
  25. data/yard-0.9.44/docs/templates/default/fulldoc/html/setup.rb +6 -0
  26. data/yard-0.9.44/docs/templates/default/layout/html/setup.rb +9 -0
  27. data/yard-0.9.44/docs/templates/default/layout/html/tag_list.erb +11 -0
  28. data/yard-0.9.44/docs/templates/default/yard_tags/html/list.erb +18 -0
  29. data/yard-0.9.44/docs/templates/default/yard_tags/html/setup.rb +26 -0
  30. data/yard-0.9.44/docs/templates/plugin.rb +70 -0
  31. data/yard-0.9.44/lib/rubygems_plugin.rb +9 -0
  32. data/yard-0.9.44/lib/yard/autoload.rb +328 -0
  33. data/yard-0.9.44/lib/yard/cli/command.rb +85 -0
  34. data/yard-0.9.44/lib/yard/cli/command_parser.rb +93 -0
  35. data/yard-0.9.44/lib/yard/cli/config.rb +198 -0
  36. data/yard-0.9.44/lib/yard/cli/diff.rb +278 -0
  37. data/yard-0.9.44/lib/yard/cli/display.rb +69 -0
  38. data/yard-0.9.44/lib/yard/cli/gems.rb +84 -0
  39. data/yard-0.9.44/lib/yard/cli/graph.rb +125 -0
  40. data/yard-0.9.44/lib/yard/cli/help.rb +20 -0
  41. data/yard-0.9.44/lib/yard/cli/i18n.rb +70 -0
  42. data/yard-0.9.44/lib/yard/cli/list.rb +23 -0
  43. data/yard-0.9.44/lib/yard/cli/markup_types.rb +32 -0
  44. data/yard-0.9.44/lib/yard/cli/server.rb +266 -0
  45. data/yard-0.9.44/lib/yard/cli/stats.rb +234 -0
  46. data/yard-0.9.44/lib/yard/cli/yardoc.rb +791 -0
  47. data/yard-0.9.44/lib/yard/cli/yardopts_command.rb +110 -0
  48. data/yard-0.9.44/lib/yard/cli/yri.rb +215 -0
  49. data/yard-0.9.44/lib/yard/code_objects/base.rb +626 -0
  50. data/yard-0.9.44/lib/yard/code_objects/class_object.rb +146 -0
  51. data/yard-0.9.44/lib/yard/code_objects/class_variable_object.rb +11 -0
  52. data/yard-0.9.44/lib/yard/code_objects/constant_object.rb +16 -0
  53. data/yard-0.9.44/lib/yard/code_objects/extended_method_object.rb +24 -0
  54. data/yard-0.9.44/lib/yard/code_objects/extra_file_object.rb +135 -0
  55. data/yard-0.9.44/lib/yard/code_objects/macro_object.rb +171 -0
  56. data/yard-0.9.44/lib/yard/code_objects/method_object.rb +196 -0
  57. data/yard-0.9.44/lib/yard/code_objects/module_object.rb +21 -0
  58. data/yard-0.9.44/lib/yard/code_objects/namespace_mapper.rb +141 -0
  59. data/yard-0.9.44/lib/yard/code_objects/namespace_object.rb +200 -0
  60. data/yard-0.9.44/lib/yard/code_objects/proxy.rb +245 -0
  61. data/yard-0.9.44/lib/yard/code_objects/root_object.rb +19 -0
  62. data/yard-0.9.44/lib/yard/config.rb +274 -0
  63. data/yard-0.9.44/lib/yard/core_ext/array.rb +16 -0
  64. data/yard-0.9.44/lib/yard/core_ext/file.rb +69 -0
  65. data/yard-0.9.44/lib/yard/core_ext/hash.rb +16 -0
  66. data/yard-0.9.44/lib/yard/core_ext/insertion.rb +63 -0
  67. data/yard-0.9.44/lib/yard/core_ext/module.rb +11 -0
  68. data/yard-0.9.44/lib/yard/core_ext/string.rb +68 -0
  69. data/yard-0.9.44/lib/yard/core_ext/symbol_hash.rb +75 -0
  70. data/yard-0.9.44/lib/yard/docstring.rb +386 -0
  71. data/yard-0.9.44/lib/yard/docstring_parser.rb +344 -0
  72. data/yard-0.9.44/lib/yard/gem_index.rb +29 -0
  73. data/yard-0.9.44/lib/yard/globals.rb +22 -0
  74. data/yard-0.9.44/lib/yard/handlers/base.rb +617 -0
  75. data/yard-0.9.44/lib/yard/handlers/c/alias_handler.rb +16 -0
  76. data/yard-0.9.44/lib/yard/handlers/c/attribute_handler.rb +13 -0
  77. data/yard-0.9.44/lib/yard/handlers/c/base.rb +164 -0
  78. data/yard-0.9.44/lib/yard/handlers/c/class_handler.rb +27 -0
  79. data/yard-0.9.44/lib/yard/handlers/c/constant_handler.rb +13 -0
  80. data/yard-0.9.44/lib/yard/handlers/c/handler_methods.rb +212 -0
  81. data/yard-0.9.44/lib/yard/handlers/c/init_handler.rb +20 -0
  82. data/yard-0.9.44/lib/yard/handlers/c/method_handler.rb +45 -0
  83. data/yard-0.9.44/lib/yard/handlers/c/mixin_handler.rb +21 -0
  84. data/yard-0.9.44/lib/yard/handlers/c/module_handler.rb +17 -0
  85. data/yard-0.9.44/lib/yard/handlers/c/override_comment_handler.rb +31 -0
  86. data/yard-0.9.44/lib/yard/handlers/c/path_handler.rb +11 -0
  87. data/yard-0.9.44/lib/yard/handlers/c/struct_handler.rb +13 -0
  88. data/yard-0.9.44/lib/yard/handlers/c/symbol_handler.rb +8 -0
  89. data/yard-0.9.44/lib/yard/handlers/common/method_handler.rb +19 -0
  90. data/yard-0.9.44/lib/yard/handlers/processor.rb +200 -0
  91. data/yard-0.9.44/lib/yard/handlers/rbs/attribute_handler.rb +79 -0
  92. data/yard-0.9.44/lib/yard/handlers/rbs/base.rb +38 -0
  93. data/yard-0.9.44/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  94. data/yard-0.9.44/lib/yard/handlers/rbs/method_handler.rb +327 -0
  95. data/yard-0.9.44/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  96. data/yard-0.9.44/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  97. data/yard-0.9.44/lib/yard/handlers/ruby/alias_handler.rb +45 -0
  98. data/yard-0.9.44/lib/yard/handlers/ruby/attribute_handler.rb +90 -0
  99. data/yard-0.9.44/lib/yard/handlers/ruby/base.rb +165 -0
  100. data/yard-0.9.44/lib/yard/handlers/ruby/class_condition_handler.rb +92 -0
  101. data/yard-0.9.44/lib/yard/handlers/ruby/class_handler.rb +119 -0
  102. data/yard-0.9.44/lib/yard/handlers/ruby/class_variable_handler.rb +17 -0
  103. data/yard-0.9.44/lib/yard/handlers/ruby/comment_handler.rb +10 -0
  104. data/yard-0.9.44/lib/yard/handlers/ruby/constant_handler.rb +73 -0
  105. data/yard-0.9.44/lib/yard/handlers/ruby/decorator_handler_methods.rb +123 -0
  106. data/yard-0.9.44/lib/yard/handlers/ruby/dsl_handler.rb +15 -0
  107. data/yard-0.9.44/lib/yard/handlers/ruby/dsl_handler_methods.rb +96 -0
  108. data/yard-0.9.44/lib/yard/handlers/ruby/exception_handler.rb +27 -0
  109. data/yard-0.9.44/lib/yard/handlers/ruby/extend_handler.rb +22 -0
  110. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/alias_handler.rb +37 -0
  111. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/attribute_handler.rb +65 -0
  112. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/base.rb +245 -0
  113. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +83 -0
  114. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/class_handler.rb +113 -0
  115. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +15 -0
  116. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/comment_handler.rb +10 -0
  117. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/constant_handler.rb +29 -0
  118. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/dsl_handler.rb +17 -0
  119. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/exception_handler.rb +13 -0
  120. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/extend_handler.rb +21 -0
  121. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/method_handler.rb +90 -0
  122. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/mixin_handler.rb +39 -0
  123. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/module_function_handler.rb +19 -0
  124. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/module_handler.rb +12 -0
  125. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +22 -0
  126. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/private_constant_handler.rb +22 -0
  127. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/visibility_handler.rb +18 -0
  128. data/yard-0.9.44/lib/yard/handlers/ruby/legacy/yield_handler.rb +29 -0
  129. data/yard-0.9.44/lib/yard/handlers/ruby/method_condition_handler.rb +9 -0
  130. data/yard-0.9.44/lib/yard/handlers/ruby/method_handler.rb +104 -0
  131. data/yard-0.9.44/lib/yard/handlers/ruby/mixin_handler.rb +61 -0
  132. data/yard-0.9.44/lib/yard/handlers/ruby/module_function_handler.rb +39 -0
  133. data/yard-0.9.44/lib/yard/handlers/ruby/module_handler.rb +12 -0
  134. data/yard-0.9.44/lib/yard/handlers/ruby/private_class_method_handler.rb +14 -0
  135. data/yard-0.9.44/lib/yard/handlers/ruby/private_constant_handler.rb +43 -0
  136. data/yard-0.9.44/lib/yard/handlers/ruby/public_class_method_handler.rb +14 -0
  137. data/yard-0.9.44/lib/yard/handlers/ruby/struct_handler_methods.rb +143 -0
  138. data/yard-0.9.44/lib/yard/handlers/ruby/visibility_handler.rb +35 -0
  139. data/yard-0.9.44/lib/yard/handlers/ruby/yield_handler.rb +31 -0
  140. data/yard-0.9.44/lib/yard/i18n/locale.rb +67 -0
  141. data/yard-0.9.44/lib/yard/i18n/message.rb +57 -0
  142. data/yard-0.9.44/lib/yard/i18n/messages.rb +56 -0
  143. data/yard-0.9.44/lib/yard/i18n/po_parser.rb +61 -0
  144. data/yard-0.9.44/lib/yard/i18n/pot_generator.rb +290 -0
  145. data/yard-0.9.44/lib/yard/i18n/text.rb +173 -0
  146. data/yard-0.9.44/lib/yard/logging.rb +260 -0
  147. data/yard-0.9.44/lib/yard/open_struct.rb +67 -0
  148. data/yard-0.9.44/lib/yard/options.rb +217 -0
  149. data/yard-0.9.44/lib/yard/parser/base.rb +57 -0
  150. data/yard-0.9.44/lib/yard/parser/c/c_parser.rb +235 -0
  151. data/yard-0.9.44/lib/yard/parser/c/comment_parser.rb +134 -0
  152. data/yard-0.9.44/lib/yard/parser/c/statement.rb +66 -0
  153. data/yard-0.9.44/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  154. data/yard-0.9.44/lib/yard/parser/rbs/statement.rb +75 -0
  155. data/yard-0.9.44/lib/yard/parser/ruby/ast_node.rb +559 -0
  156. data/yard-0.9.44/lib/yard/parser/ruby/legacy/irb/slex.rb +294 -0
  157. data/yard-0.9.44/lib/yard/parser/ruby/legacy/ruby_lex.rb +1360 -0
  158. data/yard-0.9.44/lib/yard/parser/ruby/legacy/ruby_parser.rb +32 -0
  159. data/yard-0.9.44/lib/yard/parser/ruby/legacy/statement.rb +68 -0
  160. data/yard-0.9.44/lib/yard/parser/ruby/legacy/statement_list.rb +394 -0
  161. data/yard-0.9.44/lib/yard/parser/ruby/legacy/token_list.rb +74 -0
  162. data/yard-0.9.44/lib/yard/parser/ruby/ruby_parser.rb +792 -0
  163. data/yard-0.9.44/lib/yard/parser/ruby/token_resolver.rb +158 -0
  164. data/yard-0.9.44/lib/yard/parser/source_parser.rb +526 -0
  165. data/yard-0.9.44/lib/yard/rake/yardoc_task.rb +81 -0
  166. data/yard-0.9.44/lib/yard/registry.rb +439 -0
  167. data/yard-0.9.44/lib/yard/registry_resolver.rb +225 -0
  168. data/yard-0.9.44/lib/yard/registry_store.rb +342 -0
  169. data/yard-0.9.44/lib/yard/rubygems/backports/LICENSE.txt +57 -0
  170. data/yard-0.9.44/lib/yard/rubygems/backports/MIT.txt +20 -0
  171. data/yard-0.9.44/lib/yard/rubygems/backports/gem.rb +10 -0
  172. data/yard-0.9.44/lib/yard/rubygems/backports/source_index.rb +365 -0
  173. data/yard-0.9.44/lib/yard/rubygems/backports.rb +10 -0
  174. data/yard-0.9.44/lib/yard/rubygems/doc_manager.rb +90 -0
  175. data/yard-0.9.44/lib/yard/rubygems/hook.rb +197 -0
  176. data/yard-0.9.44/lib/yard/rubygems/specification.rb +50 -0
  177. data/yard-0.9.44/lib/yard/serializers/base.rb +83 -0
  178. data/yard-0.9.44/lib/yard/serializers/file_system_serializer.rb +123 -0
  179. data/yard-0.9.44/lib/yard/serializers/process_serializer.rb +24 -0
  180. data/yard-0.9.44/lib/yard/serializers/stdout_serializer.rb +34 -0
  181. data/yard-0.9.44/lib/yard/serializers/yardoc_serializer.rb +152 -0
  182. data/yard-0.9.44/lib/yard/server/adapter.rb +100 -0
  183. data/yard-0.9.44/lib/yard/server/commands/base.rb +203 -0
  184. data/yard-0.9.44/lib/yard/server/commands/display_file_command.rb +29 -0
  185. data/yard-0.9.44/lib/yard/server/commands/display_object_command.rb +65 -0
  186. data/yard-0.9.44/lib/yard/server/commands/frames_command.rb +16 -0
  187. data/yard-0.9.44/lib/yard/server/commands/library_command.rb +187 -0
  188. data/yard-0.9.44/lib/yard/server/commands/library_index_command.rb +28 -0
  189. data/yard-0.9.44/lib/yard/server/commands/list_command.rb +25 -0
  190. data/yard-0.9.44/lib/yard/server/commands/root_request_command.rb +15 -0
  191. data/yard-0.9.44/lib/yard/server/commands/search_command.rb +79 -0
  192. data/yard-0.9.44/lib/yard/server/commands/static_file_command.rb +23 -0
  193. data/yard-0.9.44/lib/yard/server/commands/static_file_helpers.rb +60 -0
  194. data/yard-0.9.44/lib/yard/server/doc_server_helper.rb +91 -0
  195. data/yard-0.9.44/lib/yard/server/doc_server_serializer.rb +39 -0
  196. data/yard-0.9.44/lib/yard/server/http_utils.rb +512 -0
  197. data/yard-0.9.44/lib/yard/server/library_version.rb +277 -0
  198. data/yard-0.9.44/lib/yard/server/rack_adapter.rb +97 -0
  199. data/yard-0.9.44/lib/yard/server/router.rb +187 -0
  200. data/yard-0.9.44/lib/yard/server/static_caching.rb +77 -0
  201. data/yard-0.9.44/lib/yard/server/templates/default/fulldoc/html/css/custom.css +207 -0
  202. data/yard-0.9.44/lib/yard/server/templates/default/fulldoc/html/images/processing.gif +0 -0
  203. data/yard-0.9.44/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +203 -0
  204. data/yard-0.9.44/lib/yard/server/templates/default/layout/html/breadcrumb.erb +21 -0
  205. data/yard-0.9.44/lib/yard/server/templates/default/layout/html/script_setup.erb +7 -0
  206. data/yard-0.9.44/lib/yard/server/templates/default/layout/html/setup.rb +8 -0
  207. data/yard-0.9.44/lib/yard/server/templates/default/method_details/html/permalink.erb +6 -0
  208. data/yard-0.9.44/lib/yard/server/templates/default/method_details/html/setup.rb +5 -0
  209. data/yard-0.9.44/lib/yard/server/templates/doc_server/library_list/html/headers.erb +8 -0
  210. data/yard-0.9.44/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +13 -0
  211. data/yard-0.9.44/lib/yard/server/templates/doc_server/library_list/html/listing.erb +13 -0
  212. data/yard-0.9.44/lib/yard/server/templates/doc_server/library_list/html/setup.rb +6 -0
  213. data/yard-0.9.44/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -0
  214. data/yard-0.9.44/lib/yard/server/templates/doc_server/processing/html/processing.erb +58 -0
  215. data/yard-0.9.44/lib/yard/server/templates/doc_server/processing/html/setup.rb +4 -0
  216. data/yard-0.9.44/lib/yard/server/templates/doc_server/search/html/search.erb +18 -0
  217. data/yard-0.9.44/lib/yard/server/templates/doc_server/search/html/setup.rb +9 -0
  218. data/yard-0.9.44/lib/yard/server/webrick_adapter.rb +45 -0
  219. data/yard-0.9.44/lib/yard/server.rb +13 -0
  220. data/yard-0.9.44/lib/yard/tags/default_factory.rb +192 -0
  221. data/yard-0.9.44/lib/yard/tags/default_tag.rb +13 -0
  222. data/yard-0.9.44/lib/yard/tags/directives.rb +631 -0
  223. data/yard-0.9.44/lib/yard/tags/library.rb +633 -0
  224. data/yard-0.9.44/lib/yard/tags/option_tag.rb +13 -0
  225. data/yard-0.9.44/lib/yard/tags/overload_tag.rb +72 -0
  226. data/yard-0.9.44/lib/yard/tags/ref_tag.rb +8 -0
  227. data/yard-0.9.44/lib/yard/tags/ref_tag_list.rb +28 -0
  228. data/yard-0.9.44/lib/yard/tags/tag.rb +72 -0
  229. data/yard-0.9.44/lib/yard/tags/tag_format_error.rb +7 -0
  230. data/yard-0.9.44/lib/yard/tags/types_explainer.rb +288 -0
  231. data/yard-0.9.44/lib/yard/templates/engine.rb +185 -0
  232. data/yard-0.9.44/lib/yard/templates/erb_cache.rb +23 -0
  233. data/yard-0.9.44/lib/yard/templates/helpers/base_helper.rb +215 -0
  234. data/yard-0.9.44/lib/yard/templates/helpers/filter_helper.rb +27 -0
  235. data/yard-0.9.44/lib/yard/templates/helpers/html_helper.rb +688 -0
  236. data/yard-0.9.44/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +83 -0
  237. data/yard-0.9.44/lib/yard/templates/helpers/markup/html_entities.rb +2140 -0
  238. data/yard-0.9.44/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2131 -0
  239. data/yard-0.9.44/lib/yard/templates/helpers/markup/rdoc_markdown.rb +23 -0
  240. data/yard-0.9.44/lib/yard/templates/helpers/markup/rdoc_markup.rb +112 -0
  241. data/yard-0.9.44/lib/yard/templates/helpers/markup_helper.rb +175 -0
  242. data/yard-0.9.44/lib/yard/templates/helpers/method_helper.rb +77 -0
  243. data/yard-0.9.44/lib/yard/templates/helpers/module_helper.rb +21 -0
  244. data/yard-0.9.44/lib/yard/templates/helpers/text_helper.rb +112 -0
  245. data/yard-0.9.44/lib/yard/templates/helpers/uml_helper.rb +47 -0
  246. data/yard-0.9.44/lib/yard/templates/section.rb +103 -0
  247. data/yard-0.9.44/lib/yard/templates/template.rb +420 -0
  248. data/yard-0.9.44/lib/yard/templates/template_options.rb +91 -0
  249. data/yard-0.9.44/lib/yard/verifier.rb +151 -0
  250. data/yard-0.9.44/lib/yard/version.rb +6 -0
  251. data/yard-0.9.44/lib/yard.rb +75 -0
  252. data/yard-0.9.44/po/ja.po +31108 -0
  253. data/yard-0.9.44/templates/default/class/dot/setup.rb +7 -0
  254. data/yard-0.9.44/templates/default/class/dot/superklass.erb +3 -0
  255. data/yard-0.9.44/templates/default/class/html/constructor_details.erb +8 -0
  256. data/yard-0.9.44/templates/default/class/html/setup.rb +2 -0
  257. data/yard-0.9.44/templates/default/class/html/subclasses.erb +4 -0
  258. data/yard-0.9.44/templates/default/class/setup.rb +36 -0
  259. data/yard-0.9.44/templates/default/class/text/setup.rb +12 -0
  260. data/yard-0.9.44/templates/default/class/text/subclasses.erb +5 -0
  261. data/yard-0.9.44/templates/default/constant/text/header.erb +11 -0
  262. data/yard-0.9.44/templates/default/constant/text/setup.rb +4 -0
  263. data/yard-0.9.44/templates/default/docstring/html/abstract.erb +4 -0
  264. data/yard-0.9.44/templates/default/docstring/html/deprecated.erb +1 -0
  265. data/yard-0.9.44/templates/default/docstring/html/index.erb +5 -0
  266. data/yard-0.9.44/templates/default/docstring/html/note.erb +6 -0
  267. data/yard-0.9.44/templates/default/docstring/html/private.erb +4 -0
  268. data/yard-0.9.44/templates/default/docstring/html/returns_void.erb +1 -0
  269. data/yard-0.9.44/templates/default/docstring/html/text.erb +1 -0
  270. data/yard-0.9.44/templates/default/docstring/html/todo.erb +6 -0
  271. data/yard-0.9.44/templates/default/docstring/setup.rb +52 -0
  272. data/yard-0.9.44/templates/default/docstring/text/abstract.erb +2 -0
  273. data/yard-0.9.44/templates/default/docstring/text/deprecated.erb +2 -0
  274. data/yard-0.9.44/templates/default/docstring/text/index.erb +2 -0
  275. data/yard-0.9.44/templates/default/docstring/text/note.erb +4 -0
  276. data/yard-0.9.44/templates/default/docstring/text/private.erb +2 -0
  277. data/yard-0.9.44/templates/default/docstring/text/returns_void.erb +1 -0
  278. data/yard-0.9.44/templates/default/docstring/text/text.erb +1 -0
  279. data/yard-0.9.44/templates/default/docstring/text/todo.erb +4 -0
  280. data/yard-0.9.44/templates/default/fulldoc/html/css/common.css +1 -0
  281. data/yard-0.9.44/templates/default/fulldoc/html/css/full_list.css +206 -0
  282. data/yard-0.9.44/templates/default/fulldoc/html/css/style.css +1089 -0
  283. data/yard-0.9.44/templates/default/fulldoc/html/frames.erb +22 -0
  284. data/yard-0.9.44/templates/default/fulldoc/html/full_list.erb +40 -0
  285. data/yard-0.9.44/templates/default/fulldoc/html/full_list_class.erb +2 -0
  286. data/yard-0.9.44/templates/default/fulldoc/html/full_list_file.erb +7 -0
  287. data/yard-0.9.44/templates/default/fulldoc/html/full_list_method.erb +10 -0
  288. data/yard-0.9.44/templates/default/fulldoc/html/js/app.js +801 -0
  289. data/yard-0.9.44/templates/default/fulldoc/html/js/full_list.js +334 -0
  290. data/yard-0.9.44/templates/default/fulldoc/html/js/jquery.js +4 -0
  291. data/yard-0.9.44/templates/default/fulldoc/html/setup.rb +249 -0
  292. data/yard-0.9.44/templates/default/layout/dot/header.erb +6 -0
  293. data/yard-0.9.44/templates/default/layout/dot/setup.rb +15 -0
  294. data/yard-0.9.44/templates/default/layout/html/breadcrumb.erb +11 -0
  295. data/yard-0.9.44/templates/default/layout/html/files.erb +11 -0
  296. data/yard-0.9.44/templates/default/layout/html/footer.erb +5 -0
  297. data/yard-0.9.44/templates/default/layout/html/headers.erb +15 -0
  298. data/yard-0.9.44/templates/default/layout/html/index.erb +2 -0
  299. data/yard-0.9.44/templates/default/layout/html/layout.erb +26 -0
  300. data/yard-0.9.44/templates/default/layout/html/listing.erb +4 -0
  301. data/yard-0.9.44/templates/default/layout/html/objects.erb +32 -0
  302. data/yard-0.9.44/templates/default/layout/html/script_setup.erb +4 -0
  303. data/yard-0.9.44/templates/default/layout/html/search.erb +13 -0
  304. data/yard-0.9.44/templates/default/layout/html/setup.rb +89 -0
  305. data/yard-0.9.44/templates/default/method/html/header.erb +17 -0
  306. data/yard-0.9.44/templates/default/method/setup.rb +4 -0
  307. data/yard-0.9.44/templates/default/method/text/header.erb +1 -0
  308. data/yard-0.9.44/templates/default/method_details/html/header.erb +3 -0
  309. data/yard-0.9.44/templates/default/method_details/html/method_signature.erb +25 -0
  310. data/yard-0.9.44/templates/default/method_details/html/source.erb +10 -0
  311. data/yard-0.9.44/templates/default/method_details/setup.rb +11 -0
  312. data/yard-0.9.44/templates/default/method_details/text/header.erb +10 -0
  313. data/yard-0.9.44/templates/default/method_details/text/method_signature.erb +12 -0
  314. data/yard-0.9.44/templates/default/method_details/text/setup.rb +11 -0
  315. data/yard-0.9.44/templates/default/module/dot/child.erb +1 -0
  316. data/yard-0.9.44/templates/default/module/dot/dependencies.erb +3 -0
  317. data/yard-0.9.44/templates/default/module/dot/header.erb +6 -0
  318. data/yard-0.9.44/templates/default/module/dot/info.erb +14 -0
  319. data/yard-0.9.44/templates/default/module/dot/setup.rb +15 -0
  320. data/yard-0.9.44/templates/default/module/html/attribute_details.erb +10 -0
  321. data/yard-0.9.44/templates/default/module/html/attribute_summary.erb +8 -0
  322. data/yard-0.9.44/templates/default/module/html/box_info.erb +43 -0
  323. data/yard-0.9.44/templates/default/module/html/children.erb +8 -0
  324. data/yard-0.9.44/templates/default/module/html/constant_summary.erb +17 -0
  325. data/yard-0.9.44/templates/default/module/html/defines.erb +3 -0
  326. data/yard-0.9.44/templates/default/module/html/header.erb +5 -0
  327. data/yard-0.9.44/templates/default/module/html/inherited_attributes.erb +14 -0
  328. data/yard-0.9.44/templates/default/module/html/inherited_constants.erb +8 -0
  329. data/yard-0.9.44/templates/default/module/html/inherited_methods.erb +20 -0
  330. data/yard-0.9.44/templates/default/module/html/item_summary.erb +40 -0
  331. data/yard-0.9.44/templates/default/module/html/method_details_list.erb +9 -0
  332. data/yard-0.9.44/templates/default/module/html/method_summary.erb +22 -0
  333. data/yard-0.9.44/templates/default/module/html/methodmissing.erb +12 -0
  334. data/yard-0.9.44/templates/default/module/html/pre_docstring.erb +1 -0
  335. data/yard-0.9.44/templates/default/module/setup.rb +187 -0
  336. data/yard-0.9.44/templates/default/module/text/children.erb +10 -0
  337. data/yard-0.9.44/templates/default/module/text/class_meths_list.erb +8 -0
  338. data/yard-0.9.44/templates/default/module/text/extends.erb +8 -0
  339. data/yard-0.9.44/templates/default/module/text/header.erb +7 -0
  340. data/yard-0.9.44/templates/default/module/text/includes.erb +8 -0
  341. data/yard-0.9.44/templates/default/module/text/instance_meths_list.erb +8 -0
  342. data/yard-0.9.44/templates/default/module/text/setup.rb +13 -0
  343. data/yard-0.9.44/templates/default/onefile/html/files.erb +5 -0
  344. data/yard-0.9.44/templates/default/onefile/html/headers.erb +8 -0
  345. data/yard-0.9.44/templates/default/onefile/html/layout.erb +16 -0
  346. data/yard-0.9.44/templates/default/onefile/html/readme.erb +3 -0
  347. data/yard-0.9.44/templates/default/onefile/html/setup.rb +62 -0
  348. data/yard-0.9.44/templates/default/root/dot/child.erb +3 -0
  349. data/yard-0.9.44/templates/default/root/dot/setup.rb +6 -0
  350. data/yard-0.9.44/templates/default/root/html/setup.rb +2 -0
  351. data/yard-0.9.44/templates/default/tags/html/example.erb +11 -0
  352. data/yard-0.9.44/templates/default/tags/html/index.erb +3 -0
  353. data/yard-0.9.44/templates/default/tags/html/option.erb +24 -0
  354. data/yard-0.9.44/templates/default/tags/html/overload.erb +14 -0
  355. data/yard-0.9.44/templates/default/tags/html/see.erb +8 -0
  356. data/yard-0.9.44/templates/default/tags/html/tag.erb +20 -0
  357. data/yard-0.9.44/templates/default/tags/setup.rb +57 -0
  358. data/yard-0.9.44/templates/default/tags/text/example.erb +12 -0
  359. data/yard-0.9.44/templates/default/tags/text/index.erb +1 -0
  360. data/yard-0.9.44/templates/default/tags/text/option.erb +20 -0
  361. data/yard-0.9.44/templates/default/tags/text/overload.erb +19 -0
  362. data/yard-0.9.44/templates/default/tags/text/see.erb +11 -0
  363. data/yard-0.9.44/templates/default/tags/text/tag.erb +13 -0
  364. data/yard-0.9.44/templates/guide/class/html/setup.rb +2 -0
  365. data/yard-0.9.44/templates/guide/docstring/html/setup.rb +2 -0
  366. data/yard-0.9.44/templates/guide/fulldoc/html/css/style.css +358 -0
  367. data/yard-0.9.44/templates/guide/fulldoc/html/js/app.js +61 -0
  368. data/yard-0.9.44/templates/guide/fulldoc/html/setup.rb +74 -0
  369. data/yard-0.9.44/templates/guide/layout/html/layout.erb +78 -0
  370. data/yard-0.9.44/templates/guide/layout/html/setup.rb +25 -0
  371. data/yard-0.9.44/templates/guide/method/html/header.erb +18 -0
  372. data/yard-0.9.44/templates/guide/method/html/setup.rb +22 -0
  373. data/yard-0.9.44/templates/guide/module/html/header.erb +7 -0
  374. data/yard-0.9.44/templates/guide/module/html/method_list.erb +5 -0
  375. data/yard-0.9.44/templates/guide/module/html/setup.rb +27 -0
  376. data/yard-0.9.44/templates/guide/onefile/html/files.erb +4 -0
  377. data/yard-0.9.44/templates/guide/onefile/html/setup.rb +6 -0
  378. data/yard-0.9.44/templates/guide/onefile/html/toc.erb +3 -0
  379. data/yard-0.9.44/templates/guide/tags/html/setup.rb +9 -0
  380. metadata +419 -0
@@ -0,0 +1,277 @@
1
+ # frozen_string_literal: true
2
+ require 'fileutils'
3
+ require 'thread'
4
+
5
+ module YARD
6
+ module Server
7
+ # This exception is raised when {LibraryVersion#prepare!} fails, or discovers
8
+ # that the library is not "prepared" to be served by
9
+ class LibraryNotPreparedError < RuntimeError; end
10
+
11
+ # A library version encapsulates a library's documentation at a specific version.
12
+ # Although the version is optional, this allows for creating multiple documentation
13
+ # points for a specific library, each representing a unique version. The term
14
+ # "library" used in other parts of the YARD::Server documentation refers to
15
+ # objects of this class unless otherwise noted.
16
+ #
17
+ # A library points to a location where a {#yardoc_file} is located so that
18
+ # its documentation may be loaded and served. Optionally, a {#source_path} is
19
+ # given to point to a location where any extra files (and {YARD::CLI::Yardoc .yardopts})
20
+ # should be loaded from. Both of these methods may not be known immediately,
21
+ # since the yardoc file may not be built until later. Resolving the yardoc
22
+ # file and source path are dependent on the specific library "source type" used.
23
+ # Source types (known as "library source") are discussed in detail below.
24
+ #
25
+ # == Using with Adapters
26
+ # A list of libraries need to be passed into adapters upon creation. In
27
+ # most cases, you will never do this manually, but if you use a {RackMiddleware},
28
+ # you will need to pass in this list yourself. To build this list of libraries,
29
+ # you should create a hash of library names mapped to an *Array* of LibraryVersion
30
+ # objects. For example:
31
+ #
32
+ # {'mylib' => [LibraryVersion.new('mylib', '1.0', ...),
33
+ # LibraryVersion.new('mylib', '2.0', ...)]}
34
+ #
35
+ # Note that you can also use {Adapter#add_library} for convenience.
36
+ #
37
+ # The "array" part is required, even for just one library version.
38
+ #
39
+ # == Library Sources
40
+ # The {#source} method represents the library source type, ie. where the
41
+ # library "comes from". It might come from "disk", or it might come from a
42
+ # "gem" (technically the disk, but a separate type nonetheless). In these
43
+ # two cases, the yardoc file sits somewhere on your filesystem, though
44
+ # it may also be built dynamically if it does not yet exist. This behaviour
45
+ # is controlled through the {#prepare!} method, which prepares the yardoc file
46
+ # given a specific library source. We will see how this works in detail in
47
+ # the following section.
48
+ #
49
+ # == Implementing a Custom Library Source
50
+ # YARD can be extended to support custom library sources in order to
51
+ # build or retrieve a yardoc file at runtime from many different locations.
52
+ #
53
+ # To implement this behaviour, 3 methods can be added to the +LibraryVersion+
54
+ # class, +#load_yardoc_from_SOURCE+, +#yardoc_file_for_SOURCE+, and
55
+ # +#source_path_for_SOURCE+. In all cases, "SOURCE" represents the source
56
+ # type used in {#source} when creating the library object. The
57
+ # +#yardoc_file_for_SOURCE+ and +#source_path_for_SOURCE+ methods are called upon
58
+ # creation and should return the location where the source code for the library
59
+ # lives. The load method is called from {#prepare!} if there is no yardoc file
60
+ # and should set {#yardoc_file}. Below is a full example for
61
+ # implementing a custom library source, +:http+, which reads packaged .yardoc
62
+ # databases from zipped archives off of an HTTP server.
63
+ #
64
+ # Note that only +#load_yardoc_from_SOURCE+ is required. The other two
65
+ # methods are optional and can be set manually (via {#source_path=} and
66
+ # {#yardoc_file=}) on the object at any time.
67
+ #
68
+ # @example Implementing a Custom Library Source
69
+ # # Adds the source type "http" for .yardoc files zipped on HTTP servers
70
+ # class LibraryVersion
71
+ # def load_yardoc_from_http
72
+ # Thread.new do
73
+ # # zip/unzip method implementations are not shown
74
+ # download_zip_file("https://mysite.com/yardocs/#{self}.zip")
75
+ # unzip_file_to("/path/to/yardocs/#{self}")
76
+ # end
77
+ #
78
+ # # tell the server it's not ready yet (but it might be next time)
79
+ # raise LibraryNotPreparedError
80
+ # end
81
+ #
82
+ # def yardoc_file_for_http
83
+ # "/path/to/yardocs/#{self}/.yardoc"
84
+ # end
85
+ #
86
+ # def source_path_for_http
87
+ # File.dirname(yardoc_file)
88
+ # end
89
+ # end
90
+ #
91
+ # # Creating a library of this source type:
92
+ # LibraryVersion.new('name', '1.0', nil, :http)
93
+ #
94
+ class LibraryVersion
95
+ # @return [String] the name of the library
96
+ attr_accessor :name
97
+
98
+ # @return [String] the version of the specific library
99
+ attr_accessor :version
100
+
101
+ # @return [String] the location of the yardoc file used to load the object
102
+ # information from.
103
+ # @return [nil] if no yardoc file exists yet. In this case, {#prepare!} will
104
+ # be called on this library to build the yardoc file.
105
+ # @note To implement a custom yardoc file getter, implement
106
+ def yardoc_file
107
+ @yardoc_file ||= load_yardoc_file
108
+ end
109
+ attr_writer :yardoc_file
110
+
111
+ # @return [Symbol] the source type representing where the yardoc should be
112
+ # loaded from. Defaults are +:disk+ and +:gem+, though custom sources
113
+ # may be implemented. This value is used to inform {#prepare!} about how
114
+ # to load the necessary data in order to display documentation for an object.
115
+ # @see LibraryVersion LibraryVersion documentation for "Implementing a Custom Library Source"
116
+ attr_accessor :source
117
+
118
+ # @return [String] the location of the source code for a library. This
119
+ # value is filled by calling +#source_path_for_SOURCE+ on this class.
120
+ # @return [nil] if there is no source code
121
+ # @see LibraryVersion LibraryVersion documentation for "Implementing a Custom Library Source"
122
+ def source_path
123
+ @source_path ||= load_source_path
124
+ end
125
+ attr_writer :source_path
126
+
127
+ # @param [String] name the name of the library
128
+ # @param [String] version the specific (usually, but not always, numeric) library
129
+ # version
130
+ # @param [String] yardoc the location of the yardoc file, or nil if it is
131
+ # generated later
132
+ # @param [Symbol] source the location of the files used to build the yardoc.
133
+ # Builtin source types are +:disk+ or +:gem+.
134
+ def initialize(name, version = nil, yardoc = nil, source = :disk)
135
+ self.name = name
136
+ self.yardoc_file = yardoc
137
+ self.version = version
138
+ self.source = source
139
+ end
140
+
141
+ # @param [Boolean] url_format if true, returns the string in a URI-compatible
142
+ # format (for appending to a URL). Otherwise, it is given in a more human
143
+ # readable format.
144
+ # @return [String] the string representation of the library.
145
+ def to_s(url_format = true)
146
+ version ? "#{name}#{url_format ? '/' : '-'}#{version}" : name.to_s
147
+ end
148
+
149
+ # @return [Fixnum] used for Hash mapping.
150
+ def hash; to_s.hash end
151
+
152
+ # @return [Boolean] whether another LibraryVersion is equal to this one
153
+ def eql?(other)
154
+ other.is_a?(LibraryVersion) && other.name == name &&
155
+ other.version == version && other.yardoc_file == yardoc_file
156
+ end
157
+ alias == eql?
158
+ alias equal? eql?
159
+
160
+ # @return [Boolean] whether the library has been completely processed
161
+ # and is ready to be served
162
+ def ready?
163
+ return false if yardoc_file.nil?
164
+ serializer.complete?
165
+ end
166
+
167
+ # @note You should not directly override this method. Instead, implement
168
+ # +load_yardoc_from_SOURCENAME+ when implementing loading for a specific
169
+ # source type. See the {LibraryVersion} documentation for "Implementing
170
+ # a Custom Library Source"
171
+ #
172
+ # Prepares a library to be displayed by the server. This callback is
173
+ # performed before each request on a library to ensure that it is loaded
174
+ # and ready to be viewed. If any steps need to be performed prior to loading,
175
+ # they are performed through this method (though they should be implemented
176
+ # through the +load_yardoc_from_SOURCE+ method).
177
+ #
178
+ # @raise [LibraryNotPreparedError] if the library is not ready to be
179
+ # displayed. Usually when raising this error, you would simultaneously
180
+ # begin preparing the library for subsequent requests, although this
181
+ # is not necessary.
182
+ def prepare!
183
+ return if ready?
184
+ meth = "load_yardoc_from_#{source}"
185
+ send(meth) if respond_to?(meth, true)
186
+ end
187
+
188
+ # @return [Gem::Specification] a gemspec object for a given library. Used
189
+ # for :gem source types.
190
+ # @return [nil] if there is no installed gem for the library
191
+ def gemspec
192
+ ver = version ? "= #{version}" : ">= 0"
193
+ YARD::GemIndex.find_all_by_name(name, ver).last
194
+ end
195
+
196
+ protected
197
+
198
+ @@chdir_mutex = Mutex.new
199
+
200
+ # Called when a library of source type "disk" is to be prepared. In this
201
+ # case, the {#yardoc_file} should already be set, but the library may not
202
+ # be prepared. Run preparation if not done.
203
+ #
204
+ # @raise [LibraryNotPreparedError] if the yardoc file has not been
205
+ # prepared.
206
+ def load_yardoc_from_disk
207
+ return if ready?
208
+
209
+ @@chdir_mutex.synchronize do
210
+ Dir.chdir(source_path_for_disk) do
211
+ Thread.new do
212
+ CLI::Yardoc.run('--no-stats', '-n', '-b', yardoc_file)
213
+ end
214
+ end
215
+ end
216
+
217
+ raise LibraryNotPreparedError
218
+ end
219
+
220
+ # Called when a library of source type "gem" is to be prepared. In this
221
+ # case, the {#yardoc_file} needs to point to the correct location for
222
+ # the installed gem. The yardoc file is built if it has not been done.
223
+ #
224
+ # @raise [LibraryNotPreparedError] if the gem does not have an existing
225
+ # yardoc file.
226
+ def load_yardoc_from_gem
227
+ return if ready?
228
+ ver = version ? "= #{version}" : ">= 0"
229
+
230
+ @@chdir_mutex.synchronize do
231
+ Thread.new do
232
+ # Build gem docs on demand
233
+ log.debug "Building gem docs for #{to_s(false)}"
234
+ CLI::Gems.run(name, ver)
235
+ log.debug "Done building gem docs for #{to_s(false)}"
236
+ end
237
+ end
238
+
239
+ raise LibraryNotPreparedError
240
+ end
241
+
242
+ # @return [String] the source path for a disk source
243
+ def source_path_for_disk
244
+ File.dirname(yardoc_file) if yardoc_file
245
+ end
246
+
247
+ # @return [String] the source path for a gem source
248
+ def source_path_for_gem
249
+ gemspec.full_gem_path if gemspec
250
+ end
251
+
252
+ # @return [String] the yardoc file for a gem source
253
+ def yardoc_file_for_gem
254
+ require 'rubygems'
255
+ ver = version ? "= #{version}" : ">= 0"
256
+ Registry.yardoc_file_for_gem(name, ver)
257
+ end
258
+
259
+ private
260
+
261
+ def load_source_path
262
+ meth = "source_path_for_#{source}"
263
+ send(meth) if respond_to?(meth, true)
264
+ end
265
+
266
+ def load_yardoc_file
267
+ meth = "yardoc_file_for_#{source}"
268
+ send(meth) if respond_to?(meth, true)
269
+ end
270
+
271
+ def serializer
272
+ return if yardoc_file.nil?
273
+ Serializers::YardocSerializer.new(yardoc_file)
274
+ end
275
+ end
276
+ end
277
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YARD
4
+ module Server
5
+ begin
6
+ require 'rackup'
7
+ # @private
8
+ RackServer = Rackup::Server
9
+ rescue LoadError
10
+ require 'rack'
11
+ # @private
12
+ RackServer = Rack::Server
13
+ end
14
+
15
+ # This class wraps the {RackAdapter} into a Rack-compatible middleware.
16
+ # See {#initialize} for a list of options to pass via Rack's +#use+ method.
17
+ #
18
+ # @note You must pass a +:libraries+ option to the RackMiddleware via +#use+. To
19
+ # read about how to return a list of libraries, see {LibraryVersion} or look
20
+ # at the example below.
21
+ # @example Using the RackMiddleware in a Rack application
22
+ # libraries = {:mylib => [YARD::Server::LibraryVersion.new('mylib', nil, '/path/to/.yardoc')]}
23
+ # use YARD::Server::RackMiddleware, :libraries => libraries
24
+ #
25
+ class RackMiddleware
26
+ # Creates a new Rack-based middleware for serving YARD documentation.
27
+ #
28
+ # @param app the next Rack middleware in the stack
29
+ # @option opts [Hash{String=>Array<LibraryVersion>}] :libraries ({})
30
+ # the map of libraries to serve through the adapter. This option is *required*.
31
+ # @option opts [Hash] :options ({}) a list of options to pass to the adapter.
32
+ # See {Adapter#options} for a list.
33
+ # @option opts [Hash] :server_options ({}) a list of options to pass to the server.
34
+ # See {Adapter#server_options} for a list.
35
+ def initialize(app, opts = {})
36
+ args = [opts[:libraries] || {}, opts[:options] || {}, opts[:server_options] || {}]
37
+ @app = app
38
+ @adapter = RackAdapter.new(*args)
39
+ end
40
+
41
+ def call(env)
42
+ status, headers, body = *@adapter.call(env)
43
+ if status == 404
44
+ @app.call(env)
45
+ else
46
+ [status, headers, body]
47
+ end
48
+ end
49
+ end
50
+
51
+ # A server adapter to respond to requests using the Rack server infrastructure.
52
+ class RackAdapter < Adapter
53
+ include YARD::Server::HTTPUtils
54
+
55
+ # Responds to Rack requests and builds a response with the {Router}.
56
+ # @return [Array(Numeric,Hash,Array)] the Rack-style response
57
+ def call(env)
58
+ request = Rack::Request.new(env)
59
+ request.path_info = unescape(request.path_info) # unescape things like %3F
60
+ router.call(request)
61
+ rescue StandardError => ex
62
+ log.backtrace(ex)
63
+ [500, {'Content-Type' => 'text/plain'},
64
+ [ex.message + "\n" + ex.backtrace.join("\n")]]
65
+ end
66
+
67
+ # Starts the Rack server. This method will pass control to the server and
68
+ # block.
69
+ # @return [void]
70
+ def start
71
+ server = RackServer.new(server_options)
72
+ server.instance_variable_set("@app", self)
73
+ print_start_message(server)
74
+ server.start
75
+ end
76
+
77
+ private
78
+
79
+ def print_start_message(server)
80
+ opts = server.default_options.merge(server.options)
81
+ log.puts ">> YARD #{YARD::VERSION} documentation server at http://#{opts[:Host]}:#{opts[:Port]}"
82
+
83
+ # Only happens for Mongrel
84
+ return unless server.server.to_s == "Rack::Handler::Mongrel"
85
+ log.puts ">> #{server.server.class_name} web server (running on Rack)"
86
+ log.puts ">> Listening on #{opts[:Host]}:#{opts[:Port]}, CTRL+C to stop"
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ # @private
93
+ class Rack::Request
94
+ attr_accessor :version_supplied
95
+ alias query params
96
+ def xhr?; (env['HTTP_X_REQUESTED_WITH'] || "").casecmp("xmlhttprequest") == 0 end
97
+ end
@@ -0,0 +1,187 @@
1
+ # frozen_string_literal: true
2
+ module YARD
3
+ module Server
4
+ # A router class implements the logic used to recognize a request for a specific
5
+ # URL and run specific {Commands::Base commands}.
6
+ #
7
+ # == Subclassing Notes
8
+ # To create a custom router, subclass this class and pass it into the adapter
9
+ # options through {Adapter#initialize} or by directly modifying {Adapter#router}.
10
+ #
11
+ # The most general customization is to change the URL prefixes recognized by
12
+ # routing, which can be done by overriding {#docs_prefix}, {#list_prefix},
13
+ # {#static_prefix}, and {#search_prefix}.
14
+ #
15
+ # == Implementing Custom Caching
16
+ # By default, the Router class performs static disk-based caching on all
17
+ # requests through the +#check_static_cache+. To override this behaviour,
18
+ # or create your own caching mechanism, mixin your own custom module with
19
+ # this method implemented as per {StaticCaching#check_static_cache}.
20
+ #
21
+ # @example Creating a subclassed router
22
+ # # Adds 'my' to all routing prefixes
23
+ # class MyRouter < YARD::Server::Router
24
+ # def docs_prefix; 'mydocs' end
25
+ # def list_prefix; 'mylist' end
26
+ # def static_prefix; 'mystatic' end
27
+ # def search_prefix; 'mysearch' end
28
+ # end
29
+ #
30
+ # # Using it:
31
+ # WebrickAdapter.new(libraries, :router => MyRouter).start
32
+ class Router
33
+ include StaticCaching
34
+ include Commands
35
+
36
+ # @return [Adapter Dependent] the request data coming in with the routing
37
+ attr_accessor :request
38
+
39
+ # @return [Adapter] the adapter used by the router
40
+ attr_accessor :adapter
41
+
42
+ # Creates a new router for a specific adapter
43
+ #
44
+ # @param [Adapter] adapter the adapter to route requests to
45
+ def initialize(adapter)
46
+ self.adapter = adapter
47
+ end
48
+
49
+ # Perform routing on a specific request, serving the request as a static
50
+ # file through {Commands::RootRequestCommand} if no route is found.
51
+ #
52
+ # @param [Adapter Dependent] request the request object
53
+ # @return [Array(Numeric,Hash,Array)] the Rack-style server response data
54
+ def call(request)
55
+ self.request = request
56
+ result = check_static_cache || route
57
+ result ? result : RootRequestCommand.new(adapter.options).call(request)
58
+ end
59
+
60
+ # @group Route Prefixes
61
+
62
+ # @return [String] the URI prefix for all object documentation requests
63
+ def docs_prefix; 'docs' end
64
+
65
+ # @return [String] the URI prefix for all class/method/file list requests
66
+ def list_prefix; 'list' end
67
+
68
+ # @return [String] the URI prefix for all search requests
69
+ def search_prefix; 'search' end
70
+
71
+ # @return [String] the URI prefix for all static assets (templates)
72
+ def static_prefix; 'static' end
73
+
74
+ # @group Routing Methods
75
+
76
+ # @return [Array(LibraryVersion, Array<String>)] the library followed
77
+ # by the rest of the path components in the request path. LibraryVersion
78
+ # will be nil if no matching library was found.
79
+ def parse_library_from_path(paths)
80
+ return [adapter.libraries.values.first.first, paths] if adapter.options[:single_library]
81
+ library = nil
82
+ paths = paths.dup
83
+ libs = adapter.libraries[paths.first]
84
+ if libs
85
+ paths.shift
86
+ library = libs.find {|l| l.version == paths.first }
87
+ if library
88
+ request.version_supplied = true if request
89
+ paths.shift
90
+ else # use the last lib in the list
91
+ request.version_supplied = false if request
92
+ library = libs.last
93
+ end
94
+ end
95
+ [library, paths]
96
+ end
97
+
98
+ protected
99
+
100
+ # Performs routing algorithm to find which prefix is called, first
101
+ # parsing out library name/version information.
102
+ #
103
+ # @return [Array(Numeric,Hash,Array<String>)] the Rack-style response
104
+ # @return [nil] if no route is matched
105
+ def route(path = request.path_info)
106
+ path = path.gsub(%r{//+}, '/').gsub(%r{^/|/$}, '')
107
+ return route_index if path.empty? || path == docs_prefix
108
+ case path
109
+ when %r{^(#{docs_prefix}|#{list_prefix}|#{search_prefix}|#{static_prefix})(/.*|$)}
110
+ prefix = $1
111
+ paths = $2.gsub(%r{^/|/$}, '').split('/')
112
+ library, paths = *parse_library_from_path(paths)
113
+ return unless library
114
+ return case prefix
115
+ when docs_prefix; route_docs(library, paths)
116
+ when list_prefix; route_list(library, paths)
117
+ when search_prefix; route_search(library, paths)
118
+ when static_prefix; route_static(library, paths)
119
+ end
120
+ end
121
+ nil
122
+ end
123
+
124
+ # Routes requests from {#docs_prefix} and calls the appropriate command
125
+ # @param [LibraryVersion] library the library to route for
126
+ # @param [Array<String>] paths path components (split by '/')
127
+ # @return (see #route)
128
+ def route_docs(library, paths)
129
+ return route_index if library.nil?
130
+ case paths.first
131
+ when "frames"
132
+ paths.shift
133
+ cmd = DisplayObjectCommand
134
+ when "file"
135
+ paths.shift
136
+ cmd = DisplayFileCommand
137
+ else
138
+ cmd = DisplayObjectCommand
139
+ end
140
+ cmd = cmd.new(final_options(library, paths))
141
+ cmd.call(request)
142
+ end
143
+
144
+ # Routes for the index of a library / multiple libraries
145
+ # @return (see #route)
146
+ def route_index
147
+ if adapter.options[:single_library]
148
+ route_docs(adapter.libraries.values.first.first, [])
149
+ else
150
+ LibraryIndexCommand.new(adapter.options.merge(:path => '')).call(request)
151
+ end
152
+ end
153
+
154
+ # Routes requests from {#list_prefix} and calls the appropriate command
155
+ # @param (see #route_docs)
156
+ # @return (see #route_docs)
157
+ def route_list(library, paths)
158
+ return if paths.empty?
159
+ ListCommand.new(final_options(library, paths)).call(request)
160
+ end
161
+
162
+ # Routes requests from {#search_prefix} and calls the appropriate command
163
+ # @param (see #route_docs)
164
+ # @return (see #route_docs)
165
+ def route_search(library, paths)
166
+ return unless paths.empty?
167
+ SearchCommand.new(final_options(library, paths)).call(request)
168
+ end
169
+
170
+ def route_static(library, paths)
171
+ StaticFileCommand.new(final_options(library, paths)).call(request)
172
+ end
173
+
174
+ # @group Utility Methods
175
+
176
+ # Adds extra :library/:path option keys to the adapter options.
177
+ # Use this method when passing options to a command.
178
+ #
179
+ # @param (see #route_docs)
180
+ # @return [Hash] finalized options
181
+ def final_options(library, paths)
182
+ path = File.cleanpath(paths.join('/')).gsub(%r{^(\.\./)+}, '')
183
+ adapter.options.merge(:library => library, :path => path)
184
+ end
185
+ end
186
+ end
187
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+ require 'fileutils'
3
+
4
+ module YARD
5
+ module Server
6
+ # Implements static caching for requests.
7
+ #
8
+ # @see Router Router documentation for "Caching"
9
+ module StaticCaching
10
+ # Called by a router to return the cached object. By default, this
11
+ # method performs disk-based caching. To perform other forms of caching,
12
+ # implement your own +#check_static_cache+ method and mix the module into
13
+ # the Router class.
14
+ #
15
+ # This method checks for the existence of cached data. To actually cache
16
+ # a response, see {#cache}.
17
+ #
18
+ # @example Implementing In-Memory Cache Checking
19
+ # module MemoryCaching
20
+ # def check_static_cache
21
+ # # $memory_cache is filled by {Commands::Base#cache}
22
+ # cached_data = $memory_cache[request.path]
23
+ # if cached_data
24
+ # [200, {'Content-Type' => 'text/html'}, [cached_data]]
25
+ # else
26
+ # nil
27
+ # end
28
+ # end
29
+ # end
30
+ #
31
+ # class YARD::Server::Router; include MemoryCaching; end
32
+ # @return [Array(Numeric,Hash,Array)] the Rack-style response
33
+ # @return [nil] if no cache is available and routing should continue
34
+ # @see Commands::Base#cache
35
+ def check_static_cache
36
+ return nil unless adapter.document_root
37
+ cache_path = cache_path(request.path)
38
+ return nil unless cache_path
39
+
40
+ if File.file?(cache_path)
41
+ log.debug "Loading cache from disk: #{cache_path}"
42
+ return [200, {'Content-Type' => 'text/html'}, [File.read_binary(cache_path)]]
43
+ end
44
+ nil
45
+ end
46
+
47
+ # Caches rendered HTML response data to disk.
48
+ #
49
+ # @param [String] data the data to cache
50
+ # @return [void]
51
+ # @since 0.9.44
52
+ def cache(data)
53
+ return unless adapter.document_root
54
+
55
+ path = cache_path(request.path_info)
56
+ return unless path
57
+
58
+ FileUtils.mkdir_p(File.dirname(path))
59
+ log.debug "Caching data to #{path}"
60
+ File.open(path, 'wb') {|f| f.write(data) }
61
+ end
62
+
63
+ private
64
+
65
+ def cache_path(request_path)
66
+ return nil if request_path.split(/[\/\\]/).include?('..')
67
+
68
+ path = request_path.sub(/\.html$/, '') + '.html'
69
+ path = path.sub(%r{\A/+}, '')
70
+ return nil if path =~ /\A[A-Za-z]:/
71
+
72
+ path = File.cleanpath(path)
73
+ File.join(adapter.document_root, path)
74
+ end
75
+ end
76
+ end
77
+ end