[Hiki-dev:00617] Re: parser, formatter, message まわりの変更

アーカイブの一覧に戻る

KOMATSU Shinichiro koma2****@ms*****
2004年 12月 25日 (土) 01:59:53 JST


小松です。

挨拶が遅れてしまいましたが、
先日 Hiki の committer に登録していただき、
開発のお手伝いをさせていただくことになりました。
Hiki のリファクタリング、ドキュメントの充実
などをやっていきたいと思っておりますので、
皆様よろしくお願いします。


さて、

From: Kouhei Yanagita <sugi****@dream*****>
Subject: [Hiki-dev:00615] Re: parser, formatter, message まわりの変更
Date: Thu, Dec 23, 2004 at 06:42:20PM JST

> parser で思い出したのですが、
> hiki/parser.rb は今でも使われているのでしょうか?

報告ありがとうございます。調べてみましたが、
hiki/parser.rb を require or load しているファイルはないので、
使われてないようです。
CVS の log を見るに、style/default/* が出来た時以来
手が入ってないようですし、
紛らわしいので消してもいいのではないでしょうか? > かずひこさん?

> ざっと grep してみると
> about.rb プラグインと quote_page.rb プラグインで使われているようなのですが、
> これは style/*/parser.rb の方を使うように変更しなくてもいいのでしょうか?

これは [Hiki-dev:00608] でクラス名を変更したのに
追従してないのだと思います。
このままでは例外が起こるので、添付する patch のように
修正してみました。

misc/plugin/quote_page.rb では Parser, HTMLFormatter を
それぞれ @conf.parser, @conf,formatter に置き換えてますが、
about.rb の方では Parser_default, HTMLFormatter_default と
決め打ちしています。
これは、about_* の中のテキストが default style で
書かれているからです。

-- 
┏━━━━━━━━━━━━━━━━━━━━━━┓
                小松  晋一朗            
            koma2****@ms*****
            koma2****@momon*****
     http://straycat.ms.u-tokyo.ac.jp/~koma2/
┗━━━━━━━━━━━━━━━━━━━━━━┛
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /cvsroot/hiki/hiki/ChangeLog,v
retrieving revision 1.93
diff -u -r1.93 ChangeLog
--- ChangeLog	22 Dec 2004 04:43:03 -0000	1.93
+++ ChangeLog	24 Dec 2004 12:12:49 -0000
@@ -1,3 +1,8 @@
+2004-12-24  KOMATSU Shinichiro  <koma2****@ms*****>
+	* misc/plugin/quote_page.rb: s/Parser/@conf.parser/; s/HTMLFormatter/@conf.formatter/
+	* misc/plugin/about.rb: s/Parser/Parser_default/; s/HTMLFormatter/HTMLFormatter_default/
+	reported by Kouhei Yanagita ([Hiki-dev:00615])
+
 2004-12-22  Kazuhiko  <kazuh****@fdiar*****>
 	* style/default/html_formatter.rb, style/default/parser.rb: コード
 	の整理 by Kenta MURATA
Index: misc/plugin/about.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/misc/plugin/about.rb,v
retrieving revision 1.2
diff -u -r1.2 about.rb
--- misc/plugin/about.rb	1 Mar 2004 09:50:45 -0000	1.2
+++ misc/plugin/about.rb	24 Dec 2004 12:12:49 -0000
@@ -1,24 +1,26 @@
 # $Id: about.rb,v 1.2 2004/03/01 09:50:45 hitoshi Exp $
 # Copyright (C) 2003 OZAWA Sakuro <crout****@users*****>
 
+require 'style/default/html_formatter'
+require 'style/default/parser'
+
 def about_not_found_label; 'Documentation not found.'; end
 
 def about(plugin_name, top_wanted=1)
   about_plugin = 'about_' + plugin_name
   text = respond_to?(about_plugin) ? send(about_plugin) : about_not_found_label
-  tokens = Parser.new.parse(text)
-  HTMLFormatter.new(remap_headings(tokens, top_wanted), @db, self).to_s
+  tokens = Parser_default.new(@conf).parse(text)
+  HTMLFormatter_default.new(remap_headings(tokens, top_wanted), @db, self, @conf).to_s
 end
 
 def about_plugins(top=1)
   abouts = methods.select {|m| /^about_/ =~ m }
   abouts.reject! {|m| m == 'about_plugins' || m == 'about_not_found_label' }
-  parser = Parser.new
   result = ''
   abouts.collect do |m|
     heading = m.sub(/^about_/, 'About ')   
     name = m.sub(/^about_/, '')   
-    result << HTMLFormatter.new(parser.parse('!' * top + heading + "\n"), @db, self).to_s
+    result << HTMLFormatter_default.new(Parser_default.new(@conf).parse('!' * top + heading + "\n"), @db, self, @conf).to_s
     result << about(name, top + 1)
   end
   result
Index: misc/plugin/quote_page.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/misc/plugin/quote_page.rb,v
retrieving revision 1.2
diff -u -r1.2 quote_page.rb
--- misc/plugin/quote_page.rb	1 Mar 2004 09:50:45 -0000	1.2
+++ misc/plugin/quote_page.rb	24 Dec 2004 12:12:49 -0000
@@ -22,9 +22,8 @@
 def quote_page(name, top_wanted=1)
   unless @quote_page_quoted.include?(name)
     @quote_page_quoted << name
-    parser = Parser.new
-    tokens = parser.parse(@db.exist?(name) ? @db.load(name) : %Q|[[#{name}]]|)
-    HTMLFormatter.new(remap_headings(tokens, top_wanted), @db, self).to_s
+    tokens =****@conf*****(@conf).parse(@db.exist?(name) ? @db.load(name) : %Q|[[#{name}]]|)
+    @conf.formatter.new(remap_headings(tokens, top_wanted), @db, self, @conf).to_s
   else
     ''
   end


Hiki-dev メーリングリストの案内
アーカイブの一覧に戻る