[#31320] Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

124 messages 2007/08/01
[#31321] Re: Import RubyGems to Ruby 1.9 — Nobuyoshi Nakada <nobu@...> 2007/08/01

なかだです。

[#31329] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/08/01

-----BEGIN PGP SIGNED MESSAGE-----

[#31918] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31970] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/08

-----BEGIN PGP SIGNED MESSAGE-----

[#32023] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/11

まつもと ゆきひろです

[#32062] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32066] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32068] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32069] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32070] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#32073] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/15

まつもと ゆきひろです

[#32079] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/16

-----BEGIN PGP SIGNED MESSAGE-----

[#32080] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/16

まつもと ゆきひろです

[#32132] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#32081] Re: Import RubyGems to Ruby 1.9 — Takahiro Kambe <taca@...> 2007/10/16

In message <471447D5.5050902@sarion.co.jp>

[#32087] Re: Import RubyGems to Ruby 1.9 — "Akinori MUSHA" <knu@...> 2007/10/17

 Rubygems は、基本的に他のパッケージシステムから包みやすい作り

[#32104] Re: Import RubyGems to Ruby 1.9 — akira yamada <akira@...> 2007/10/20

Tuesday 16 October 2007 14:09:13 に NAKAMURA, Hiroshi さんは書きました:

[#32109] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/20

-----BEGIN PGP SIGNED MESSAGE-----

[#31332] Re: Import RubyGems to Ruby 1.9 — Tadayoshi Funaba <tadf@...> 2007/08/01

> ちなみに「ruby/1.9.1の標準添付からどのライブラリを外すか?」という議論も

[#31858] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/25

-----BEGIN PGP SIGNED MESSAGE-----

[#31872] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/27

-----BEGIN PGP SIGNED MESSAGE-----

[#31905] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/29

-----BEGIN PGP SIGNED MESSAGE-----

[#31906] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/29

まつもと ゆきひろです

[#31910] Re: Import RubyGems to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/09/30

-----BEGIN PGP SIGNED MESSAGE-----

[#31920] Re: Import RubyGems to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/09/30

まつもと ゆきひろです

[#31323] Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...>

むらけんです.

16 messages 2007/08/01
[#31326] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31327] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — "Kenta Murata" <muraken@...> 2007/08/01

むらけんです.

[#31328] Re: Bignum#to_s の Karatsuba 基数変換による高速化 — Yukihiro Matsumoto <matz@...> 2007/08/01

まつもと ゆきひろです

[#31525] いくつかのバグ報告と提案(5点) — eklerni <eklerni@...>

From:eklerni

13 messages 2007/08/20

[#31539] strtod の精度 — Satoshi Nakagawa <snakagawa@...>

中川といいます。

27 messages 2007/08/20
[#31542] Re: strtod の精度 — Yukihiro Matsumoto <matz@...> 2007/08/20

まつもと ゆきひろです

[ruby-dev:31350] Re: RDoc i18n化パッチ

From: KURODA Hiraku <hiraku@...>
Date: 2007-08-05 15:19:00 UTC
List: ruby-dev #31350
黒田拓です。
なかださん、お返事ありがとうございました。

Nobuyoshi Nakada さんは書きました:
> 基本的には、こういった機能追加は1.8ではなく1.9でしょう。

言われてみればそうでした。
頂いた助言を元にパッチを作り直したのですが、今回、パッチ元は1.9にしました。


> 細かいことをいうと、remove_unwanted_langがちょっとまどろっこしい
> かな。

修正、ありがとうございました。自分の書いたコードがえらくスッキリと変わっ
ていて驚きました。


> * lang: が視覚的な区切りとして認識しづらい

とりあえず:section:とかと同様に、:lang: を区切りにするようにしたのです
が、あまり変わらないですね。悩ましいところです。

他に、
>         if l.sub!(/^(\s*\#?).*\s*lang:\s*([a-z]{2})/n, '\1')
>           sl = $2
などとして「`:lang: ja'の前後に任意の文字を入れられる」とかも考えてみた
のですが、条件がゆるすぎるような気がして今回提出のパッチには入れていない
です。

後は使い方の問題にして、ドキュメントを書く際に言語指定の前に空行だけのコ
メント行を入れて目立たせるとかでしょうか。


> * 出力されたHTMLのcharsetがiso8859-1のまま
> * 異なるエンコーディングはどう扱うべきか
> といったあたりが疑問です。

まず、デフォルトのcharset指定をUTF-8に変更してみました。

そして、出力するcharsetに応じて、Kconvを使って変換するオプションを追加し
てみました。
起動時に
 * -K オプションが指定されていたらKconvを使って変換する
 * `-k euc' などとして変換元の文字コードを指定出来る
 * -kによる指定がない場合は、変換元文字コードにはKconv::AUTOを使う
という動作です。

 ~/$ rdoc -l ja -K -k euc -c Shift_jis
といった具合です。

他の言語がどう記述されるか見当がつかなかったので(本当に多言語なドキュメ
ントをソースに入れるならUTF-8を使うことになるのでしょうか)、僕の方ではと
りあえず日本語のみを念頭に考えています。


-- 
--------------------------------------------------
 黒田 拓(くろだ ひらく)
    hiraku@sapporo.email.ne.jp
    http://www.hinet.mydns.jp/~hiraku/
--------------------------------------------------


Attachments (1)

rdoc_i18n_1.9-r12874.patch (3.16 KB, text/x-diff)
diff -ur ruby1.9.orig/lib/rdoc/options.rb ruby1.9/lib/rdoc/options.rb
--- ruby1.9.orig/lib/rdoc/options.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby1.9/lib/rdoc/options.rb	2007-08-05 23:45:11.000000000 +0900
@@ -94,6 +94,12 @@
   # scan newer sources than the flag file if true.
   attr_reader :force_update
 
+  # Language of Document
+  attr_reader :lang
+  attr_reader :lang_strict
+  attr_reader :kcode
+  attr_reader :kconv
+
   module OptionList
 
     OPTION_LIST = [
@@ -238,6 +244,18 @@
         "name of the current file will be substituted;\n" +
         "if the URL doesn't contain a '\%s', the\n" +
         "filename will be appended to it." ],
+
+      [ "--lang",          "-l",   "language",
+        "Set language of document."],
+
+      [ "--lang-strict",   "-L",  nil,
+        "Use ONLY language-specified(or not specified) document."],
+
+      [ "--kconv", "-K", nil,
+	"Convert comment charset by kconv."],
+
+      [ "--kcode", "-k", "kcode",
+	"Set charset of comments in source file."],
     ]
 
     def OptionList.options
@@ -381,7 +399,7 @@
                  when /^E/i
                    'EUC-JP'
                  else
-                   'iso-8859-1'
+                   'UTF-8'
                  end
 
       accessors = []
@@ -409,6 +427,10 @@
         when "--template"      then @template      = arg
         when "--title"         then @title         = arg
         when "--webcvs"        then @webcvs        = arg
+        when "--lang"          then @lang          = arg
+        when "--lang-strict"   then @lang_strict   = true
+	when "--kcode"         then @kcode = arg
+	when "--kconv"         then @kconv = true
 
         when "--accessor" 
           arg.split(/,/).each do |accessor|
diff -ur ruby1.9.orig/lib/rdoc/parsers/parse_rb.rb ruby1.9/lib/rdoc/parsers/parse_rb.rb
--- ruby1.9.orig/lib/rdoc/parsers/parse_rb.rb	2007-02-13 08:01:19.000000000 +0900
+++ ruby1.9/lib/rdoc/parsers/parse_rb.rb	2007-08-05 23:45:11.000000000 +0900
@@ -2339,6 +2339,9 @@
           context.set_current_section(param, comment)
           comment.clear
           break 
+
+	when "lang"
+	  break
         else
           warn "Unrecognized directive '#{directive}'"
           break
@@ -2346,6 +2349,7 @@
       end
 
       remove_private_comments(comment)
+      remove_unwanted_lang(comment)
     end
 
     def remove_private_comments(comment)
@@ -2353,6 +2357,42 @@
       comment.sub!(/^#--.*/m, '')
     end
 
+    def remove_unwanted_lang(comment)
+      dl = @options.lang # Document Language
+      strict = @options.lang_strict
+      sl = nil # Section Language
+      r = []
+      comment.each_line do |l|
+	if l.sub!(/^(\s*\#?)\s*:lang:\s*([a-z]{2})(?=\s|$)/n, '\1')
+	  sl = $2
+	  r << l
+	elsif sl == dl or !(strict || (dl && sl))
+	  r << l
+	end
+      end
+
+      r = r.join
+      if @options.kconv
+	require "kconv"
+	oc, ic = [@options.charset, @options.kcode].map do |i|
+	  case i
+	  when /^s/i
+	    Kconv::SJIS
+	  when /^e/i
+	    Kconv::EUC
+	  when /^u/i
+	    Kconv::UTF8
+	  else
+	    nil
+	  end
+	end
+	oc = Kconv::UTF8 unless oc
+	ic = Kconv::AUTO unless ic
+	r = r.kconv(oc, ic)
+      end
+
+      comment.replace(r)
+    end
 
 
     def get_symbol_or_name

In This Thread

Prev Next