Class: Fastlane::MarkdownDocsGenerator
- Inherits:
-
Object
- Object
- Fastlane::MarkdownDocsGenerator
- Defined in:
- lib/fastlane/documentation/markdown_docs_generator.rb
Constant Summary collapse
- ENHANCER_URL =
"https://fastlane-enhancer.herokuapp.com"
Instance Attribute Summary collapse
-
#categories ⇒ Object
Returns the value of attribute categories.
-
#plugins ⇒ Object
Returns the value of attribute plugins.
Instance Method Summary collapse
- #all_actions_from_enhancer ⇒ Object
- #fill_built_in_actions ⇒ Object
- #fill_plugins ⇒ Object
- #generate!(target_path: "docs/Actions.md") ⇒ Object
-
#initialize ⇒ MarkdownDocsGenerator
constructor
A new instance of MarkdownDocsGenerator.
- #number_of_launches_for_action(action_name) ⇒ Object
- #work ⇒ Object
Constructor Details
#initialize ⇒ MarkdownDocsGenerator
Returns a new instance of MarkdownDocsGenerator.
9 10 11 12 13 14 15 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 9 def initialize require 'fastlane' require 'fastlane/documentation/actions_list' Fastlane.load_actions self.work end |
Instance Attribute Details
#categories ⇒ Object
Returns the value of attribute categories.
5 6 7 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 5 def categories @categories end |
#plugins ⇒ Object
Returns the value of attribute plugins.
7 8 9 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 7 def plugins @plugins end |
Instance Method Details
#all_actions_from_enhancer ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 81 def all_actions_from_enhancer require 'faraday' require 'json' unless @launches conn = Faraday.new(ENHANCER_URL) conn.basic_auth(ENV["ENHANCER_USER"], ENV["ENHANCER_PASSWORD"]) begin @launches = JSON.parse(conn.get('/index.json').body) rescue UI.user_error!("Couldn't fetch usage data, make sure to have ENHANCER_USER and ENHANCER_PASSWORD") end end @launches end |
#fill_built_in_actions ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 22 def fill_built_in_actions self.categories = {} Fastlane::Action::AVAILABLE_CATEGORIES.each { |a| self.categories[readable_category_name(a)] = {} } # Fill categories with all built-in actions ActionsList.all_actions do |action| readable = readable_category_name(action.category) if self.categories[readable].kind_of?(Hash) self.categories[readable][number_of_launches_for_action(action.action_name)] = action else UI.error("Action '#{action.name}' doesn't contain category information... skipping") end end end |
#fill_plugins ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 39 def fill_plugins self.plugins = [] all_fastlane_plugins = PluginFetcher.fetch_gems # that's all available gems # We iterate over the enhancer data, since this includes the various actions per plugin # we then access `all_fastlane_plugins` to get the URL to the plugin all_actions_from_enhancer.each do |current_action| action_name = current_action["action"] # e.g. "fastlane-plugin-synx/synx" next unless action_name.start_with?("fastlane-plugin") # we only care about plugins here gem_name = action_name.split("/").first # e.g. fastlane-plugin-synx ruby_gem_info = all_fastlane_plugins.find { |a| a.full_name == gem_name } next unless ruby_gem_info # `ruby_gem_info` e.g. # # #<Fastlane::FastlanePlugin:0x007ff7fc4de9e0 # @downloads=888, # @full_name="fastlane-plugin-synx", # @homepage="https://github.com/afonsograca/fastlane-plugin-synx", # @info="Organise your Xcode project folder to match your Xcode groups.", # @name="synx"> self.plugins << { linked_title: ruby_gem_info.linked_title, action_name: action_name.split("/").last, description: ruby_gem_info.info, usage: number_of_launches_for_action(action_name) } end end |
#generate!(target_path: "docs/Actions.md") ⇒ Object
97 98 99 100 101 102 103 104 105 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 97 def generate!(target_path: "docs/Actions.md") template = File.join(Fastlane::ROOT, "lib/assets/Actions.md.erb") result = ERB.new(File.read(template), 0, '-').result(binding) # http://www.rrn.dk/rubys-erb-templating-system puts result File.write(target_path, result) UI.success(target_path) end |
#number_of_launches_for_action(action_name) ⇒ Object
74 75 76 77 78 79 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 74 def number_of_launches_for_action(action_name) found = all_actions_from_enhancer.find { |c| c["action"] == action_name.to_s } return found["launches"] if found return rand # so we don't overwrite another action, this is between 0 and 1 end |
#work ⇒ Object
17 18 19 20 |
# File 'lib/fastlane/documentation/markdown_docs_generator.rb', line 17 def work fill_built_in_actions fill_plugins end |