brianjlandau-sdoc-helpers 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +51 -0
- data/Rakefile +20 -0
- data/lib/rake/sdoctask.rb +23 -0
- data/lib/sdoc_helpers.rb +4 -0
- data/lib/sdoc_helpers/markdown.rb +56 -0
- data/lib/sdoc_helpers/pages.rb +30 -0
- data/lib/sdoc_helpers/version.rb +3 -0
- metadata +62 -0
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
sdoc-helpers
|
2
|
+
============
|
3
|
+
|
4
|
+
Some Rake tasks and hacks to let me easily generate documentation like
|
5
|
+
that found at <http://defunkt.github.com/mustache/>.
|
6
|
+
|
7
|
+
After installing it, put this in your Rakefile:
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'sdoc_helpers'
|
11
|
+
Rake::SDocTask.new do |rdoc|
|
12
|
+
rdoc.title = "My Library Documentation"
|
13
|
+
end
|
14
|
+
rescue LoadError
|
15
|
+
puts "sdoc support not enabled. Please gem install sdoc-helpers."
|
16
|
+
end
|
17
|
+
|
18
|
+
Now (with a clean index) run `rake pages:init` to create and publish
|
19
|
+
your `gh-pages` branch.
|
20
|
+
|
21
|
+
It'll drop you back on master when it's done. Now in the future just
|
22
|
+
run `rake pages` to publish sdoc documentation to your `gh-pages`
|
23
|
+
branch.
|
24
|
+
|
25
|
+
Make sure you don't already have a `docs/` directory. If you do, this
|
26
|
+
won't work.
|
27
|
+
|
28
|
+
If you README (or any files) end in `md` or `markdown` they'll get
|
29
|
+
parsed by `RDiscount` and displayed as Markdown. This gives you a
|
30
|
+
nicely formatted README on GitHub as well as in your sdoc.
|
31
|
+
|
32
|
+
Enjoy.
|
33
|
+
|
34
|
+
|
35
|
+
Dependencies
|
36
|
+
------------
|
37
|
+
|
38
|
+
* rdiscount
|
39
|
+
* sdoc
|
40
|
+
|
41
|
+
|
42
|
+
Installation
|
43
|
+
------------
|
44
|
+
|
45
|
+
gem install sdoc-helpers
|
46
|
+
|
47
|
+
|
48
|
+
Author
|
49
|
+
------
|
50
|
+
|
51
|
+
Chris Wanstrath // chris@ozmm.org
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
|
5
|
+
require 'sdoc_helpers/version'
|
6
|
+
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = "brianjlandau-sdoc-helpers"
|
9
|
+
gemspec.summary = "Simple helpers to make using sdoc easier."
|
10
|
+
gemspec.description = "Simple helpers to make using sdoc easier."
|
11
|
+
gemspec.email = "chris@ozmm.org"
|
12
|
+
gemspec.homepage = "http://github.com/brianjlandau/sdoc-helpers"
|
13
|
+
gemspec.authors = ["Chris Wanstrath", "Brian Landau"]
|
14
|
+
gemspec.version = SDocHelpers::Version.to_s
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler not available."
|
19
|
+
puts "Install it with: gem install jeweler"
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake/rdoctask'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
# Just a customized version of the normal RDoc task for generating SDocs.
|
5
|
+
class SDocTask < RDocTask
|
6
|
+
def initialize
|
7
|
+
@name = :rdoc
|
8
|
+
@rdoc_files = Rake::FileList.new
|
9
|
+
@rdoc_files.include('README*')
|
10
|
+
@rdoc_files.include('LICENSE*')
|
11
|
+
@rdoc_files.include('lib/**/*.rb')
|
12
|
+
@rdoc_dir = 'docs'
|
13
|
+
@main = Dir['README*'].first
|
14
|
+
@title = nil
|
15
|
+
@template = 'direct'
|
16
|
+
@external = false
|
17
|
+
@inline_source = true
|
18
|
+
@options = ['--fmt', 'shtml']
|
19
|
+
yield self if block_given?
|
20
|
+
define
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/sdoc_helpers.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module SDocHelpers
|
4
|
+
module MarkdownFiles
|
5
|
+
def description
|
6
|
+
return super unless full_name =~ /\.(md|markdown)$/
|
7
|
+
# assuming your path is ROOT/html or ROOT/doc
|
8
|
+
path = Dir.pwd + '/../' + full_name
|
9
|
+
Markdown.new(gfm(File.read(path))).to_html + open_links_in_new_window
|
10
|
+
end
|
11
|
+
|
12
|
+
def open_links_in_new_window
|
13
|
+
<<-html
|
14
|
+
<script type="text/javascript">$(function() {
|
15
|
+
$('a').each(function() { $(this).attr('target', '_blank') })
|
16
|
+
})</script>
|
17
|
+
html
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def gfm(text)
|
23
|
+
# Extract pre blocks
|
24
|
+
extractions = {}
|
25
|
+
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
|
26
|
+
md5 = Digest::MD5.hexdigest(match)
|
27
|
+
extractions[md5] = match
|
28
|
+
"{gfm-extraction-#{md5}}"
|
29
|
+
end
|
30
|
+
|
31
|
+
# prevent foo_bar_baz from ending up with an italic word in the middle
|
32
|
+
text.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x|
|
33
|
+
x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__'
|
34
|
+
end
|
35
|
+
|
36
|
+
# in very clear cases, let newlines become <br /> tags
|
37
|
+
text.gsub!(/(\A|^$\n)(^\w[^\n]*\n)(^\w[^\n]*$)+/m) do |x|
|
38
|
+
x.gsub(/^(.+)$/, "\\1 ")
|
39
|
+
end
|
40
|
+
|
41
|
+
# Insert pre block extractions
|
42
|
+
text.gsub!(/\{gfm-extraction-([0-9a-f]{32})\}/) do
|
43
|
+
extractions[$1]
|
44
|
+
end
|
45
|
+
|
46
|
+
text
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
begin
|
52
|
+
require 'rdiscount'
|
53
|
+
RDoc::TopLevel.send :include, SDocHelpers::MarkdownFiles
|
54
|
+
rescue LoadError
|
55
|
+
puts "Markdown support not enabled. Please install RDiscount."
|
56
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rake/sdoctask'
|
2
|
+
|
3
|
+
namespace :pages do
|
4
|
+
task :publish => [ :check_dirty, :rerdoc ] do
|
5
|
+
`git checkout gh-pages`
|
6
|
+
`ls -1 | grep -v docs | xargs rm -rf; mv docs/* .; rm -rf docs`
|
7
|
+
`git add .; git commit -m "update docs"; git push origin gh-pages`
|
8
|
+
`git checkout master`
|
9
|
+
puts :done
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Initialize GitHub Pages with documentation"
|
13
|
+
task :init => [ :check_dirty, :rerdoc ] do
|
14
|
+
`git symbolic-ref HEAD refs/heads/gh-pages`
|
15
|
+
`rm .git/index`
|
16
|
+
`ls -1 | grep -v docs | xargs rm -rf; mv docs/* .; rm -rf docs`
|
17
|
+
`git add .;git commit -m "create docs"; git push origin gh-pages`
|
18
|
+
`git checkout master`
|
19
|
+
puts :done
|
20
|
+
end
|
21
|
+
|
22
|
+
task :check_dirty do
|
23
|
+
if !`git status`.include?('nothing to commit')
|
24
|
+
abort "dirty index - not publishing!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Build and publish documentation using GitHub Pages."
|
30
|
+
task :pages => "pages:publish"
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brianjlandau-sdoc-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Wanstrath
|
8
|
+
- Brian Landau
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-24 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Simple helpers to make using sdoc easier.
|
18
|
+
email: chris@ozmm.org
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- README.md
|
25
|
+
files:
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- lib/rake/sdoctask.rb
|
29
|
+
- lib/sdoc_helpers.rb
|
30
|
+
- lib/sdoc_helpers/markdown.rb
|
31
|
+
- lib/sdoc_helpers/pages.rb
|
32
|
+
- lib/sdoc_helpers/version.rb
|
33
|
+
has_rdoc: true
|
34
|
+
homepage: http://github.com/brianjlandau/sdoc-helpers
|
35
|
+
licenses: []
|
36
|
+
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options:
|
39
|
+
- --charset=UTF-8
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
version:
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.5
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: Simple helpers to make using sdoc easier.
|
61
|
+
test_files: []
|
62
|
+
|