Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit f62ef19a4aa3d3e4ce1aa37a499907ff776a8964 1 parent 210e5cc
authored December 24, 2010
1  .document
@@ -11,6 +11,7 @@ KNOWN_ISSUES
11 11
 TODO
12 12
 NEWS
13 13
 ChangeLog
  14
+LATEST
14 15
 lib
15 16
 ext/unicorn_http/unicorn_http.c
16 17
 unicorn_1
1  .gitignore
@@ -21,3 +21,4 @@ pkg/
21 21
 /GIT-VERSION-FILE
22 22
 /man
23 23
 /tmp
  24
+/LATEST
8  .wrongdoc.yml
... ...
@@ -0,0 +1,8 @@
  1
+---
  2
+cgit_url: http://git.bogomips.org/cgit/unicorn.git
  3
+git_url: git://git.bogomips.org/unicorn.git
  4
+rdoc_url: http://unicorn.bogomips.org/
  5
+changelog_start: v1.1.5
  6
+merge_html:
  7
+  unicorn_1: Documentation/unicorn.1.html
  8
+  unicorn_rails_1: Documentation/unicorn_rails.1.html
89  GNUmakefile
... ...
@@ -1,8 +1,6 @@
1 1
 # use GNU Make to run tests in parallel, and without depending on RubyGems
2 2
 all:: test
3 3
 
4  
-GIT_URL = git://git.bogomips.org/unicorn.git
5  
-CGIT_URL = http://git.bogomips.org/cgit/unicorn.git
6 4
 RLFLAGS = -G2
7 5
 
8 6
 MRI = ruby
@@ -157,78 +155,39 @@ clean:
157 155
 	$(RM) $(setup_rb_files) $(t_log)
158 156
 	$(RM) -r $(test_prefix) man
159 157
 
160  
-man:
161  
-	$(MAKE) -C Documentation install-man
  158
+man html:
  159
+	$(MAKE) -C Documentation install-$@
162 160
 
163  
-pkg_extra := GIT-VERSION-FILE NEWS ChangeLog $(ext)/unicorn_http.c
164  
-manifest: $(pkg_extra) man
165  
-	$(RM) .manifest
166  
-	$(MAKE) .manifest
  161
+pkg_extra := GIT-VERSION-FILE Changelog LATEST NEWS \
  162
+             $(ext)/unicorn_http.c $(man1_paths)
167 163
 
168  
-.manifest:
169  
-	(git ls-files && \
170  
-         for i in $@ $(pkg_extra) $(man1_paths); \
171  
-	 do echo $$i; done) | LC_ALL=C sort > $@+
  164
+ChangeLog: GIT-VERSION-FILE .wrongdoc.yml
  165
+	wrongdoc prepare
  166
+
  167
+.manifest: ChangeLog $(ext)/unicorn_http.c
  168
+	(git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
  169
+	  LC_ALL=C sort > $@+
172 170
 	cmp $@+ $@ || mv $@+ $@
173 171
 	$(RM) $@+
174 172
 
175  
-NEWS: GIT-VERSION-FILE .manifest
176  
-	$(RAKE) -s news_rdoc > $@+
177  
-	mv $@+ $@
178  
-
179  
-SINCE = 1.1.5
180  
-ChangeLog: LOG_VERSION = \
181  
-  $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
182  
-          echo $(GIT_VERSION) || git describe)
183  
-ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
184  
-ChangeLog: GIT-VERSION-FILE
185  
-	@echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
186  
-	@echo >> $@+
187  
-	git log $(log_range) | sed -e 's/^/    /' >> $@+
188  
-	mv $@+ $@
189  
-
190  
-news_atom := http://unicorn.bogomips.org/NEWS.atom.xml
191  
-cgit_atom := $(CGIT_URL)/atom/?h=master
192  
-atom = <link rel="alternate" title="Atom feed" href="$(1)" \
193  
-             type="application/atom+xml"/>
194  
-
195  
-# using rdoc 2.5.x+
196  
-doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
  173
+doc: .document $(ext)/unicorn_http.c man html .wrongdoc.yml
197 174
 	for i in $(man1_rdoc); do echo > $$i; done
198 175
 	find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
199  
-	rdoc --webcvs=$(CGIT_URL)/tree/%s \
200  
-	  -t "$(shell sed -ne '1s/^= //p' README)"
  176
