Ruby 컨트리뷰션 시작하기: RDoc을 활용한 문서화 기여 방법
Ruby 소스 코드 기여는 거창한 기능 구현뿐만 아니라 10줄 미만의 작은 문서화 수정이나 예제 코드 오류 교정만으로도 큰 가치를 지닌다.
Ruby 컨트리뷰션 시작하기: RDoc을 활용한 문서화 기여 방법
Ruby 소스 코드 기여는 거창한 기능 구현뿐만 아니라 10줄 미만의 작은 문서화 수정이나 예제 코드 오류 교정만으로도 큰 가치를 지닌다.
Recently I learned you can use #RDoc in your #RubyGem description, and rubygems.org will render it as HTML!
Unfortunately, their CSS reset gets the better of it. But not for long, if this PR gets merged: https://github.com/rubygems/rubygems.org/pull/6228 (before/after screenshots included)
Here's to @st0012 and his fabulous work on Aliki that made this easy!
Interesting to see there’s an effort underway to support YARD syntax in the rdoc gem…
https://github.com/ruby/rdoc/pull/1416
Which seems to come out of…
@serge many of the projects we use in Python, like #Flask, are documented using #Sphinx, which can be configured to automatically generate API documentation from Python source code:
https://www.sphinx-doc.org/en/master/tutorial/automatic-doc-generation.html
This is (similar to the #yardoc and #rdoc situation) backwards compatible with #pydoc, though much more expressive due to the machine-readable format for defining parameters, return values and potential exceptions:
https://www.sphinx-doc.org/en/master/tutorial/automatic-doc-generation.html
Learned about #ruby #rdoc this morning :)
thingy.rb
```ruby
# This is the function that does a thingy
def my_thingy
puts "my thingy"
end
```
Rakefile
```ruby
require 'rdoc/task'
task :default => [:rdoc]
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'rdoc'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('/*.rb')
end
```
```bash
> rake
```
Generates searchable documentation, and displays my docs in my editors overlay hints :)