Skip to content

Commit f5bfc84

Browse files
committed
Land rapid7#6977, Add a more verbose message when generating module documentation
2 parents bca88d8 + 78775f7 commit f5bfc84

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,8 +778,13 @@ def cmd_info(*args)
778778
if dump_json
779779
print(Serializer::Json.dump_module(active_module) + "\n")
780780
elsif show_doc
781-
print_status("Please wait, generating documentation for #{active_module.shortname}")
782-
Msf::Util::DocumentGenerator.spawn_module_document(active_module)
781+
f = Rex::Quickfile.new(["#{active_module.shortname}_doc", '.html'])
782+
begin
783+
print_status("Generating documentation for #{active_module.shortname}, then opening #{f.path} in a browser...")
784+
Msf::Util::DocumentGenerator.spawn_module_document(active_module, f)
785+
ensure
786+
f.close if f
787+
end
783788
else
784789
print(Serializer::ReadableText.dump_module(active_module))
785790
end
@@ -801,8 +806,13 @@ def cmd_info(*args)
801806
elsif dump_json
802807
print(Serializer::Json.dump_module(mod) + "\n")
803808
elsif show_doc
804-
print_status("Please wait, generating documentation for #{mod.shortname}")
805-
Msf::Util::DocumentGenerator.spawn_module_document(mod)
809+
f = Rex::Quickfile.new(["#{active_module.shortname}_doc", '.html'])
810+
begin
811+
print_status("Generating documentation for #{active_module.shortname}, then opening #{f.path} in a browser...")
812+
Msf::Util::DocumentGenerator.spawn_module_document(active_module, f)
813+
ensure
814+
f.close if f
815+
end
806816
else
807817
print(Serializer::ReadableText.dump_module(mod))
808818
end

lib/msf/util/document_generator.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ module DocumentGenerator
1515
# Spawns a module document with a browser locally.
1616
#
1717
# @param mod [Msf::Module] Module to create document for.
18+
# @param out_file [Rex::Quickfile] File handle to write the document to.
1819
# @return [void]
19-
def self.spawn_module_document(mod)
20+
def self.spawn_module_document(mod, out_file)
2021
md = get_module_document(mod)
21-
f = Rex::Quickfile.new(["#{mod.shortname}_doc", '.html'])
22-
f.write(md)
23-
f.close
24-
kb_path = f.path
25-
26-
Rex::Compat.open_webrtc_browser("file://#{kb_path}")
22+
out_file.write(md)
23+
Rex::Compat.open_webrtc_browser("file://#{out_file.path}")
2724
end
2825

2926

0 commit comments

Comments
 (0)