+	$(RM) -r doc
  177
+	wrongdoc all
201 178
 	install -m644 COPYING doc/COPYING
202  
-	install -m644 $(shell grep '^[A-Z]' .document)  doc/
203  
-	$(MAKE) -C Documentation install-html install-man
  179
+	install -m644 $(shell grep '^[A-Z]' .document) doc/
204 180
 	install -m644 $(man1_paths) doc/
205  
-	cd doc && for i in $(base_bins); do \
206  
-	  $(RM) 1.html $${i}.1.html; \
207  
-	  sed -e '/"documentation">/r man1/'$$i'.1.html' \
208  
-		< $${i}_1.html > tmp && mv tmp $${i}_1.html; \
209  
-	  ln $${i}_1.html $${i}.1.html; \
210  
-	  done
211  
-	$(RUBY) -i -p -e \
212  
-	  '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
213  
-	  doc/ChangeLog.html
214  
-	$(RUBY) -i -p -e \
215  
-	  '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
216  
-	  doc/NEWS.html doc/README.html
217  
-	$(RAKE) -s news_atom OUT=doc/NEWS.atom.xml
218  
-	cd doc && ln README.html tmp && mv tmp index.html
  181
+	tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
219 182
 	$(RM) $(man1_rdoc)
220 183
 
221 184
 # publishes docs to http://unicorn.bogomips.org
222 185
 publish_doc:
223 186
 	-git set-file-times
224  
-	$(RM) -r doc ChangeLog NEWS
225  
-	$(MAKE) doc LOG_VERSION=$(shell git tag -l | tail -1)
226  
-	@awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' \
227  
-	 < NEWS > doc/LATEST
228  
-	find doc/images doc/js -type f | \
229  
-		TZ=UTC xargs touch -d '1970-01-01 00:00:00' doc/rdoc.css
  187
+	$(MAKE) doc
  188
+	find doc/images -type f | \
  189
+		TZ=UTC xargs touch -d '1970-01-01 00:00:02' doc/rdoc.css
230 190
 	$(MAKE) doc_gz
231  
-	tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
232 191
 	chmod 644 $$(find doc -type f)
233 192
 	$(RSYNC) -av doc/ unicorn.bogomips.org:/srv/unicorn/
234 193
 	git ls-files | xargs touch
@@ -275,10 +234,10 @@ release_changes := release_changes-$(VERSION)
275 234
 release-notes: $(release_notes)
276 235
 release-changes: $(release_changes)
277 236
 $(release_changes):
278  
-	$(RAKE) -s release_changes > $@+
  237
+	wrongdoc release_changes > $@+
279 238
 	$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
280 239
 $(release_notes):
281  
-	GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
  240
+	wrongdoc release_notes > $@+
282 241
 	$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
283 242
 
284 243
 # ensures we're actually on the tagged $(VERSION), only used for release
@@ -298,18 +257,18 @@ gem: $(pkggem)
298 257
 install-gem: $(pkggem)
299 258
 	gem install $(CURDIR)/$<
300 259
 
301  
-$(pkggem): manifest fix-perms
  260
+$(pkggem): .manifest fix-perms
302 261
 	gem build $(rfpackage).gemspec
303 262
 	mkdir -p pkg
304 263
 	mv $(@F) $@
305 264
 
306 265
 $(pkgtgz): distdir = $(basename $@)
307 266
 $(pkgtgz): HEAD = v$(VERSION)
308  
-$(pkgtgz): manifest fix-perms
  267
+$(pkgtgz): .manifest fix-perms
309 268
 	@test -n "$(distdir)"
310 269
 	$(RM) -r $(distdir)
311 270
 	mkdir -p $(distdir)
312  
-	tar cf - `cat .manifest` | (cd $(distdir) && tar xf -)
  271
+	tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
313 272
 	cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
314 273
 	mv $@+ $@
315 274
 
@@ -331,5 +290,5 @@ gem install-gem: GIT-VERSION-FILE
331 290
 	$(MAKE) $@ VERSION=$(GIT_VERSION)
332 291
 endif
333 292
 
334  
-.PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) manifest man
  293
+.PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) man
335 294
 .PHONY: test-install
112  Rakefile
... ...
@@ -1,121 +1,9 @@
1 1
 # -*- encoding: binary -*-
2 2
 autoload :Gem, 'rubygems'
