docter 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +25 -4
- data/DISCLAIMER +7 -0
- data/NOTICE +43 -0
- data/Rakefile +45 -93
- data/lib/docter.rb +32 -17
- data/lib/docter/collection.rb +26 -14
- data/lib/docter/common.rb +24 -5
- data/lib/docter/page.rb +51 -21
- data/lib/docter/rake.rb +16 -0
- data/lib/docter/server.rb +21 -1
- data/lib/docter/template.rb +45 -29
- data/lib/docter/ultraviolet.rb +16 -0
- metadata +29 -16
data/CHANGELOG
CHANGED
@@ -1,14 +1,35 @@
|
|
1
|
+
1.1.3 (2008-04-15)
|
2
|
+
* Changed: Now using Syntax by default for syntax highlighting, which works
|
3
|
+
equally well on JRuby.
|
4
|
+
* Changed: Fixed copying of resources with nested directories.
|
5
|
+
* Removed: Dependency on Facets.
|
6
|
+
|
7
|
+
1.1.2 (2007-01-25)
|
8
|
+
* Changed: list_links now limits itself so HTTP URLs (no mailto:, FTP).
|
9
|
+
* Changed: Upgraded to HAML 1.8.
|
10
|
+
* Fixed: list_links returns URLs in alphabetical order (of title)
|
11
|
+
capitializing first letter of title.
|
12
|
+
* Fixed: list_links no longer returns URLs that have no title.
|
13
|
+
* Fixed: Generated IDs for headers conform to HTML spec (i.e. a-z, 0-9,
|
14
|
+
hyphen, underscore, colon and period).
|
15
|
+
* Fixed: Empty ToC no longer included in HTML.
|
16
|
+
|
1
17
|
1.1.1 (2007-01-03)
|
2
18
|
* Fixed: Upgraded to Facets 2.2.1 to prevent conflict with Buildr.
|
3
19
|
|
4
20
|
1.1.0 (2007-01-03)
|
5
21
|
* Changed: Now using YAML for nested ToC.
|
6
|
-
* Fixed: Sleek upload with changelog for each release courtesy of Anatol
|
22
|
+
* Fixed: Sleek upload with changelog for each release courtesy of Anatol
|
23
|
+
Pomozov.
|
7
24
|
|
8
25
|
1.0.1 (2007-06-06)
|
9
|
-
* Added: renumber_footnotes to template for handling footnote numbering when
|
10
|
-
|
11
|
-
* Changed:
|
26
|
+
* Added: renumber_footnotes to template for handling footnote numbering when
|
27
|
+
creating a single page.
|
28
|
+
* Changed: Ultraviolet no longer used as default syntax highlighting, must
|
29
|
+
require separately.
|
30
|
+
* Changed: footnote_links is now list_links and the new method eliminates
|
31
|
+
duplicates (based on URL), sorts alphabetically (the text component) and
|
32
|
+
capitalizes the text description.
|
12
33
|
|
13
34
|
1.0.0 (2007-06-03)
|
14
35
|
* First release of working code.
|
data/DISCLAIMER
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Apache Buildr is an effort undergoing incubation at The Apache Software
|
2
|
+
Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of
|
3
|
+
all newly accepted projects until a further review indicates that the
|
4
|
+
infrastructure, communications, and decision making process have stabilized in
|
5
|
+
a manner consistent with other successful ASF projects. While incubation status
|
6
|
+
is not necessarily a reflection of the completeness or stability of the code,
|
7
|
+
it does indicate that the project has yet to be fully endorsed by the ASF.
|
data/NOTICE
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
=========================================================================
|
2
|
+
== NOTICE file for use with the Apache License, Version 2.0, ==
|
3
|
+
== in this case for the Apache Buildr distribution. ==
|
4
|
+
=========================================================================
|
5
|
+
|
6
|
+
Apache Docter (part of Apache Buildr)
|
7
|
+
This product includes software developed at
|
8
|
+
The Apache Software Foundation (http://www.apache.org/).
|
9
|
+
|
10
|
+
COPYRIGHT NOTICES
|
11
|
+
-----------------
|
12
|
+
Copyright 2007 Intalio
|
13
|
+
|
14
|
+
This product includes software developed by Intalio
|
15
|
+
http://www.intalio.com
|
16
|
+
|
17
|
+
|
18
|
+
THIRD-PARTY DEPENDENCIES
|
19
|
+
------------------------
|
20
|
+
Even though those dependencies aren't shipped with Docter, Docter needs
|
21
|
+
the third-party libraries listed below to run. According licenses are
|
22
|
+
bundled under the etc/legal directory (when available).
|
23
|
+
|
24
|
+
* HAML - http://haml.hamptoncatlin.com/
|
25
|
+
Licensed under MIT
|
26
|
+
Copyright (c) 2006-2007 Hampton Catlin
|
27
|
+
|
28
|
+
* highline - http://rubyforge.org/projects/highline
|
29
|
+
Licensed under the Ruby License
|
30
|
+
Copyright 2005 Gray Productions
|
31
|
+
Copyright 2007 Jeremy Hinegardner
|
32
|
+
|
33
|
+
* Rake - http://rubyforge.org/projects/rake
|
34
|
+
Licensed under MIT/X Consortium
|
35
|
+
Copyright 2003, 2004 by Jim Weirich
|
36
|
+
|
37
|
+
* RedCloth - http://whytheluckystiff.net/ruby/redcloth/
|
38
|
+
Licensed under BSD
|
39
|
+
Copyright 2004 why the lucky stiff (and his puppet organizations.)
|
40
|
+
|
41
|
+
* Syntax -- http://syntax.rubyforge.org/
|
42
|
+
Licensed under BSD
|
43
|
+
Copyright 2005 Jamis Buck
|
data/Rakefile
CHANGED
@@ -1,102 +1,54 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
6
15
|
|
7
16
|
|
8
17
|
# Gem specification comes first, other tasks rely on it.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
# Packaging and local installation.
|
34
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
35
|
-
pkg.need_tar = true
|
36
|
-
pkg.need_zip = true
|
37
|
-
end
|
38
|
-
|
39
|
-
desc 'Install the package locally'
|
40
|
-
task :install=>:package do |task|
|
41
|
-
system 'gem', 'install', "pkg/#{spec.name}-#{spec.version}.gem"
|
42
|
-
end
|
43
|
-
|
44
|
-
desc 'Uninstall previously installed packaged'
|
45
|
-
task :uninstall do |task|
|
46
|
-
system 'gem', 'uninstall', spec.name, '-v', spec.version.to_s
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
desc 'Generate RDoc documentation'
|
51
|
-
rdoc = Rake::RDocTask.new(:rdoc) do |rdoc|
|
52
|
-
rdoc.rdoc_dir = 'rdoc'
|
53
|
-
rdoc.title = spec.name
|
54
|
-
rdoc.options = spec.rdoc_options
|
55
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
-
rdoc.rdoc_files.include spec.extra_rdoc_files
|
57
|
-
end
|
58
|
-
|
59
|
-
task('clobber') { rm_rf [rdoc.rdoc_dir.to_s] }
|
60
|
-
|
61
|
-
|
62
|
-
# Commit to SVN, upload and do the release cycle.
|
63
|
-
namespace :svn do
|
64
|
-
task :clean? do |task|
|
65
|
-
status = `svn status`.reject { |line| line =~ /\s(pkg|html)$/ }
|
66
|
-
fail "Cannot release unless all local changes are in SVN:\n#{status}" unless status.empty?
|
67
|
-
end
|
68
|
-
|
69
|
-
task :tag do |task|
|
70
|
-
cur_url = `svn info`.scan(/URL: (.*)/)[0][0]
|
71
|
-
new_url = cur_url.sub(/trunk$/, "tags/#{spec.version.to_s}")
|
72
|
-
system 'svn', 'remove', new_url, '-m', 'Removing old copy' rescue nil
|
73
|
-
system 'svn', 'copy', cur_url, new_url, '-m', "Release #{spec.version.to_s}"
|
18
|
+
def spec
|
19
|
+
Gem::Specification.new do |spec|
|
20
|
+
spec.name = 'docter'
|
21
|
+
spec.version = File.read(__FILE__.pathmap('%d/lib/docter.rb')).scan(/VERSION\s*=\s*(['"])(.*)\1/)[0][1]
|
22
|
+
spec.author = 'Apache Buildr'
|
23
|
+
spec.email = 'buildr-user@incubator.apache.org'
|
24
|
+
spec.homepage = 'http://incubator.apache.org/buildr/'
|
25
|
+
spec.summary = 'We has docs'
|
26
|
+
spec.files = FileList['lib/**/*', 'README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER',
|
27
|
+
'Rakefile'].collect
|
28
|
+
spec.require_path = 'lib'
|
29
|
+
spec.has_rdoc = true
|
30
|
+
spec.extra_rdoc_files = ['README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER']
|
31
|
+
spec.rdoc_options << '--title' << "Docter -- #{spec.summary}" <<
|
32
|
+
'--main' << 'README' << '--line-numbers' << '--inline-source' << '-p' <<
|
33
|
+
'--webcvs' << 'http://svn.apache.org/repos/asf/incubator/buildr/docter/trunk/'
|
34
|
+
spec.rubyforge_project = 'buildr'
|
35
|
+
|
36
|
+
# Tested against these dependencies.
|
37
|
+
spec.add_dependency 'RedCloth', '~> 3.0'
|
38
|
+
spec.add_dependency 'haml', '~> 1.8'
|
39
|
+
spec.add_dependency 'mongrel', '~> 1.1'
|
40
|
+
spec.add_dependency 'syntax', '~> 1.0'
|
41
|
+
spec.add_dependency 'rake', '~> 0.8'
|
74
42
|
end
|
75
43
|
end
|
76
44
|
|
77
|
-
namespace :upload do
|
78
|
-
task :packages=>['rake:package'] do |task|
|
79
|
-
# Read the changes for this release.
|
80
|
-
pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
|
81
|
-
changelog = File.read(__FILE__.pathmap('%d/CHANGELOG'))
|
82
|
-
changes = changelog.scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
|
83
|
-
current = changes[spec.version.to_s]
|
84
|
-
if !current && spec.version.to_s =~ /\.0$/
|
85
|
-
current = changes[spec.version.to_s.split('.')[0..-2].join('.')]
|
86
|
-
end
|
87
|
-
fail "No changeset found for version #{spec.version}" unless current
|
88
45
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rubyforge.add_release spec.rubyforge_project.downcase, spec.name.downcase, spec.version, *files
|
96
|
-
rm '.changes'
|
97
|
-
puts "Release #{spec.version} uploaded"
|
46
|
+
namespace 'release' do
|
47
|
+
|
48
|
+
# License requirement.
|
49
|
+
task 'check'=>'apache:license'
|
50
|
+
task 'make' do
|
51
|
+
task('release:rubyforge').invoke
|
98
52
|
end
|
99
|
-
end
|
100
53
|
|
101
|
-
|
102
|
-
task :release=>[ 'clobber', 'svn:clean?', 'upload:packages' ]
|
54
|
+
end
|
data/lib/docter.rb
CHANGED
@@ -1,28 +1,43 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
6
16
|
|
7
17
|
module Docter
|
8
|
-
VERSION = '1.1.
|
18
|
+
VERSION = '1.1.3'.freeze
|
9
19
|
end
|
10
20
|
|
11
|
-
$LOAD_PATH.unshift __DIR__
|
12
21
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
22
|
+
# Ruby 1.9 conveniences.
|
23
|
+
module Kernel #:nodoc:
|
24
|
+
def tap
|
25
|
+
yield self if block_given?
|
26
|
+
self
|
27
|
+
end unless method_defined?('tap')
|
28
|
+
end
|
29
|
+
|
30
|
+
class Symbol #:nodoc:
|
31
|
+
def to_proc
|
32
|
+
Proc.new{|*args| args.shift.__send__(self, *args)}
|
33
|
+
end unless method_defined?('to_proc')
|
21
34
|
end
|
22
35
|
|
36
|
+
|
23
37
|
require 'docter/common.rb'
|
24
38
|
require 'docter/page.rb'
|
25
39
|
require 'docter/template.rb'
|
26
40
|
require 'docter/collection.rb'
|
27
|
-
require 'docter/server.rb'
|
28
|
-
require 'docter/rake.rb'
|
41
|
+
require 'docter/server.rb'
|
42
|
+
require 'docter/rake.rb'
|
43
|
+
require 'docter/ultraviolet.rb' if defined?(Uv)
|
data/lib/docter/collection.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'redcloth'
|
18
|
+
|
19
|
+
|
1
20
|
module Docter
|
2
21
|
|
3
22
|
class Collection
|
@@ -30,21 +49,14 @@ module Docter
|
|
30
49
|
@toc = ToC.from_yaml(yaml, @collection)
|
31
50
|
end
|
32
51
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
52
|
+
def create_from_textile(text, options)
|
53
|
+
html = RedCloth.new(erb_this(text, binding), [:no_span_caps]).to_html(:textile)
|
54
|
+
create_from_html html, options
|
55
|
+
end
|
38
56
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
43
|
-
else
|
44
|
-
def create_from_textile(text, options)
|
45
|
-
fail "You need to install RedCloth first:\n gem install RedCloth"
|
46
|
-
end
|
47
|
-
alias :create_from_markup :create_from_textile
|
57
|
+
def create_from_markup(text, options)
|
58
|
+
html = RedCloth.new(erb_this(text, binding), [:no_span_caps]).to_html(:markup)
|
59
|
+
create_from_html html, options
|
48
60
|
end
|
49
61
|
|
50
62
|
def create_from_html(html, options)
|
data/lib/docter/common.rb
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'erb'
|
18
|
+
|
19
|
+
|
1
20
|
module Docter
|
2
21
|
|
3
22
|
module HTML
|
@@ -10,15 +29,15 @@ module Docter
|
|
10
29
|
# Returns the inner text from some HTML text, effectively stripping the tags, normalizing whitespaces
|
11
30
|
# and stripping leading/trailing spaces.
|
12
31
|
def inner_text_from(html)
|
13
|
-
html.gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m,
|
32
|
+
html.gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip.gsub(/\s+/m, ' ')
|
14
33
|
end
|
15
34
|
|
16
35
|
def regexp_element(name)
|
17
|
-
|
36
|
+
/<(#{name})(?:>|\s+(.*?)>)(.*?)<\/\1\s*>/mi
|
18
37
|
end
|
19
38
|
|
20
39
|
def regexp_attribute(name)
|
21
|
-
|
40
|
+
/(#{name})=([\"'])(.*?)\2/mi
|
22
41
|
end
|
23
42
|
|
24
43
|
end
|
@@ -271,7 +290,7 @@ module Docter
|
|
271
290
|
options = Hash === args.last ? args.pop.clone : {}
|
272
291
|
args.each { |arg| options[arg.to_sym] = true }
|
273
292
|
cls = %{ class="#{options[:class]}"} if options[:class]
|
274
|
-
%{<ol #{cls}>#{map { |entry| entry.to_html(options) }}</ol>}
|
293
|
+
%{<ol #{cls}>#{map { |entry| entry.to_html(options) }}</ol>} unless empty?
|
275
294
|
end
|
276
295
|
|
277
296
|
protected
|
@@ -335,7 +354,7 @@ module Docter
|
|
335
354
|
end
|
336
355
|
end
|
337
356
|
if url
|
338
|
-
%{<li><a href=
|
357
|
+
%{<li><a href='#{url}'>#{title}</a>#{nested}</li>}
|
339
358
|
else
|
340
359
|
%{<li>#{title}#{nested}</li>}
|
341
360
|
end
|
data/lib/docter/page.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'cgi'
|
18
|
+
require 'redcloth'
|
19
|
+
require 'syntax/convertors/html'
|
20
|
+
|
21
|
+
|
1
22
|
module Docter
|
2
23
|
|
3
24
|
# A single documentation page. Has title, content and ToC.
|
@@ -155,26 +176,20 @@ module Docter
|
|
155
176
|
|
156
177
|
private
|
157
178
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
%{<notextile><pre class='#{spec.split(',').join(' ')}'>#{CGI.escapeHTML(code)}</pre></notextile>}
|
170
|
-
end
|
171
|
-
# Create the HTML.
|
172
|
-
RedCloth.new(text, [:no_span_caps]).to_html(format)
|
173
|
-
end
|
174
|
-
else
|
175
|
-
def use_redcloth(format, text, options)
|
176
|
-
fail "You need to install RedCloth first:\n gem install RedCloth"
|
179
|
+
# :call-seq:
|
180
|
+
# use_redcloth(format, text, options)
|
181
|
+
#
|
182
|
+
# Format may be :textile or :markdown. Runs erb_this on the text first to apply ERB code,
|
183
|
+
# processes code sections ({{{ ... }}}), and converts the Textile/Markdown text to HTML.
|
184
|
+
def use_redcloth(format, text, options)
|
185
|
+
text = erb_this(text)
|
186
|
+
# Process {{{ ... }}} code sections into pre tags.
|
187
|
+
text = text.gsub(/^\{\{\{([^\n]*)\n(.*?)\n\}\}\}/m) do
|
188
|
+
code, spec = $2, $1.scan(/^!(.*?)$/).to_s.strip
|
189
|
+
%{<notextile><pre class='#{spec.split(',').join(' ')}'>#{CGI.escapeHTML(code)}</pre></notextile>}
|
177
190
|
end
|
191
|
+
# Create the HTML.
|
192
|
+
RedCloth.new(text, [:no_span_caps]).to_html(format)
|
178
193
|
end
|
179
194
|
|
180
195
|
# :call-seq:
|
@@ -202,8 +217,8 @@ module Docter
|
|
202
217
|
tag, attributes, text = $1.downcase, $2.to_s, inner_text_from($3)
|
203
218
|
# Make sure all H2/H3 headers have a usable ID, create once if necessary.
|
204
219
|
id = CGI.unescape($3) if attributes[regexp_attribute('id')]
|
205
|
-
if id.to_s.
|
206
|
-
id = CGI.unescapeHTML(text.downcase.gsub(
|
220
|
+
if id.to_s.strip.empty?
|
221
|
+
id = CGI.unescapeHTML(text.downcase).gsub(/\s+/, '_').gsub(/[^A-Za-z0-9\-_:.]/, '')
|
207
222
|
header = %{<#{tag} #{attributes} id='#{id}'>#{text}</#{tag}>}
|
208
223
|
end
|
209
224
|
if tag == 'h2'
|
@@ -285,4 +300,19 @@ module Docter
|
|
285
300
|
|
286
301
|
end
|
287
302
|
|
303
|
+
|
304
|
+
# Syntax highlighting filter.
|
305
|
+
filter_for :syntax do |html|
|
306
|
+
html.gsub(HTML.regexp_element('pre')) do |pre|
|
307
|
+
attributes, code = $2, $3
|
308
|
+
if attributes[HTML.regexp_attribute('class')]
|
309
|
+
classes = $3.split(/\s+/)
|
310
|
+
lang = classes.first
|
311
|
+
end
|
312
|
+
unescaped = CGI.unescapeHTML(code)
|
313
|
+
highlight = Syntax::Convertors::HTML.for_syntax(lang).convert(unescaped, false)
|
314
|
+
%{<pre class="#{lang}">#{highlight}</pre>}
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
288
318
|
end
|
data/lib/docter/rake.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
1
17
|
module Docter
|
2
18
|
module Rake
|
3
19
|
|
data/lib/docter/server.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'mongrel'
|
18
|
+
require 'cgi'
|
19
|
+
|
20
|
+
|
1
21
|
module Docter
|
2
22
|
|
3
23
|
class MongrelHandler < Mongrel::HttpHandler
|
@@ -52,7 +72,7 @@ module Docter
|
|
52
72
|
rescue Exception=>error
|
53
73
|
response.start(500) do |head, out|
|
54
74
|
head['Content-Type'] = 'text/plain'
|
55
|
-
error = ["#{error.class}: #{error}", error.backtrace.join(
|
75
|
+
error = ["#{error.class}: #{error}", error.backtrace.join("\n")]
|
56
76
|
out.puts *error
|
57
77
|
puts *error
|
58
78
|
end
|
data/lib/docter/template.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'haml'
|
18
|
+
require 'erb'
|
19
|
+
|
20
|
+
|
1
21
|
module Docter
|
2
22
|
|
3
23
|
# A template for formatting pages. The template is parsed once and processed using each Page to
|
@@ -17,10 +37,11 @@ module Docter
|
|
17
37
|
@links ||= []
|
18
38
|
content.gsub(regexp_element('a')) do |link|
|
19
39
|
url = $3 if link =~ regexp_attribute('href')
|
20
|
-
|
40
|
+
text = inner_text_from(link)
|
41
|
+
if url =~ /^\w+:/ && url != text
|
21
42
|
unless index = @links.index(url)
|
22
43
|
index = @links.size
|
23
|
-
@links << [url,
|
44
|
+
@links << [url, text]
|
24
45
|
end
|
25
46
|
mark ? "#{link}<sup>[#{index + 1}]</sup>" : link
|
26
47
|
else
|
@@ -31,9 +52,10 @@ module Docter
|
|
31
52
|
|
32
53
|
def list_links(cls = nil)
|
33
54
|
# Remove duplicate links (same URL), sort by text and convert into DT/DD pairs.
|
34
|
-
links = @links.
|
35
|
-
|
36
|
-
|
55
|
+
links = @links.select { |url, text| url =~ /^http(s?):/ }.
|
56
|
+
inject({}) { |hash, link| hash[link.first] ||= link.last ; hash }.
|
57
|
+
sort { |a,b| a.last.downcase <=> b.last.downcase }.
|
58
|
+
map { |url, text| %{<dt>#{text.gsub(/^\w/) { |a| a.upcase }}</dt><dd><a href='#{url}'>#{url}</a></dd>} }
|
37
59
|
%{<dl class='#{cls}'>#{links.join}</dl>}
|
38
60
|
end
|
39
61
|
|
@@ -118,13 +140,13 @@ module Docter
|
|
118
140
|
# map.find('images/logo.png') => 'images/logo.png'
|
119
141
|
# map.find('fancy.css') => 'css/fancy.css'
|
120
142
|
def find(path)
|
121
|
-
@sources.inject(nil) do |found,
|
143
|
+
@sources.inject(nil) do |found, source|
|
122
144
|
break found if found
|
123
|
-
if File.directory?(
|
124
|
-
base = File.dirname(
|
125
|
-
|
145
|
+
if File.directory?(source)
|
146
|
+
base = File.join(File.dirname(source), '')
|
147
|
+
Dir.glob(File.join(source, "/**/*")).find { |file| file.sub(base, '') == path }
|
126
148
|
else
|
127
|
-
|
149
|
+
source if File.basename(source) == path
|
128
150
|
end
|
129
151
|
end
|
130
152
|
end
|
@@ -135,17 +157,17 @@ module Docter
|
|
135
157
|
# Copy resource files to the destination directory.
|
136
158
|
def copy_resources(to_dir)
|
137
159
|
mkpath to_dir
|
138
|
-
@sources.each do |
|
139
|
-
if File.directory?(
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
mkpath File.dirname(target)
|
144
|
-
cp
|
160
|
+
@sources.each do |src|
|
161
|
+
if File.directory?(src)
|
162
|
+
target = File.join(to_dir, File.basename(src))
|
163
|
+
mkpath target
|
164
|
+
FileList["#{src}/**/*"].reject { |path| File.directory?(path) }.each do |path|
|
165
|
+
mkpath File.dirname(path).gsub(/^#{src}/, target)
|
166
|
+
cp path, path.gsub(/^#{src}/, target)
|
145
167
|
end
|
146
168
|
else
|
147
|
-
cp
|
148
|
-
end
|
169
|
+
cp src, to_dir
|
170
|
+
end
|
149
171
|
end
|
150
172
|
touch to_dir # For Rake dependency management.
|
151
173
|
end
|
@@ -161,16 +183,10 @@ module Docter
|
|
161
183
|
|
162
184
|
protected
|
163
185
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
@process = lambda { |context| template.render(context) }
|
169
|
-
end
|
170
|
-
else
|
171
|
-
def create_from_haml(content, options)
|
172
|
-
fail "You need to install HAML first:\n gem install haml"
|
173
|
-
end
|
186
|
+
def create_from_haml(content, options)
|
187
|
+
@options = options
|
188
|
+
template = Haml::Engine.new(content, :filename=>@filename)
|
189
|
+
@process = lambda { |context| template.render(context) }
|
174
190
|
end
|
175
191
|
|
176
192
|
def create_from_erb(content, options)
|
data/lib/docter/ultraviolet.rb
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
1
17
|
require 'uv' # gem install ultraviolet
|
2
18
|
|
3
19
|
module Docter
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Apache Buildr
|
@@ -9,44 +9,53 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-04-15 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: RedCloth
|
17
17
|
version_requirement:
|
18
18
|
version_requirements: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: "
|
22
|
+
version: "3.0"
|
23
23
|
version:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
|
-
name:
|
25
|
+
name: haml
|
26
26
|
version_requirement:
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
28
|
requirements:
|
29
29
|
- - ~>
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version: "
|
31
|
+
version: "1.8"
|
32
32
|
version:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: mongrel
|
35
35
|
version_requirement:
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: "1.
|
40
|
+
version: "1.1"
|
41
41
|
version:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: syntax
|
44
44
|
version_requirement:
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ~>
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: "1.
|
49
|
+
version: "1.0"
|
50
|
+
version:
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rake
|
53
|
+
version_requirement:
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0.8"
|
50
59
|
version:
|
51
60
|
description:
|
52
61
|
email: buildr-user@incubator.apache.org
|
@@ -58,19 +67,23 @@ extra_rdoc_files:
|
|
58
67
|
- README
|
59
68
|
- CHANGELOG
|
60
69
|
- LICENSE
|
70
|
+
- NOTICE
|
71
|
+
- DISCLAIMER
|
61
72
|
files:
|
62
73
|
- lib/docter
|
63
|
-
- lib/docter/server.rb
|
64
|
-
- lib/docter/template.rb
|
65
74
|
- lib/docter/collection.rb
|
75
|
+
- lib/docter/common.rb
|
76
|
+
- lib/docter/page.rb
|
66
77
|
- lib/docter/rake.rb
|
78
|
+
- lib/docter/server.rb
|
79
|
+
- lib/docter/template.rb
|
67
80
|
- lib/docter/ultraviolet.rb
|
68
|
-
- lib/docter/page.rb
|
69
|
-
- lib/docter/common.rb
|
70
81
|
- lib/docter.rb
|
71
|
-
- CHANGELOG
|
72
82
|
- README
|
83
|
+
- CHANGELOG
|
73
84
|
- LICENSE
|
85
|
+
- NOTICE
|
86
|
+
- DISCLAIMER
|
74
87
|
- Rakefile
|
75
88
|
has_rdoc: true
|
76
89
|
homepage: http://incubator.apache.org/buildr/
|
@@ -102,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
115
|
requirements: []
|
103
116
|
|
104
117
|
rubyforge_project: buildr
|
105
|
-
rubygems_version: 1.
|
118
|
+
rubygems_version: 1.1.1
|
106
119
|
signing_key:
|
107
120
|
specification_version: 2
|
108
121
|
summary: We has docs
|