Class: Cosmos::HandbookCreator
- Defined in:
- lib/cosmos/tools/handbook_creator/handbook_creator.rb
Overview
Creates command and telemetry handbooks from the COSMOS definitions in both HTML and PDF format.
Class Method Summary collapse
-
.run(option_parser = nil, options = nil) ⇒ Object
Runs the application.
Instance Method Summary collapse
- #create_pdfs(both, hide_ignored) ⇒ Object
-
#initialize(options) ⇒ HandbookCreator
constructor
A new instance of HandbookCreator.
- #initialize_actions ⇒ Object
- #initialize_central_widget ⇒ Object
- #initialize_menus ⇒ Object
Methods inherited from QtTool
#about, #closeEvent, #complete_initialize, create_default_options, graceful_kill, #initialize_help_menu, post_options_parsed_hook, pre_window_new_hook, redirect_io, restore_io
Constructor Details
#initialize(options) ⇒ HandbookCreator
Returns a new instance of HandbookCreator.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 25 def initialize () super() # MUST BE FIRST - All code before super is executed twice in RubyQt Based classes Cosmos.load_cosmos_icon("handbook_creator.png") initialize_actions() () () complete_initialize() # Bring up slash screen for long duration tasks after creation Splash.execute(self) do |splash| ConfigParser.splash = splash System.commands @config = HandbookCreatorConfig.new(.config_file) ConfigParser.splash = nil end end |
Class Method Details
.run(option_parser = nil, options = nil) ⇒ Object
Runs the application
140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 140 def self.run(option_parser = nil, = nil) Cosmos.catch_fatal_exception do unless option_parser and option_parser, = () .title = "Handbook Creator" .config_file = File.join(Cosmos::USERPATH, 'config', 'tools', 'handbook_creator', 'handbook_creator.txt') option_parser.on("-c", "--config FILE", "Use the specified configuration file") do |arg| .config_file = File.join(Cosmos::USERPATH, 'config', 'tools', 'handbook_creator', arg) end end super(option_parser, ) end end |
Instance Method Details
#create_pdfs(both, hide_ignored) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 64 def create_pdfs(both, hide_ignored) success = false ProgressDialog.execute(self, 'PDF Creation Progress', 700, 600, true, false, true, true, false) do |progress_dialog| begin success = @config.create_pdf(hide_ignored, progress_dialog) if success msg = "\n\n" msg << "HTML and " if both msg << "PDF Handbooks created successfully" progress_dialog.append_text(msg) else progress_dialog.append_text("\nPDF Handbooks could not be created.\n\nIs wkhtmltopdf in your PATH and are all existing pdfs closed?\n\nUsing version 0.11.0_rc1 of wkhtmltox is recommended which can be found at: http://download.gna.org/wkhtmltopdf/obsolete/\n\nVersion 0.12.x has shown issues with Handbook Creator's default templates.") end rescue => error progress_dialog.append_text("\n\nError processing:\n#{error.formatted}") ensure progress_dialog.complete end end rescue Exception => err Cosmos.handle_critical_exception(err) end |
#initialize_actions ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 43 def initialize_actions super() @hide_ignored_action = Qt::Action.new(tr('&Hide Ignored Items'), self) @hide_ignored_keyseq = Qt::KeySequence.new(tr('Ctrl+H')) @hide_ignored_action.shortcut = @hide_ignored_keyseq @hide_ignored_action.statusTip = tr('Do not include ignored items in command and telemetry handbooks') @hide_ignored_action.setCheckable(true) @hide_ignored_action.setChecked(false) end |
#initialize_central_widget ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 87 def # Create the central widget @central_widget = Qt::Widget.new setCentralWidget(@central_widget) @top_layout = Qt::VBoxLayout.new @html_button = Qt::PushButton.new(Cosmos.get_icon('html-32.png'), 'Create HTML Handbooks') @html_button.setStyleSheet("text-align:left") @html_button.connect(SIGNAL('clicked()')) do begin @config.create_html(@hide_ignored_action.isChecked) Qt::MessageBox.information(self, 'Done', 'HTML Handbooks created successfully') rescue Exception => err Cosmos.handle_critical_exception(err) end end @top_layout.addWidget(@html_button) @pdf_button = Qt::PushButton.new(Cosmos.get_icon('pdf-32.png'), 'Create PDF Handbooks') @pdf_button.setStyleSheet("text-align:left") @pdf_button.connect(SIGNAL('clicked()')) do create_pdfs(false, @hide_ignored_action.isChecked) end @top_layout.addWidget(@pdf_button) @html_pdf_button = Qt::PushButton.new('Create HTML and PDF Handbooks') @html_pdf_button.setStyleSheet("text-align:left") @html_pdf_button.connect(SIGNAL('clicked()')) do begin @config.create_html(@hide_ignored_action.isChecked) create_pdfs(true, @hide_ignored_action.isChecked) rescue Exception => err Cosmos.handle_critical_exception(err) end end @top_layout.addWidget(@html_pdf_button) @open_button = Qt::PushButton.new(Cosmos.get_icon('open_in_browser-32.png'), 'Open in Web Browser') @open_button.setStyleSheet("text-align:left") @open_button.connect(SIGNAL('clicked()')) do begin Cosmos.open_in_web_browser(File.join(System.paths['HANDBOOKS'], @config.pages[0].filename)) rescue Exception => err Cosmos.handle_critical_exception(err) end end @top_layout.addWidget(@open_button) @central_widget.setLayout(@top_layout) end |
#initialize_menus ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cosmos/tools/handbook_creator/handbook_creator.rb', line 53 def # File Menu @file_menu = .addMenu(tr('&File')) @file_menu.addAction(@hide_ignored_action) @file_menu.addAction(@exit_action) # Help Menu @about_string = "Handbook Creator creates Command and Telemetry Handbooks" () end |