3 3
 
4  
-# most tasks are in the GNUmakefile which offers better parallelism
5  
-
6  
-def old_summaries
7  
-  @old_summaries ||= File.readlines(".CHANGELOG.old").inject({}) do |hash, line|
8  
-    version, summary = line.split(/ - /, 2)
9  
-    hash[version] = summary
10  
-    hash
11  
-  end
12  
-end
13  
-
14  
-def tags
15  
-  timefmt = '%Y-%m-%dT%H:%M:%SZ'
16  
-  @tags ||= `git tag -l`.split(/\n/).map do |tag|
17  
-    next if tag == "v0.0.0"
18  
-    if %r{\Av[\d\.]+} =~ tag
19  
-      header, subject, body = `git cat-file tag #{tag}`.split(/\n\n/, 3)
20  
-      header = header.split(/\n/)
21  
-      tagger = header.grep(/\Atagger /).first
22  
-      body ||= "initial"
23  
-      time = Time.at(tagger.split(/ /)[-2].to_i).utc
24  
-      {
25  
-        :time => time.strftime(timefmt),
26  
-        :ruby_time => time,
27  
-        :tagger_name => %r{^tagger ([^<]+)}.match(tagger)[1].strip,
28  
-        :tagger_email => %r{<([^>]+)>}.match(tagger)[1].strip,
29  
-        :id => `git rev-parse refs/tags/#{tag}`.chomp!,
30  
-        :tag => tag,
31  
-        :subject => subject,
32  
-        :body => (old = old_summaries[tag]) ? "#{old}\n#{body}" : body,
33  
-      }
34  
-    end
35  
-  end.compact.sort { |a,b| b[:time] <=> a[:time] }
36  
-end
37  
-
38 4
 cgit_url = "http://git.bogomips.org/cgit/unicorn.git"
39 5
 git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/unicorn.git'
40 6
 
41  
-desc 'prints news as an Atom feed'
42  
-task :news_atom do
43  
-  require 'nokogiri'
44  
-  new_tags = tags[0,10]
45  
-  out = ENV["OUT"] ? File.open(ENV["OUT"], "w") : $stdout
46  
-  out.puts(Nokogiri::XML::Builder.new do
47  
-    feed :xmlns => "http://www.w3.org/2005/Atom" do
48  
-      id! "http://unicorn.bogomips.org/NEWS.atom.xml"
49  
-      title "Unicorn news"
50  
-      subtitle "Rack HTTP server for Unix and fast clients"
51  
-      link! :rel => 'alternate', :type => 'text/html',
52  
-            :href => 'http://unicorn.bogomips.org/NEWS.html'
53  
-      updated new_tags.first[:time]
54  
-      new_tags.each do |tag|
55  
-        entry do
56  
-          title tag[:subject]
57  
-          updated tag[:time]
58  
-          published tag[:time]
59  
-          author {
60  
-            name tag[:tagger_name]
61  
-            email tag[:tagger_email]
62  
-          }
63  
-          url = "#{cgit_url}/tag/?id=#{tag[:tag]}"
64  
-          link! :rel => "alternate", :type => "text/html", :href =>url
65  
-          id! url
66  
-          message_only = tag[:body].split(/\n.+\(\d+\):\n {6}/s).first.strip
67  
-          content({:type =>:text}, message_only)
68  
-          content(:type =>:xhtml) { pre tag[:body] }
69  
-        end
70  
-      end
71  
-    end
72  
-  end.to_xml)
73  
-  if out.respond_to?(:path) && new_tags[0]
74  
-    path = out.path
75  
-    out.close
76  
-    time = new_tags[0][:ruby_time]
77  
-    File.utime(time, time, path)
78  
-  end
79  
-end
80  
-
81  
-desc 'prints RDoc-formatted news'
82  
-task :news_rdoc do
83  
-  tags.each do |tag|
84  
-    time = tag[:time].tr!('T', ' ').gsub!(/:\d\dZ/, ' UTC')
85  
-    puts "=== #{tag[:subject]} / #{time}"
86  
-    puts ""
87  
-
88  
-    body = tag[:body]
89  
-    puts tag[:body].gsub(/^/sm, "  ").gsub(/[ \t]+$/sm, "")
90  
-    puts ""
91  
-  end
92  
-end
93  
-
94  
-desc "print release changelog for Rubyforge"
95  
-task :release_changes do
96  
-  version = ENV['VERSION'] or abort "VERSION= needed"
97  
-  version = "v#{version}"
98  
-  vtags = tags.map { |tag| tag[:tag] =~ /\Av/ and tag[:tag] }.sort
99  
-  prev = vtags[vtags.index(version) - 1]
100  
-  system('git', 'diff', '--stat', prev, version) or abort $?
101  
-  puts ""
102  
-  system('git', 'log', "#{prev}..#{version}") or abort $?
103  
-end
104  
-
105  
-desc "print release notes for Rubyforge"
106  
-task :release_notes do
107  
-  spec = Gem::Specification.load('unicorn.gemspec')
108  
-  puts spec.description.strip
109  
-  puts ""
110  
-  puts "* #{spec.homepage}"
111  
-  puts "* #{spec.email}"
112  
-  puts "* #{git_url}"
113  
-
114  
-  _, _, body = `git cat-file tag v#{spec.version}`.split(/\n\n/, 3)
115  
-  print "\nChanges:\n\n"
116  
-  puts body
117  
-end
118  
-
119 7
 desc "post to RAA"
