我已经决定将我的项目中的README文件转换为markdown并且已经使用了yard验证了所提供的文档。所以我安装了rdiscount,将README更改为README.md并尝试:
yard doc README.md
给了我一个警告:
[warn]: Syntax error in `readme.md`:(3,18): syntax error, unexpected tinteger, expecting $end
所以我试过了:
yard doc -m markdown -- README.md
同样的问题。运行:
yard doc --backtrace -- README.md
提供更多信息:
[warn]: Syntax error in `readme.md`:(3,18): syntax error, unexpected tinteger, expecting $end
[error]: ParserSyntaxError: syntax error in `README.md`:(3,18): syntax error, unexpected tINTEGER, expecting $end
[error]: Stack trace:
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/ruby/ruby_parser.rb:505:in `on_parse_error'
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/ruby/ruby_parser.rb:49:in `parse'
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/ruby/ruby_parser.rb:49:in `parse'
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/ruby/ruby_parser.rb:15:in `parse'
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/source_parser.rb:438:in `parse'
/Users/wadewest/.rvm/gems/ruby-1.9.2-p290@peppercorn/gems/yard-0.7.3/lib/yard/parser/source_parser.rb:361:in `parse_in_order'
如果我尝试使用纺织品,也会发生同样的事情。如果有人想尝试重现问题,项目就在github。谢谢。
答案 0 :(得分:6)
我认为你对yard
选项感到困惑。帮助说:
$ yard --help doc
Usage: yard doc [options] [source_files [- extra_files]]
(if a list of source files is omitted,
{lib,app}/**/*.rb ext/**/*.c is used.)
Example: yardoc -o documentation/ - FAQ LICENSE
The above example outputs documentation for files in
lib/**/*.rb to documentation/ including the extra files
FAQ and LICENSE.
...
所以当你这样说:
$ yard doc -m markdown -- README.md
Yard会尝试将README.md
解释为某种源文件。您的README.md
将被解释为Ruby源文件(它不是)并导致 Ruby 错误,如下所示:
unexpected tinteger, expecting $end
如果您稍微编辑README.md
,您会看到错误的位置在移动,但如果您尝试将README.md
读取为Ruby源文件,则错误将有意义。
在完全运行README.md
时,您无需说出yard
的任何内容,yard
将知道如何处理README.md
所有内容。