docs.rake 924 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. namespace :docs do
  2. def rdoc_to_markdown(content)
  3. content.gsub(/^ ?(=+) /) do |m|
  4. m.gsub('=', '#')
  5. end
  6. end
  7. def prepare_docstring(content)
  8. content = rdoc_to_markdown(content)
  9. "<!-- Please don't edit this file. It will be clobbered. -->\n\n#{content}"
  10. end
  11. def filename_from_module(mod)
  12. mod.name.to_s.underscore.gsub('_', '-')
  13. end
  14. def write_docstrings_to(path, mods)
  15. mods.each do |mod|
  16. File.open("#{path}/#{filename_from_module(mod)}.md", 'w+') do |f|
  17. f << prepare_docstring(mod.docstring)
  18. end
  19. end
  20. end
  21. desc "Update docs in the docs folder"
  22. task :build do
  23. require 'yard'
  24. require 'active_support/all'
  25. YARD::Registry.load!
  26. views = YARD::Registry.at("ActiveAdmin::Views")
  27. # Index Types
  28. index_types = views.children.select{|obj| obj.name.to_s =~ /^IndexAs/ }
  29. write_docstrings_to "docs/3-index-pages", index_types
  30. end
  31. end