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.
-
#needs_database? ⇒ Boolean
DB は与えられれば使うが必須ではない (--database は任意).
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 = RUBY_VERSION @parser. = "Usage: #{File.basename($0, '.*')} htmlfile [options] rdfile" @parser.on('--target=NAME', 'Compile NAME to HTML.') {|name| @target = name } @parser.on('--[no-]force', '-f', 'Force to use rd_file template.') {|bool| @rd_file = bool } @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
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 80 81 82 83 84 85 86 87 |
# File 'lib/bitclust/subcommands/htmlfile_command.rb', line 43 def exec(argv, ) db = MethodDatabase.dummy({'version' => @version}) if [:prefix] db = MethodDatabase.new([:prefix]) end @capi = [:capi] target_file = argv[0] if /refm\/doc\// =~ target_file @rd_file = true if @rd_file.nil? end = { 'version' => @version } #: Database::database_properties 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, :target_version => @version }).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 |
#needs_database? ⇒ Boolean
DB は与えられれば使うが必須ではない (--database は任意)
39 40 41 |
# File 'lib/bitclust/subcommands/htmlfile_command.rb', line 39 def needs_database? false end |