6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/docwright/extractors/api_extractor.rb', line 6
def generate
lines = ["# Api Documentation\n"]
routes = Rails.application.routes.routes
routes.each do |route|
next if route.name.to_s.start_with?("rails_")
next if route.verb.empty?
next if route.defaults[:controller].to_s.start_with?("rails/")
lines << "- **#{route.verb}** #{route.path.spec} -> #{route.defaults[:controller]}##{route.defaults[:action]}"
end
FileUtils.mkdir_p("docs")
Docwright::Merger.write("docs/api.md", lines.join("\n"))
puts "DocWright: wrote docs/api.md"
end
|