proscribe 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ doc
2
+ /Gemfile.lock
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,8 @@
1
+ manual: 'manual'
2
+
3
+ files:
4
+ - source: lib/**/*.rb
5
+
6
+ output: doc
7
+
8
+ github: rstacruz/proscribe
@@ -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
- = Hyde::Page['/'].title
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
- != yield
47
+ - if page.meta.usage
48
+ %h2 Usage
49
+ %pre= page.meta.usage
48
50
 
49
- - groups = page_children(page)
50
- - groups.each do |type, children|
51
- %h3= type.to_s.gsub('_', ' ').capitalize
51
+ != yield
52
52
 
53
- %ul.section
54
- - children.each do |method|
55
- %li
56
- %a{href: rel(method.path)}= method.title
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
- Dir.chdir(project.dir) {
13
- system "proton build"
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)
@@ -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
- # == Common usage
10
+ # ## Description
11
+ # Gets the ones with comment blocks starting with `[...]`
11
12
  #
12
- # ex = Extractor.new(Dir['./**/*.rb'])
13
- # ex.blocks
13
+ # ## Common usage
14
14
  #
15
- # ex.blocks.map! { |b| b.file = "file: #{b.file}" }
15
+ # ex = Extractor.new(Dir['./**/*.rb'])
16
+ # ex.blocks
16
17
  #
17
- # ex.write!('manual/') # Writes to manual/
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
- # Returns an array of Extractor::Blocks.
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
- :line => hash[:line] + block.size + 1,
64
- :source => filename,
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
- :line => hash[:line] + block.size + 1,
72
- :source => filename,
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
- title = options[:title]
103
- parent = options[:parent]
104
- body = options[:body]
105
- type = options[:type].downcase
106
-
107
- source = options[:source]
108
- line = options[:line]
109
-
110
- file = to_filename(title, parent)
111
- brief, *body = body.split("\n\n")
112
- body = "#{body.join("\n\n")}"
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
- heading = "title: #{title}\npage_type: #{type}\nsource_file: #{source}\nsource_line: #{line}\nbrief: #{brief}\n"
115
- heading += "--\n"
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 fix_links(str, options={})
125
- from = ("/" + options[:from].to_s).squeeze('/')
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
- s = "<a href='/#{to_filename(s, '', :ext => '.html')}'>#{name}</a>"
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|
@@ -6,6 +6,6 @@ module ProScribe
6
6
  # ProScribe.version #=> "0.0.2"
7
7
  #
8
8
  def self.version
9
- "0.0.3"
9
+ "0.0.4"
10
10
  end
11
11
  end
data/lib/proscribe.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'proton'
1
2
  require 'yaml'
2
3
  require 'fileutils'
3
4
  require 'tmpdir'
data/manual/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ gem 'proscribe', '~> 0.0.1'
2
+ require 'proscribe'
3
+ run ProScribe.rack_app
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.3
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-07-29 00:00:00.000000000 +08:00
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: &2158295020 !ruby/object:Gem::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: *2158295020
25
+ version_requirements: *2154058100
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: shake
28
- requirement: &2158294520 !ruby/object:Gem::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: *2158294520
36
+ version_requirements: *2154057600
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: tilt
39
- requirement: &2158294060 !ruby/object:Gem::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.2.2
44
+ version: 1.3.2
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2158294060
47
+ version_requirements: *2164403120
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: proton
50
- requirement: &2158293600 !ruby/object:Gem::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.3
55
+ version: 0.3.4
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2158293600
58
+ version_requirements: *2164402660
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: fssm
61
- requirement: &2158293140 !ruby/object:Gem::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: *2158293140
69
+ version_requirements: *2164402200
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rdiscount
72
- requirement: &2158292680 !ruby/object:Gem::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: *2158292680
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
- - data/default/_extensions/helpers.rb
90
- - data/default/_layouts/_nav.haml
91
- - data/default/_layouts/default.haml
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
- - bin/proscribe
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
- - lib/proscribe.rb
107
- - HISTORY.md
108
- - README.md
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: []
@@ -1,8 +0,0 @@
1
- - is_active = from == p
2
- - if p.html?
3
- %li
4
- %a{href: rel(p.path), class: ("active" if is_active)}= p
5
- %ul{class: "level-#{level}"}
6
- - p.children.each do |pp|
7
- != partial :'_nav', from: from, p: pp, level: level+1
8
-