fastlane/lib/fastlane/documentation/markdown_docs_generator.rb in fastlane-2.43.0 vs fastlane/lib/fastlane/documentation/markdown_docs_generator.rb in fastlane-2.44.0.beta.20170630010021
- old
+ new
@@ -1,9 +1,7 @@
module Fastlane
class MarkdownDocsGenerator
- ENHANCER_URL = "https://enhancer.fastlane.tools"
-
attr_accessor :categories
def initialize
require 'fastlane'
require 'fastlane/documentation/actions_list'
@@ -32,37 +30,18 @@
end
end
end
def number_of_launches_for_action(action_name)
- found = all_actions_from_enhancer.find { |c| c["action"] == action_name.to_s }
+ 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
+ return found["index"] if found
+ return 10_000 + rand # new actions that we've never tracked before will be shown at the bottom of the page, need `rand` to not overwrite them
end
def all_actions_from_enhancer
- require 'faraday'
require 'json'
-
- # Only Fabric team members have access to the enhancer instance
- # This can be used to check doc changes for everyone else
- if FastlaneCore::Env.truthy?('USE_ENHANCE_TEST_DATA')
- return [{ "action" => "puts", "launches" => 123, "errors" => 0, "ratio" => 0.0, "crashes" => 0 },
- { "action" => "fastlane_version", "launches" => 123, "errors" => 43, "ratio" => 0.34, "crashes" => 0 },
- { "action" => "default_platform", "launches" => 123, "errors" => 33, "ratio" => 0.27, "crashes" => 31 }]
- end
-
- unless @launches
- conn = Faraday.new(ENHANCER_URL)
- conn.basic_auth(ENV["ENHANCER_USER"], ENV["ENHANCER_PASSWORD"])
- begin
- @launches = JSON.parse(conn.get('/index.json?minimum_launches=0').body)
- rescue
- UI.user_error!("Couldn't fetch usage data, make sure to have ENHANCER_USER and ENHANCER_PASSWORD")
- end
- end
- @launches
+ @_launches ||= JSON.parse(File.read(File.join(Fastlane::ROOT, "assets/action_ranking.json"))) # root because we're in a temporary directory here
end
def generate!(target_path: "docs/Actions.md")
template = File.join(Fastlane::ROOT, "lib/assets/Actions.md.erb")