120 8
 task :raa_update do
121 9
   require 'net/http'
33  unicorn.gemspec
... ...
@@ -1,7 +1,9 @@
1 1
 # -*- encoding: binary -*-
2  
-
3 2
 ENV["VERSION"] or abort "VERSION= must be specified"
4 3
 manifest = File.readlines('.manifest').map! { |x| x.chomp! }
  4
+require 'wrongdoc'
  5
+extend Wrongdoc::Gemspec
  6
+name, summary, title = readme_metadata
5 7
 
6 8
 # don't bother with tests that fork, not worth our time to get working
7 9
 # with `gem check -t` ... (of course we care for them when testing with
@@ -12,35 +14,19 @@ end.compact
12 14
 
13 15
 Gem::Specification.new do |s|
14 16
   s.name = %q{unicorn}
15  
-  s.version = ENV["VERSION"]
16  
-
17  
-  s.authors = ["Unicorn hackers"]
  17
+  s.version = ENV["VERSION"].dup
  18
+  s.authors = ["#{name} hackers"]
18 19
   s.date = Time.now.utc.strftime('%Y-%m-%d')
19  
-  s.description = File.read("README").split(/\n\n/)[1].delete('\\')
  20
+  s.description = readme_description
20 21
   s.email = %q{mongrel-unicorn@rubyforge.org}
21 22
   s.executables = %w(unicorn unicorn_rails)
22 23
   s.extensions = %w(ext/unicorn_http/extconf.rb)
23  
-
24  
-  s.extra_rdoc_files = File.readlines('.document').map! do |x|
25  
-    x.chomp!
26  
-    if File.directory?(x)
27  
-      manifest.grep(%r{\A#{x}/})
28  
-    elsif File.file?(x)
29  
-      x
30  
-    else
31  
-      nil
32  
-    end
33  
-  end.flatten.compact
34  
-
  24
+  s.extra_rdoc_files = extra_rdoc_files(manifest)
35 25
   s.files = manifest
36  
-  s.homepage = %q{http://unicorn.bogomips.org/}
37  
-
38  
-  summary = %q{Rack HTTP server for fast clients and Unix}
39  
-  s.rdoc_options = [ "-t", "Unicorn: #{summary}" ]
  26
+  s.homepage = Wrongdoc.config[:rdoc_url]
  27
+  s.rdoc_options = rdoc_options
40 28
   s.require_paths = %w(lib ext)
41 29
   s.rubyforge_project = %q{mongrel}
42  
-  s.summary = summary
43  
-
44 30
   s.test_files = test_files
45 31
 
46 32
   # for people that are absolutely stuck on Rails 2.3.2 and can't
@@ -51,6 +37,7 @@ Gem::Specification.new do |s|
51 37
   s.add_dependency(%q<kgio>, '~> 2.0.0')
52 38
 
53 39
   s.add_development_dependency('isolate', '~> 3.0.0')
  40
+  s.add_development_dependency('wrongdoc', '~> 1.0.1')
54 41
 
55 42
   # s.licenses = %w(GPLv2 Ruby) # licenses= method is not in older RubyGems
56 43
 end

0 notes on commit f62ef19

Please sign in to comment.
Something went wrong with that request. Please try again.