This repository has been archived by the owner on Mar 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: svn://78.47.249.61/ruby-mediawiki/trunk@36 ba9c31aa-a806-0410-9a81-9f13d15ee83b
- Loading branch information
astro
committed
Dec 14, 2005
1 parent
16bfb54
commit 784627e
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'yaml' | ||
require 'rdoc/ri/ri_reader' | ||
|
||
$:.unshift('../lib') | ||
require 'mediawiki/dotfile' | ||
|
||
|
||
def find(dir, &block) | ||
Dir.foreach(dir) { |file| | ||
next if file =~ /^\./ | ||
|
||
path = "#{dir}/#{file}" | ||
if File.directory?(path) | ||
find(path) { |f| yield f } | ||
else | ||
yield path | ||
end | ||
} | ||
end | ||
|
||
def wiki_format(flow) | ||
s = '' | ||
case flow | ||
when Array | ||
flow.each { |subflow| | ||
s += wiki_format(subflow) | ||
} | ||
when SM::Flow::LIST | ||
flow.contents.each { |subflow| | ||
s += wiki_format(subflow) | ||
} | ||
when SM::Flow::LI | ||
s += "* '''#{flow.label}''' #{flow.body}\n" | ||
when SM::Flow::P | ||
s += "#{flow.body}\n\n" | ||
else | ||
puts "Unknown Flow: #{flow.inspect}" | ||
end | ||
s.gsub!(/"/, '"') | ||
s.gsub!(/<b>(.+?)<\/b>/, '\'\'\'\1\'\'\'') | ||
s.gsub!(/<i>(.+?)<\/i>/, '\'\'\1\'\'') | ||
s | ||
end | ||
|
||
def belongs_to_class?(classname, methodname) | ||
c = classname.split(/::|#/) | ||
m = methodname.split(/::|#/) | ||
m.pop | ||
c == m | ||
end | ||
|
||
classes = [] | ||
methods = [] | ||
|
||
find("../rdoc-ri") { |file| | ||
next unless file =~ /\.yaml$/ | ||
ri = YAML::load(File.new(file)) | ||
case ri | ||
when RI::ClassDescription | ||
classes << ri | ||
when RI::MethodDescription | ||
methods << ri | ||
else | ||
puts "Unknown Description: #{ri.inspect}" | ||
end | ||
} | ||
|
||
classes.sort! { |a,b| | ||
a.full_name <=> b.full_name | ||
} | ||
methods.sort! { |a,b| | ||
a.full_name <=> b.full_name | ||
} | ||
|
||
text = '' | ||
classes.each { |klass| | ||
text += "==#{klass.full_name}==\n\n" | ||
text += wiki_format(klass.comment || []) | ||
methods.each { |method| | ||
if belongs_to_class?(klass.full_name, method.full_name) | ||
text += "===#{method.full_name}===\n" | ||
text += wiki_format(method.comment || []) | ||
text += "\n" | ||
end | ||
} | ||
} | ||
|
||
|
||
wiki, conf = MediaWiki.dotfile('rdoc to wiki') | ||
article = wiki.article(conf['page']) | ||
article.text = "=#{conf['title']}=\n\n" + text | ||
article.submit("I can even document myself :-)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/sh | ||
rdoc --inline-source --line-numbers --op rdoc lib/mediawiki.rb lib/mediawiki/*.rb | ||
rdoc --inline-source --line-numbers --op rdoc-ri -f ri lib/mediawiki.rb lib/mediawiki/*.rb |