From 472240687caf3f113a3ff408729f8205c475d7d5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 09:20:40 +0000 Subject: doc: use wrongdoc for documentation wrongdoc factors out a bunch of common code from this project into its own and removes JavaScript from RDoc to boot. --- .document | 1 + .gitignore | 1 + .wrongdoc.yml | 4 +++ GNUmakefile | 68 +++++++++------------------------------ Rakefile | 102 +--------------------------------------------------------- kgio.gemspec | 31 +++++++----------- 6 files changed, 33 insertions(+), 174 deletions(-) create mode 100644 .wrongdoc.yml diff --git a/.document b/.document index 593bf40..f3e553b 100644 --- a/.document +++ b/.document @@ -2,6 +2,7 @@ LICENSE README TODO NEWS +LATEST ChangeLog ISSUES HACKING diff --git a/.gitignore b/.gitignore index 88d1bfe..77c63dd 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ pkg/ /man tags TAGS +/LATEST diff --git a/.wrongdoc.yml b/.wrongdoc.yml new file mode 100644 index 0000000..2c904c7 --- /dev/null +++ b/.wrongdoc.yml @@ -0,0 +1,4 @@ +--- +cgit_url: http://git.bogomips.org/cgit/kgio.git +git_url: git://git.bogomips.org/kgio.git +rdoc_url: http://bogomips.org/kgio/ diff --git a/GNUmakefile b/GNUmakefile index 62bf388..d913176 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,6 @@ all:: RUBY = ruby RAKE = rake RSYNC = rsync -GIT_URL = git://git.bogomips.org/kgio.git GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @./GIT-VERSION-GEN @@ -32,56 +31,22 @@ clean: -$(MAKE) -C ext/kgio clean $(RM) $(setup_rb_files) ext/kgio/Makefile -pkg_extra := GIT-VERSION-FILE NEWS ChangeLog -manifest: $(pkg_extra) - $(RM) .manifest - $(MAKE) .manifest +pkg_extra := GIT-VERSION-FILE NEWS ChangeLog LATEST +ChangeLog: GIT-VERSION-FILE .wrongdoc.yml + wrongdoc prepare -.manifest: - (git ls-files && \ - for i in $@ $(pkg_extra) $(man1_paths); \ - do echo $$i; done) | LC_ALL=C sort > $@+ +.manifest: ChangeLog + (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \ + LC_ALL=C sort > $@+ cmp $@+ $@ || mv $@+ $@ $(RM) $@+ -NEWS: GIT-VERSION-FILE - $(RAKE) -s news_rdoc > $@+ - mv $@+ $@ - -latest: NEWS - @awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $< - -SINCE = -ChangeLog: LOG_VERSION = \ - $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \ - echo $(GIT_VERSION) || git describe) -ifneq ($(SINCE),) -ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION) -endif -ChangeLog: GIT-VERSION-FILE - @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+ - @echo >> $@+ - git log $(log_range) | sed -e 's/^/ /' >> $@+ - mv $@+ $@ - -news_atom := http://bogomips.org/kgio/NEWS.atom.xml -cgit_atom := http://git.bogomips.org/cgit/kgio.git/atom/?h=master -atom = - -# using rdoc 2.5.x -doc: .document NEWS ChangeLog - rdoc -t "$(shell sed -ne '1s/^= //p' README)" +doc: .document .wrongdoc.yml + find lib ext -type f -name '*.rbc' -exec rm -f '{}' ';' + $(RM) -r doc + wrongdoc all install -m644 COPYING doc/COPYING install -m644 $(shell grep '^[A-Z]' .document) doc/ - $(RUBY) -i -p -e \ - '$$_.gsub!("",%q{\&$(call atom,$(cgit_atom))})' \ - doc/ChangeLog.html - $(RUBY) -i -p -e \ - '$$_.gsub!("",%q{\&$(call atom,$(news_atom))})' \ - doc/NEWS.html doc/README.html - $(RAKE) -s news_atom > doc/NEWS.atom.xml - cd doc && ln README.html tmp && mv tmp index.html ifneq ($(VERSION),) rfproject := rainbows @@ -94,10 +59,10 @@ release_changes := release_changes-$(VERSION) release-notes: $(release_notes) release-changes: $(release_changes) $(release_changes): - $(RAKE) -s release_changes > $@+ + wrongdoc release_changes > $@+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@ $(release_notes): - GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+ + wrongdoc release_notes > $@+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@ # ensures we're actually on the tagged $(VERSION), only used for release @@ -170,10 +135,8 @@ $(test_units): build # this requires GNU coreutils variants publish_doc: -git set-file-times - $(RM) -r doc ChangeLog NEWS - $(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1) - $(MAKE) -s latest > doc/LATEST - find doc/images doc/js -type f | \ + $(MAKE) doc + find doc/images -type f | \ TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css $(MAKE) doc_gz chmod 644 $$(find doc -type f) @@ -184,8 +147,7 @@ publish_doc: # "gzip_static on" can serve the gzipped versions directly. doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.\(gif\|jpg\|png\|gz\)$$') doc_gz: - touch doc/NEWS.atom.xml -d "$$(awk 'NR==1{print $$4,$$5,$$6}' NEWS)" for i in $(docs); do \ gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done -.PHONY: .FORCE-GIT-VERSION-FILE doc manifest man test $(test_units) +.PHONY: .FORCE-GIT-VERSION-FILE doc manifest test $(test_units) diff --git a/Rakefile b/Rakefile index b687070..b663562 100644 --- a/Rakefile +++ b/Rakefile @@ -1,106 +1,6 @@ # -*- encoding: binary -*- - -# most tasks are in the GNUmakefile which offers better parallelism - -def tags - timefmt = '%Y-%m-%dT%H:%M:%SZ' - @tags ||= `git tag -l`.split(/\n/).map do |tag| - if %r{\Av[\d\.]+} =~ tag - header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3) - header = header.split(/\n/) - tagger = header.grep(/\Atagger /).first - body ||= "initial" - { - :time => Time.at(tagger.split(/ /)[-2].to_i).utc.strftime(timefmt), - :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip, - :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip, - :id => `git rev-parse refs/tags/#{tag}`.chomp!, - :tag => tag, - :subject => subject, - :body => body, - } - end - end.compact.sort { |a,b| b[:time] <=> a[:time] } -end - cgit_url = "http://git.bogomips.org/cgit/kgio.git" -git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/kgio.git' -web_url = "http://bogomips.org/kgio" - -desc 'prints news as an Atom feed' -task :news_atom do - require 'nokogiri' - new_tags = tags[0,10] - puts(Nokogiri::XML::Builder.new do - feed :xmlns => "http://www.w3.org/2005/Atom" do - id! "#{web_url}NEWS.atom.xml" - title "kgio news" - subtitle "socket methods using MSG_DONTWAIT and more" - link! :rel => "alternate", :type => "text/html", - :href => "#{web_url}NEWS.html" - updated(new_tags.empty? ? "1970-01-01T00:00:00Z" : new_tags.first[:time]) - new_tags.each do |tag| - entry do - title tag[:subject] - updated tag[:time] - published tag[:time] - author { - name tag[:tagger_name] - email tag[:tagger_email] - } - url = "#{cgit_url}/tag/?id=#{tag[:tag]}" - link! :rel => "alternate", :type => "text/html", :href =>url - id! url - message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip - content({:type =>:text}, message_only) - content(:type =>:xhtml) { pre tag[:body] } - end - end - end - end.to_xml) -end - -desc 'prints RDoc-formatted news' -task :news_rdoc do - tags.each do |tag| - time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC') - puts "=== #{tag[:tag].sub(/^v/, '')} / #{time}" - puts "" - - body = tag[:body] - puts tag[:body].gsub(/^/sm, " ").gsub(/[ \t]+$/sm, "") - puts "" - end -end - -desc "print release changelog for Rubyforge" -task :release_changes do - version = ENV['VERSION'] or abort "VERSION= needed" - version = "v#{version}" - vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort - prev = vtags[vtags.index(version) - 1] - if prev - system('git', 'diff', '--stat', prev, version) or abort $? - puts "" - system('git', 'log', "#{prev}..#{version}") or abort $? - else - system('git', 'log', version) or abort $? - end -end - -desc "print release notes for Rubyforge" -task :release_notes do - spec = Gem::Specification.load('kgio.gemspec') - puts spec.description.strip - puts "" - puts "* #{spec.homepage}" - puts "* #{spec.email}" - puts "* #{git_url}" - - _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3) - print "\nChanges:\n\n" - puts body -end +git_url = 'git://git.bogomips.org/kgio.git' desc "post news article to rubyforge" task :publish_news do diff --git a/kgio.gemspec b/kgio.gemspec index 2686309..7788378 100644 --- a/kgio.gemspec +++ b/kgio.gemspec @@ -1,36 +1,27 @@ ENV["VERSION"] or abort "VERSION= must be specified" manifest = File.readlines('.manifest').map! { |x| x.chomp! } -summary = File.readlines("README")[0].gsub(/\A=\s+\S+[^\w]+/, '').strip -description = File.read("README").split(/\n\n/)[1].strip +require 'wrongdoc' +extend Wrongdoc::Gemspec +name, summary, title = readme_metadata Gem::Specification.new do |s| s.name = %q{kgio} - s.version = ENV["VERSION"] - - s.homepage = 'http://bogomips.org/kgio/' - s.authors = ["kgio hackers"] + s.version = ENV["VERSION"].dup + s.homepage = Wrongdoc.config[:rdoc_url] + s.authors = ["#{name} hackers"] s.date = Time.now.utc.strftime('%Y-%m-%d') - s.description = description + s.description = readme_description s.email = %q{kgio@bogomips.org} - - s.extra_rdoc_files = File.readlines('.document').map! do |x| - x.chomp! - if File.directory?(x) - manifest.grep(%r{\A#{x}/}) - elsif File.file?(x) - x - else - nil - end - end.flatten.compact - + s.extra_rdoc_files = extra_rdoc_files(manifest) s.files = manifest - s.rdoc_options = [ "-t", summary ] + s.rdoc_options = rdoc_options s.require_paths = %w(lib ext) s.rubyforge_project = %q{rainbows} s.summary = summary s.test_files = Dir['test/test_*.rb'] s.extensions = %w(ext/kgio/extconf.rb) + s.add_development_dependency('wrongdoc', '~> 1.0.1') + # s.license = %w(LGPL) # disabled for compatibility with older RubyGems end -- cgit v1.2.3-24-ge0c7