From 56015d05becf16b4ae5084b979d6000dd8a2e5c2 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 26 Oct 2013 00:30:42 -0600 Subject: resolves #739 generate API docs using YARD instead of RDoc --- .gitignore | 1 + Rakefile | 33 +++++++++++++++++++++++++++++++-- asciidoctor.gemspec | 3 ++- lib/asciidoctor/abstract_node.rb | 2 +- lib/asciidoctor/substitutors.rb | 2 +- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f6a58923..48a7d7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ pkg/ /Gemfile.lock /.bundle +/.yardoc/ /rdoc/ diff --git a/Rakefile b/Rakefile index a3ad9626..ddb9ddc9 100644 --- a/Rakefile +++ b/Rakefile @@ -44,17 +44,46 @@ begin rescue LoadError end +=begin begin require 'rdoc/task' RDoc::Task.new do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = "Asciidoctor #{Asciidoctor::VERSION}" rdoc.markup = 'tomdoc' if rdoc.respond_to?(:markup) - #rdoc.rdoc_files.include('CHANGELOG', 'LICENSE', 'README.adoc', 'lib/**/*.rb') rdoc.rdoc_files.include('LICENSE', 'lib/**/*.rb') end rescue LoadError end +=end + +begin + require 'yard' + require 'yard-tomdoc' + require './lib/asciidoctor' + # register .adoc extension for AsciiDoc markup helper + YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:asciidoc] = %w(adoc) + YARD::Rake::YardocTask.new do |yard| + yard.files = %w( + lib/**/*.rb + - + CHANGELOG.adoc + LICENSE + ) + # --no-highlight enabled to prevent verbatim blocks in AsciiDoc that begin with $ from being dropped + # need to patch htmlify method to not attempt to syntax highlight blocks (or fix what's wrong) + yard.options = %w( + --exclude backends + --exclude opal_ext + --hide-api private + --no-highlight + -o rdoc + --plugin tomdoc + --title Asciidoctor\ API\ Documentation + ) + end +rescue LoadError +end begin require 'bundler/gem_tasks' @@ -71,5 +100,5 @@ end desc 'Open an irb session preloaded with this library' task :console do - sh "bundle console", :verbose => false + sh 'bundle console', :verbose => false end diff --git a/asciidoctor.gemspec b/asciidoctor.gemspec index ef54356b..c4cf2601 100644 --- a/asciidoctor.gemspec +++ b/asciidoctor.gemspec @@ -35,8 +35,9 @@ EOS s.add_development_dependency 'haml', '~> 4.0.0' s.add_development_dependency 'nokogiri', '~> 1.5.10' s.add_development_dependency 'rake', '~> 10.0.0' - s.add_development_dependency 'rdoc', '~> 4.0.0' s.add_development_dependency 'rspec-expectations', '~> 2.14.0' s.add_development_dependency 'slim', '~> 2.0.0' s.add_development_dependency 'tilt', '~> 1.4.1' + s.add_development_dependency 'yard', '~> 0.8.7' + s.add_development_dependency 'yard-tomdoc', '~> 0.7.0' end diff --git a/lib/asciidoctor/abstract_node.rb b/lib/asciidoctor/abstract_node.rb index 8003d0c4..7c30caab 100644 --- a/lib/asciidoctor/abstract_node.rb +++ b/lib/asciidoctor/abstract_node.rb @@ -135,7 +135,7 @@ class AbstractNode # enabled on the current node. # # Check if the option is enabled. This method simply checks to see if the - # {name}-option attribute is defined on the current node. + # %name%-option attribute is defined on the current node. # # name - the String or Symbol name of the option # diff --git a/lib/asciidoctor/substitutors.rb b/lib/asciidoctor/substitutors.rb index b1911c47..59105c6a 100644 --- a/lib/asciidoctor/substitutors.rb +++ b/lib/asciidoctor/substitutors.rb @@ -263,7 +263,7 @@ module Substitutors # Public: Substitute attribute references # - # Attribute references are in the format {name}. + # Attribute references are in the format +{name}+. # # If an attribute referenced in the line is missing, the line is dropped. # -- cgit v1.2.3