# # ActiveFacts Generators. # # Generate a glossary in HTML # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # require 'activefacts/metamodel' require 'activefacts/registry' require 'activefacts/compositions' require 'activefacts/generator' require 'byebug' module ActiveFacts module Generators #:nodoc: module Doc class Glossary #:nodoc: # Options are comma or space separated: # * gen_bootstrap Generate bootstrap styled glossary html def self.options { gen_bootstrap: ['Boolean', "Generate bootstrap styled glossary html"], } end # Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary. def initialize vocabulary, options = {} @vocabulary = vocabulary @options = options @gen_bootstrap = options.has_key?("gen_bootstrap") end def puts(*a) @out.puts *a end def print(*a) @out.print *a end def generate @all_object_type = @vocabulary. all_object_type. sort_by{|o| o.name.gsub(/ /,'').downcase} glossary_start + glossary_body + glossary_end end def glossary_start if !@gen_bootstrap # puts "" css_file = "css/orm2.css" File.open(File.dirname(__FILE__)+css_file) do |f| "\n" end + %Q{ \n }.gsub(/^\s+/, '') else '' end end def glossary_body if @gen_bootstrap object_types_dump_toc() object_types_dump_def() else object_types_dump_def() object_types_dump_toc() end end def glossary_end if !@gen_bootstrap %Q{ }.gsub(/^\s+/, '') else '' end end def object_types_dump_toc if @gen_bootstrap '