Class: BitClust::Subcommands::HtmlfileCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::HtmlfileCommand
- Defined in:
- lib/bitclust/subcommands/htmlfile_command.rb
Instance Method Summary collapse
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ HtmlfileCommand
constructor
A new instance of HtmlfileCommand.
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root
Constructor Details
#initialize ⇒ HtmlfileCommand
Returns a new instance of HtmlfileCommand.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bitclust/subcommands/htmlfile_command.rb', line 14 def initialize super @target = nil @templatedir = srcdir_root + "data/bitclust/template.offline" @baseurl = "file://" + srcdir_root.to_s @version = "2.0.0" @parser. = "Usage: #{File.basename($0, '.*')} htmlfile [options] rdfile" @parser.on('--target=NAME', 'Compile NAME to HTML.') {|name| @target = name } @parser.on('--force', '-f', 'Force to use rd_file template.') {|name| @rd_file = true } @parser.on('--ruby_version=VER', '--ruby=VER', 'Set Ruby version') {|version| @version = version } @parser.on('--baseurl=URL', 'Base URL of generated HTML') {|url| @baseurl = url } @parser.on('--templatedir=PATH', 'Template directory') {|path| @templatedir = path } end |
Instance Method Details
#exec(argv, options) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/bitclust/subcommands/htmlfile_command.rb', line 38 def exec(argv, ) db = MethodDatabase.dummy({'version' => @version}) if [:prefix] db = MethodDatabase.new([:prefix]) end @capi = [:capi] target_file = argv[0] = { 'version' => @version } manager = ScreenManager.new(:templatedir => @templatedir, :base_url => @baseurl, :cgi_url => @baseurl, :default_encoding => 'utf-8') unless @rd_file begin if @capi lib = FunctionReferenceParser.parse_file(target_file, ) unless @target raise NotImplementedError, "generating a C API html without --target=NAME is not implemented yet." end else lib = RRDParser.parse_stdlib_file(target_file, ) end entry = @target ? lookup(lib, @target) : lib puts manager.entry_screen(entry, { :database => db }).body return rescue ParseError => ex $stderr.puts ex. $stderr.puts ex.backtrace[0], ex.backtrace[1..-1].map{|s| "\tfrom " + s} end end begin entry = DocEntry.new(db, target_file) source = Preprocessor.read(target_file, ) entry.source = source puts manager.doc_screen(entry, { :database => db }).body rescue WriterError => ex $stderr.puts ex. exit 1 end end |