proscribe 0.0.3 → 0.0.4
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/.gitignore +2 -0
- data/Gemfile +1 -0
- data/HISTORY.md +15 -0
- data/Scribefile +8 -0
- data/data/default/_layouts/_subindex.haml +18 -0
- data/data/default/_layouts/default.haml +9 -11
- data/lib/proscribe/cli.rb +5 -2
- data/lib/proscribe/extractor.rb +64 -32
- data/lib/proscribe/version.rb +1 -1
- data/lib/proscribe.rb +1 -0
- data/manual/config.ru +3 -0
- data/manual/index.md +56 -0
- data/proscribe.gemspec +20 -0
- metadata +30 -24
- data/data/default/_layouts/_nav.haml +0 -8
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
v0.0.4 - Aug 01, 2011
|
2
|
+
---------------------
|
3
|
+
|
4
|
+
### Changed:
|
5
|
+
* Upgrade Proton. This makes things so much faster.
|
6
|
+
* Improvements and stuff.
|
7
|
+
|
8
|
+
### Added:
|
9
|
+
* support for 'Usage: xx'
|
10
|
+
* Inheritance via 'Inherits: {Classname}'
|
11
|
+
|
12
|
+
### Fixed:
|
13
|
+
* Ensure that the page headers in generated files are YAML-parseable.
|
14
|
+
* Only make {linking} work for those without spaces around it.
|
15
|
+
|
1
16
|
v0.0.2 - Jul 29, 2011
|
2
17
|
---------------------
|
3
18
|
|
data/Scribefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
-# Combine all childrens
|
2
|
+
- from = [from] unless from.is_a?(Array)
|
3
|
+
- childrens = from.compact.map { |p| page_children(p) }
|
4
|
+
- groups = childrens.inject({}) { |h, groups| groups.each { |k, v| h[k] ||= Array.new; h[k] += v }; h }
|
5
|
+
- suffix ||= nil
|
6
|
+
|
7
|
+
- groups.each do |type, children|
|
8
|
+
%h3
|
9
|
+
= type.to_s.gsub('_', ' ').capitalize
|
10
|
+
- if suffix
|
11
|
+
= suffix
|
12
|
+
|
13
|
+
%ul.section
|
14
|
+
- children.each do |method|
|
15
|
+
%li
|
16
|
+
%a{href: rel(method.path)}= method.title
|
17
|
+
- unless method.meta.brief.to_s.empty?
|
18
|
+
%span.brief= method.meta.brief
|
@@ -24,7 +24,7 @@
|
|
24
24
|
%body
|
25
25
|
#top
|
26
26
|
%a#logo{href: rel('/')}
|
27
|
-
=
|
27
|
+
= Proton::Page['/'].title
|
28
28
|
|
29
29
|
#area
|
30
30
|
#content
|
@@ -44,18 +44,16 @@
|
|
44
44
|
%h5= page.meta.brief
|
45
45
|
|
46
46
|
.content
|
47
|
-
|
47
|
+
- if page.meta.usage
|
48
|
+
%h2 Usage
|
49
|
+
%pre= page.meta.usage
|
48
50
|
|
49
|
-
|
50
|
-
- groups.each do |type, children|
|
51
|
-
%h3= type.to_s.gsub('_', ' ').capitalize
|
51
|
+
!= yield
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
- unless method.meta.brief.to_s.empty?
|
58
|
-
%span.brief= method.meta.brief
|
53
|
+
!= partial :_subindex, :from => page
|
54
|
+
- if page.meta.inherits
|
55
|
+
- pages = page.meta.inherits.split(' ').map { |path| Proton::Page[path] }
|
56
|
+
!= partial :_subindex, :from => pages, :suffix => "(Inherited)"
|
59
57
|
|
60
58
|
-# Source
|
61
59
|
%section.footer
|
data/lib/proscribe/cli.rb
CHANGED
@@ -6,11 +6,14 @@ class ProScribe::CLI < Shake
|
|
6
6
|
extend ProScribe::Helpers
|
7
7
|
|
8
8
|
task(:build) do
|
9
|
+
|
9
10
|
project.make
|
10
11
|
pass project.dir if ARGV.delete('-d') || ARGV.delete('--debug')
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
require 'proton'
|
14
|
+
pro = Proton::Project.new project.dir
|
15
|
+
pro.build { |file|
|
16
|
+
puts "* %-35s %-35s" % [ file, "(#{file.path})" ]
|
14
17
|
}
|
15
18
|
|
16
19
|
copy_files project.dir('_output'), project.root(project.config.output)
|
data/lib/proscribe/extractor.rb
CHANGED
@@ -4,17 +4,20 @@ require 'ostruct'
|
|
4
4
|
require 'fileutils'
|
5
5
|
|
6
6
|
module ProScribe
|
7
|
+
# Class: Extractor (ProScribe)
|
7
8
|
# Extracts comments from list of files.
|
8
|
-
# Gets the ones with comment blocks starting with `[...]`
|
9
9
|
#
|
10
|
-
#
|
10
|
+
# ## Description
|
11
|
+
# Gets the ones with comment blocks starting with `[...]`
|
11
12
|
#
|
12
|
-
#
|
13
|
-
# ex.blocks
|
13
|
+
# ## Common usage
|
14
14
|
#
|
15
|
-
#
|
15
|
+
# ex = Extractor.new(Dir['./**/*.rb'])
|
16
|
+
# ex.blocks
|
16
17
|
#
|
17
|
-
#
|
18
|
+
# ex.blocks.map! { |b| b.file = "file: #{b.file}" }
|
19
|
+
#
|
20
|
+
# ex.write!('manual/') # Writes to manual/
|
18
21
|
#
|
19
22
|
class Extractor
|
20
23
|
def initialize(files, root, options={})
|
@@ -31,7 +34,8 @@ module ProScribe
|
|
31
34
|
}
|
32
35
|
end
|
33
36
|
|
34
|
-
#
|
37
|
+
# Method: blocks (ProScribe::Extractor)
|
38
|
+
# Returns an array of {Extractor::Block}s.
|
35
39
|
def blocks
|
36
40
|
@blocks ||= begin
|
37
41
|
@files.map { |file|
|
@@ -60,16 +64,16 @@ module ProScribe
|
|
60
64
|
:type => $1,
|
61
65
|
:title => $2,
|
62
66
|
:parent => $3,
|
63
|
-
:
|
64
|
-
:
|
67
|
+
:source_line => hash[:line] + block.size + 1,
|
68
|
+
:source_file => filename,
|
65
69
|
:body => (block[0..-2].join("\n") + "\n")
|
66
70
|
elsif block.first =~ re
|
67
71
|
Extractor::Block.new \
|
68
72
|
:type => $1,
|
69
73
|
:title => $2,
|
70
74
|
:parent => $3,
|
71
|
-
:
|
72
|
-
:
|
75
|
+
:source_line => hash[:line] + block.size + 1,
|
76
|
+
:source_file => filename,
|
73
77
|
:body => (block[1..-1].join("\n") + "\n")
|
74
78
|
end
|
75
79
|
}.compact
|
@@ -99,20 +103,38 @@ module ProScribe
|
|
99
103
|
attr_accessor :file
|
100
104
|
|
101
105
|
def initialize(options)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
106
|
+
options[:type].downcase!
|
107
|
+
body = options.delete(:body)
|
108
|
+
type = options.delete(:type)
|
109
|
+
file = to_filename(options[:title], options[:parent])
|
110
|
+
|
111
|
+
# Build the hash thing.
|
112
|
+
header = Hash[options.map { |(k, v)| [k.to_s, v] }]
|
113
|
+
|
114
|
+
# Extract the brief and other artifacts.
|
115
|
+
body = body.split("\n")
|
116
|
+
while true
|
117
|
+
line = body.first
|
118
|
+
if line.nil?
|
119
|
+
break
|
120
|
+
elsif line =~ /^(.*?): (.*?)$/
|
121
|
+
header[$1.downcase] = $2.strip
|
122
|
+
body.shift
|
123
|
+
elsif line.strip.empty?
|
124
|
+
body.shift
|
125
|
+
else
|
126
|
+
brief = body.shift
|
127
|
+
break
|
128
|
+
end
|
129
|
+
end
|
130
|
+
body = body.join("\n")
|
113
131
|
|
114
|
-
|
115
|
-
|
132
|
+
# Build the hash thing.
|
133
|
+
header['page_type'] = type
|
134
|
+
header['brief'] = brief
|
135
|
+
header['inherits'] = resolve(header['inherits']) { |fname, _, _| fname } if header['inherits']
|
136
|
+
heading = YAML::dump(header).gsub(/^[\-\n]*/, '').strip
|
137
|
+
heading += "\n--\n"
|
116
138
|
|
117
139
|
@file = file
|
118
140
|
body = Tilt.new(".md") { body }.render
|
@@ -121,13 +143,8 @@ module ProScribe
|
|
121
143
|
end
|
122
144
|
|
123
145
|
private
|
124
|
-
def
|
125
|
-
|
126
|
-
depth = from.to_s.count('/')
|
127
|
-
indent = (depth > 1 ? '../'*(depth-1) : './')[0..-2]
|
128
|
-
|
129
|
-
# First pass, {Helpers::content_for} to become links
|
130
|
-
str = str.gsub(/{([^}]*?)}/) { |s|
|
146
|
+
def resolve(str, &blk)
|
147
|
+
str.gsub(/{(?!\s)([^}]*?)(?<!\s)}/) { |s|
|
131
148
|
s = s.gsub(/{|}/, '')
|
132
149
|
|
133
150
|
m = s.match(/^(.*?)[:\.]+([A-Za-z_\(\)\!\?]+)$/)
|
@@ -137,7 +154,19 @@ module ProScribe
|
|
137
154
|
name, context = s, nil
|
138
155
|
end
|
139
156
|
|
140
|
-
|
157
|
+
fname = to_filename(s, '', :ext => '.html')
|
158
|
+
yield fname, name, context
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
162
|
+
def fix_links(str, options={})
|
163
|
+
from = ("/" + options[:from].to_s).squeeze('/')
|
164
|
+
depth = from.to_s.count('/')
|
165
|
+
indent = (depth > 1 ? '../'*(depth-1) : './')[0..-2]
|
166
|
+
|
167
|
+
# First pass, {Helpers::content_for} to become links
|
168
|
+
str = resolve(str) { |fname, name, context|
|
169
|
+
s = "<a href='/#{fname}'>#{name}</a>"
|
141
170
|
s += " <span class='context'>(#{context})</span>" if context
|
142
171
|
s
|
143
172
|
}
|
@@ -151,6 +180,9 @@ module ProScribe
|
|
151
180
|
}
|
152
181
|
end
|
153
182
|
|
183
|
+
# Private method: to_filename (ProScribe::Extractor)
|
184
|
+
# Changes something to a filename.
|
185
|
+
#
|
154
186
|
def to_filename(title, parent='', options={})
|
155
187
|
extension = options[:ext] || '.erb'
|
156
188
|
pathify = lambda { |s|
|
data/lib/proscribe/version.rb
CHANGED
data/lib/proscribe.rb
CHANGED
data/manual/config.ru
ADDED
data/manual/index.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
title: ProScribe manual
|
2
|
+
brief: Crappy source documentation tool.
|
3
|
+
--
|
4
|
+
|
5
|
+
$ gem install proscribe
|
6
|
+
|
7
|
+
#### Enable ProScribe
|
8
|
+
Make your code project ProScribe-able using `proscribe new`.
|
9
|
+
|
10
|
+
$ proscribe new
|
11
|
+
create Scribefile
|
12
|
+
create manual/
|
13
|
+
create manual/index.md
|
14
|
+
</pre>
|
15
|
+
|
16
|
+
#### Inline comments
|
17
|
+
Now edit your files in `manual/` and inline comments in your source code. Use Markdown!
|
18
|
+
|
19
|
+
# Class: Adaptor
|
20
|
+
# Adapts insteads of dying.
|
21
|
+
#
|
22
|
+
# ## Usage
|
23
|
+
#
|
24
|
+
# a = Adaptor.new(plug)
|
25
|
+
#
|
26
|
+
# ## Description
|
27
|
+
#
|
28
|
+
# This is a great class.
|
29
|
+
#
|
30
|
+
class Adaptor
|
31
|
+
# ...
|
32
|
+
end
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
#### Build as HTML
|
36
|
+
|
37
|
+
To build documentation HTML, use this. This builds HTML in `doc/` by default.
|
38
|
+
|
39
|
+
$ proscribe build
|
40
|
+
...
|
41
|
+
|
42
|
+
$ ls doc/
|
43
|
+
index.html
|
44
|
+
style.css
|
45
|
+
...
|
46
|
+
|
47
|
+
#### Real-time previews
|
48
|
+
You may also preview your changes in real time. Do this, then point your browser to `http://localhost:4833` to see your changes in real time.
|
49
|
+
|
50
|
+
$ proscribe start
|
51
|
+
* Starting server...
|
52
|
+
>> Thin web server (v1.2.11 codename Bat-Shit Crazy)
|
53
|
+
>> Maximum connections set to 1024
|
54
|
+
>> Listening on 0.0.0.0:4833, CTRL+C to stop
|
55
|
+
|
56
|
+
[Source code](http://github.com/rstacruz/proscribe "Source code")
|
data/proscribe.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require './lib/proscribe/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "proscribe"
|
5
|
+
s.version = ProScribe.version
|
6
|
+
s.summary = %{Documentation generator.}
|
7
|
+
s.description = %Q{Build some documentation for your projects of any language.}
|
8
|
+
s.authors = ["Rico Sta. Cruz"]
|
9
|
+
s.email = ["rico@sinefunc.com"]
|
10
|
+
s.homepage = "http://github.com/rstacruz/proscribe"
|
11
|
+
s.files = `git ls-files`.strip.split("\n")
|
12
|
+
s.executables = Dir["bin/*"].map { |f| File.basename(f) }
|
13
|
+
|
14
|
+
s.add_dependency "hashie", "~> 1.0.0"
|
15
|
+
s.add_dependency "shake", "~> 0.1.2"
|
16
|
+
s.add_dependency "tilt", "~> 1.3.2"
|
17
|
+
s.add_dependency "proton", "~> 0.3.4"
|
18
|
+
s.add_dependency "fssm", "~> 0.2.7"
|
19
|
+
s.add_dependency "rdiscount", "~> 1.6.8"
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proscribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-08-01 00:00:00.000000000 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hashie
|
17
|
-
requirement: &
|
17
|
+
requirement: &2154058100 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2154058100
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: shake
|
28
|
-
requirement: &
|
28
|
+
requirement: &2154057600 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,32 +33,32 @@ dependencies:
|
|
33
33
|
version: 0.1.2
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2154057600
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: tilt
|
39
|
-
requirement: &
|
39
|
+
requirement: &2164403120 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: 1.
|
44
|
+
version: 1.3.2
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2164403120
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: proton
|
50
|
-
requirement: &
|
50
|
+
requirement: &2164402660 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.3.
|
55
|
+
version: 0.3.4
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2164402660
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: fssm
|
61
|
-
requirement: &
|
61
|
+
requirement: &2164402200 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 0.2.7
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2164402200
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rdiscount
|
72
|
-
requirement: &
|
72
|
+
requirement: &2164401740 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: 1.6.8
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2164401740
|
81
81
|
description: Build some documentation for your projects of any language.
|
82
82
|
email:
|
83
83
|
- rico@sinefunc.com
|
@@ -86,16 +86,22 @@ executables:
|
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
89
|
+
- .gitignore
|
90
|
+
- Gemfile
|
91
|
+
- HISTORY.md
|
92
|
+
- README.md
|
93
|
+
- Scribefile
|
94
|
+
- bin/proscribe
|
92
95
|
- data/default/Gemfile
|
93
96
|
- data/default/Gemfile.lock
|
94
|
-
- data/default/proscribe.js
|
95
97
|
- data/default/Protonfile
|
98
|
+
- data/default/_extensions/helpers.rb
|
99
|
+
- data/default/_layouts/_subindex.haml
|
100
|
+
- data/default/_layouts/default.haml
|
101
|
+
- data/default/proscribe.js
|
96
102
|
- data/default/style.scss
|
97
103
|
- data/rack/config.ru
|
98
|
-
-
|
104
|
+
- lib/proscribe.rb
|
99
105
|
- lib/proscribe/cli.rb
|
100
106
|
- lib/proscribe/extractor.rb
|
101
107
|
- lib/proscribe/helpers.rb
|
@@ -103,9 +109,9 @@ files:
|
|
103
109
|
- lib/proscribe/rack_app.rb
|
104
110
|
- lib/proscribe/version.rb
|
105
111
|
- lib/proscribe/watcher.rb
|
106
|
-
-
|
107
|
-
-
|
108
|
-
-
|
112
|
+
- manual/config.ru
|
113
|
+
- manual/index.md
|
114
|
+
- proscribe.gemspec
|
109
115
|
has_rdoc: true
|
110
116
|
homepage: http://github.com/rstacruz/proscribe
|
111
117
|
licenses: []
|