forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdocs.rake
37 lines (29 loc) · 843 Bytes
/
docs.rake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
namespace :docs do
AUTOGEN_WARNING = <<-EOD
<!--
WARNING: Please DO NOT edit this file! Update
source documentation in lib/active_admin/views
and execute rake yard to regenerate it.
-->
EOD
def filename_from_module(mod)
mod.name.to_s.underscore.tr('_', '-')
end
def write_docstrings_to(path, mods)
mods.each do |mod|
File.open("#{path}/#{filename_from_module(mod)}.md", 'w+') do |f|
f << AUTOGEN_WARNING + mod.docstring + "\n"
end
end
end
desc "Update docs in the docs folder"
task :build do
require 'yard'
require 'active_support/all'
YARD::Registry.load!
views = YARD::Registry.at("ActiveAdmin::Views")
# Index Types
index_types = views.children.select{|obj| obj.name.to_s =~ /^IndexAs/ }
write_docstrings_to "docs/3-index-pages", index_types
end
end