cqdocs 0.0.1
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/lib/sinatra/cqdocs.rb +58 -0
- metadata +62 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module CqDocs
|
5
|
+
|
6
|
+
module Helpers
|
7
|
+
|
8
|
+
def get_view_as_string(filename)
|
9
|
+
view = File.join(settings.cqdocs_view_path, filename)
|
10
|
+
layout = File.join(settings.cqdocs_view_path, 'layouts/sample_markup.haml')
|
11
|
+
data = ""
|
12
|
+
f = File.open(view, "r")
|
13
|
+
f.each_line do |line|
|
14
|
+
data += line
|
15
|
+
end
|
16
|
+
return data
|
17
|
+
return layout
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_sample_code options={}, &block
|
21
|
+
block = capture_haml(&block)
|
22
|
+
capture_haml do
|
23
|
+
haml_tag :section, :id => classify(options[:name]) do
|
24
|
+
haml_tag :div, :class => "page-header" do
|
25
|
+
haml_tag :h1, options[:name]
|
26
|
+
end
|
27
|
+
haml_tag :h2, "Example"
|
28
|
+
haml_tag :p, options[:description]
|
29
|
+
haml_tag :div, block, :class => "bs-docs-example"
|
30
|
+
haml_tag :h2, "Markup"
|
31
|
+
haml_tag :pre, html_escape(block), :class => "prettyprint linenums"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def classify string
|
37
|
+
result = string.downcase
|
38
|
+
result = result.gsub(/([\W_]+)/, '-')
|
39
|
+
result = result.gsub(/-\z/, '')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.registered(app)
|
44
|
+
app.helpers NiftyDocs::Helpers
|
45
|
+
|
46
|
+
unless defined?(settings.template_engine)
|
47
|
+
app.set :template_engine, :haml
|
48
|
+
end
|
49
|
+
|
50
|
+
app.set :cqdocs_view_path, File.expand_path('../views/', __FILE__)
|
51
|
+
|
52
|
+
app.get "/body_components.html" do
|
53
|
+
view_location = File.expand_path('../views', __FILE__)
|
54
|
+
send settings.template_engine, get_view_as_string("body_components.#{settings.template_engine}"), :layout => :"layouts/sample_markup", :views => view_location
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cqdocs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Leo Herrick
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2013-03-12 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Can be used to generate set of docs for CQ projects
|
22
|
+
email: leoherrick@gmail.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files: []
|
28
|
+
|
29
|
+
files:
|
30
|
+
- lib/sinatra/cqdocs.rb
|
31
|
+
has_rdoc: true
|
32
|
+
homepage:
|
33
|
+
licenses: []
|
34
|
+
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
requirements: []
|
55
|
+
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 1.3.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 3
|
60
|
+
summary: CQ Docs!
|
61
|
+
test_files: []
|
62
|
+
|