diff --git a/autohotkey/tools/handbook_creator.ahk b/autohotkey/tools/handbook_creator.ahk index b2031fe2e..60761102b 100644 --- a/autohotkey/tools/handbook_creator.ahk +++ b/autohotkey/tools/handbook_creator.ahk @@ -19,5 +19,14 @@ Click 55 165 ; Open in browser HC-4 Sleep 2000 WinActivate Handbook Creator Sleep 500 +Send ^h ; Hide ignored parameters / items +Sleep 500 +Click 55 75 ; Create HTML HC-1 +WinWaitActive Done +Send {Enter} +WinWaitActive Handbook Creator +Click 55 165 ; Open in browser HC-4 +Sleep 2000 +WinActivate Handbook Creator Send ^q diff --git a/demo/config/tools/handbook_creator/templates/command_packets.html.erb b/demo/config/tools/handbook_creator/templates/command_packets.html.erb index d4287641a..1c3dbf9c5 100644 --- a/demo/config/tools/handbook_creator/templates/command_packets.html.erb +++ b/demo/config/tools/handbook_creator/templates/command_packets.html.erb @@ -4,6 +4,8 @@

<%= "#{packet.target_name} #{packet.packet_name}" %>

<%= packet.hazardous ? 'Hazardous' : '' %>
<%= packet.description %>
+ <% items = packet.sorted_items.reject{|item| ignored[packet.target_name].include? item.name} %> + <% next if items.empty? %> @@ -19,7 +21,7 @@ - <% packet.sorted_items.each do |item| %> + <% items.each do |item| %>
<%= item.name %> diff --git a/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb b/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb index 968ed12f1..ddac52c5d 100644 --- a/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb +++ b/demo/config/tools/handbook_creator/templates/telemetry_packets.html.erb @@ -3,6 +3,8 @@
">

<%= "#{packet.target_name} #{packet.packet_name}" %>

<%= packet.description %>
+ <% items = packet.sorted_items.reject{|item| ignored[packet.target_name].include? item.name} %> + <% next if items.empty? %> @@ -16,7 +18,7 @@ - <% packet.sorted_items.each do |item| %> + <% items.each do |item| %>
<%= item.name %> diff --git a/lib/cosmos/tools/handbook_creator/handbook_creator.rb b/lib/cosmos/tools/handbook_creator/handbook_creator.rb index cc046b03f..71ed5a26f 100644 --- a/lib/cosmos/tools/handbook_creator/handbook_creator.rb +++ b/lib/cosmos/tools/handbook_creator/handbook_creator.rb @@ -18,8 +18,8 @@ module Cosmos - # Creates command and telemetry handbooks from the COSMOS definitions in both - # HTML and PDF format. + # Creates command and telemetry handbooks from the COSMOS definitions in + # both HTML and PDF format. class HandbookCreator < QtTool def initialize (options) @@ -42,11 +42,18 @@ def initialize (options) 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 def initialize_menus # File Menu @file_menu = menuBar.addMenu(tr('&File')) + @file_menu.addAction(@hide_ignored_action) @file_menu.addAction(@exit_action) # Help Menu @@ -54,11 +61,11 @@ def initialize_menus initialize_help_menu() end - def create_pdfs(both = false) + 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(progress_dialog) + success = @config.create_pdf(hide_ignored, progress_dialog) if success msg = "\n\n" msg << "HTML and " if both @@ -88,7 +95,7 @@ def initialize_central_widget @html_button.setStyleSheet("text-align:left") @html_button.connect(SIGNAL('clicked()')) do begin - @config.create_html + @config.create_html(@hide_ignored_action.isChecked) Qt::MessageBox.information(self, 'Done', 'HTML Handbooks created successfully') rescue Exception => err Cosmos.handle_critical_exception(err) @@ -99,7 +106,7 @@ def initialize_central_widget @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() + create_pdfs(false, @hide_ignored_action.isChecked) end @top_layout.addWidget(@pdf_button) @@ -107,8 +114,8 @@ def initialize_central_widget @html_pdf_button.setStyleSheet("text-align:left") @html_pdf_button.connect(SIGNAL('clicked()')) do begin - @config.create_html - create_pdfs(true) + @config.create_html(@hide_ignored_action.isChecked) + create_pdfs(true, @hide_ignored_action.isChecked) rescue Exception => err Cosmos.handle_critical_exception(err) end diff --git a/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb b/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb index 71f1c1515..f63139063 100644 --- a/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb +++ b/lib/cosmos/tools/handbook_creator/handbook_creator_config.rb @@ -65,7 +65,8 @@ def add_section(section) @sections << section end - def create_html + def create_html(hide_ignored) + @hide_ignored = hide_ignored Cosmos.set_working_dir do if @type == :TARGETS target_names = @target_names @@ -77,7 +78,8 @@ def create_html end end - def create_pdf(progress_dialog = nil) + def create_pdf(hide_ignored, progress_dialog = nil) + @hide_ignored = hide_ignored if @pdf if progress_dialog Qt.execute_in_main_thread(true) do @@ -169,19 +171,45 @@ def create_file_internal(file, target_names, target_pages, output) if section.output != :ALL next unless section.output == output end - packets = [] - packets = build_packets(System.commands, target_names) if section.type == :CMD - packets = build_packets(System.telemetry, target_names) if section.type == :TLM + packets = build_packets(section.type, target_names) + ignored = build_ignored(section.type, target_names) if target_pages - section.create(file, target_names[0] + ' ' + section.title.to_s, packets) + section.create(file, target_names[0] + ' ' + section.title.to_s, packets, ignored) else - section.create(file, section.title.to_s, packets) + section.create(file, section.title.to_s, packets, ignored) end end end - def build_packets(packet_accessor, target_names) + def build_ignored(type, target_names) + ignored = {} + target_names = System.targets.keys if target_names.empty? + target_names.each do |name| + if @hide_ignored + if type == :CMD + ignored[name] = System.targets[name].ignored_parameters + elsif type == :TLM + ignored[name] = System.targets[name].ignored_items + end + else + # If we're not ignoring items the hash contains an empty array + ignored[name] = [] + end + end + ignored + end + + def build_packets(type, target_names) packets = [] + case type + when :CMD + packet_accessor = System.commands + when :TLM + packet_accessor = System.telemetry + else + # Return the empty array because there are no packets + return packets + end if target_names.empty? packet_accessor.all.sort.each do |target_name, target_packets| target_packets.sort.each do |packet_name, packet| @@ -221,7 +249,7 @@ def initialize(output, filename, title, type = :NONE) @type = type end - def create(file, title, packets = []) + def create(file, title, packets = [], ignored = {}) file.puts ERB.new(File.read(@filename)).result(binding) end @@ -235,15 +263,15 @@ def initialize(filename) process_file(filename) end - def create_html - @pages.each {|page| page.create_html} + def create_html(hide_ignored) + @pages.each {|page| page.create_html(hide_ignored)} end - def create_pdf(progress_dialog = nil) + def create_pdf(hide_ignored, progress_dialog = nil) begin @pages.each_with_index do |page, index| progress_dialog.set_overall_progress(index.to_f / @pages.length.to_f) if progress_dialog - page.create_pdf(progress_dialog) + page.create_pdf(hide_ignored, progress_dialog) end progress_dialog.set_overall_progress(1.0) if progress_dialog rescue Exception => err