# # ActiveFacts Generators. # # Generate a glossary in HTML # # Copyright (c) 2009 Clifford Heath. Read the LICENSE file. # require 'activefacts/api' require 'activefacts/registry' module ActiveFacts module Generators #:nodoc: class HTML #:nodoc: class GLOSSARY #:nodoc: # Base class for generators of object-oriented class libraries for an ActiveFacts vocabulary. def initialize(vocabulary, *options) @vocabulary = vocabulary @vocabulary = @vocabulary.Vocabulary.values[0] if ActiveFacts::API::Constellation === @vocabulary options.each{|option| set_option(option) } end def set_option(option) @gen_bootstrap = false case option when 'help', '?' $stderr.puts "Usage:\t\tafgen --html/glossary[=option] input_file.cql\n"+ "\t\tbootstrap\tGenerate bootstrap styled glossary html" exit 0 when /bootstrap/ @gen_bootstrap = true else super end end def puts(*a) @out.puts *a end def print(*a) @out.print *a end def generate(out = $>) @out = out @all_object_type = @vocabulary. all_object_type. sort_by{|o| o.name.gsub(/ /,'').downcase} vocabulary_start if @gen_bootstrap object_types_dump_toc() object_types_dump_def() else object_types_dump_def() object_types_dump_toc() end vocabulary_end end def vocabulary_start if !@gen_bootstrap # puts "" css_file = "/../../../../css/orm2.css" File.open(File.dirname(__FILE__)+css_file) do |f| puts "" end puts %Q{ }.gsub(/^\s+/, '') end end def vocabulary_end if !@gen_bootstrap puts %Q{ }.gsub(/^\s+/, '') end end def object_types_dump_toc if @gen_bootstrap puts '