aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/man.rb
diff options
context:
space:
mode:
authorMike McQuaid2014-09-20 15:30:44 +0100
committerMike McQuaid2014-09-24 15:23:33 -0700
commit52d6aa379cd1040b0da3c62cfd48076368557175 (patch)
tree84d81d62a4e6f2d38bd1482baa77bbae1046bc17 /Library/Homebrew/cmd/man.rb
parent0f38b19a8c3c22a55ae9a7d5106cf7f1b78144d0 (diff)
downloadhomebrew-52d6aa379cd1040b0da3c62cfd48076368557175.tar.bz2
brew-man: Rubify, make an internal command.
Closes #32472.
Diffstat (limited to 'Library/Homebrew/cmd/man.rb')
-rwxr-xr-xLibrary/Homebrew/cmd/man.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/man.rb b/Library/Homebrew/cmd/man.rb
new file mode 100755
index 000000000..f28d76de1
--- /dev/null
+++ b/Library/Homebrew/cmd/man.rb
@@ -0,0 +1,37 @@
+require 'formula'
+
+module Homebrew
+ SOURCE_PATH=HOMEBREW_REPOSITORY/"Library/Homebrew/manpages"
+ TARGET_PATH=HOMEBREW_REPOSITORY/"share/man/man1"
+ LINKED_PATH=HOMEBREW_PREFIX/"share/man/man1"
+
+ def man
+ if ARGV.include?("--link") || ARGV.include?("-l")
+ Dir["#{TARGET_PATH}/*.1"].each do |page|
+ FileUtils.ln_s page, LINKED_PATH
+ return
+ end
+ end
+
+ which("ronn") || odie("You need to \"gem install ronn\" and put it in your path.")
+
+ if ARGV.include?("--server") || ARGV.include?("-s")
+ puts "Man page test server: http://localhost:1207/"
+ puts "Control-C to exit."
+ system "ronn", "--server", Dir["#{SOURCE_PATH}/*"]
+ return
+ end
+
+ puts "Writing manpages to #{TARGET_PATH}"
+
+ target_file = nil
+ Dir["#{SOURCE_PATH}/*.md"].each do |source_file|
+ target_file = TARGET_PATH/File.basename(source_file, ".md")
+ safe_system "ronn --roff --pipe --organization='Homebrew' --manual='brew' #{source_file} > #{target_file}"
+ end
+
+ if ARGV.include?("--verbose") || ARGV.include?("-v")
+ system "man", target_file
+ end
+ end
+end