From f1b07529002655e3805f08537fe71f9bfe405acf Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 29 Dec 2006 01:14:48 +0000 Subject: [PATCH] Moved utils script to utils/ (instead of trunk) --- utils/fetch_doc.rb | 82 +++++++++++++++++++++++++++++++++++++++++++ utils/roll_release.sh | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100755 utils/fetch_doc.rb create mode 100755 utils/roll_release.sh diff --git a/utils/fetch_doc.rb b/utils/fetch_doc.rb new file mode 100755 index 0000000..a680853 --- /dev/null +++ b/utils/fetch_doc.rb @@ -0,0 +1,82 @@ +#!/usr/bin/env ruby +# +# fetch_doc.rb +# +# Fetch the documentation from the wiki and translate it +# to be human readable. +# + +require 'open-uri' + +BASE_URI = 'http://www.pamusb.org/wiki/doc/' +DOC_PATH = '../doc/' +DOCS = [ 'installation', 'upgrading', 'configuration', 'faq' ] +MANS = [ 'pusb_hotplug', 'pusb_conf', 'pusb_check' ] + +REPLACE_LIST = [ + # Remove wiki links [[link|name]] + { :pattern => /\[\[.+\|(.+)\]\]/, :with => '\1' }, + + # Remove misc xhtml/wiki characters + { :pattern => /\/\//, :with => '' }, + { :pattern => /\\\\ /, :with => '' }, + { :pattern => /\*\*/, :with => '' }, + { :pattern => /</, :with => '<' }, + { :pattern => />/, :with => '>' }, + { :pattern => /"/, :with => '"' }, + { :pattern => /.*\n/, :with => '' }, + { :pattern => /<\/code>.*\n/, :with => '' }, + { :pattern => /(.+)<\/file>/m, :with => '\1' }, + + # Remove trailing whitespaces + { :pattern => /^ /, :with => '' }, + + # Fit 80 colums + { :pattern => /(.{1,80})( +|$\n?)|(.{1,80})/, :with => "\\1\\3\n" }, +] + +def fetch_raw_doc(name) + uri = BASE_URI + name + '?do=edit' + + body = open(uri) { |f| f.read } + body.gsub!(/.*