docme 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/docme +4 -0
- data/lib/docme.rb +139 -0
- data/lib/docme/utils.rb +8 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8092d5b797a25febaea7f8a5fefceb7d1abcdd6
|
4
|
+
data.tar.gz: de1f4530c2d36f17ae757ba8b41bc17cb51abdbc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f05590f2bca35a3b51268f7575639d06495e4dff166acc60855f63e5c03595325a66ea4208056ae9c4fe3be0e09b2500d5c13c33acf3d7b9afce8acc128205b0
|
7
|
+
data.tar.gz: 0e67d56038efee0c763e0616afc47b91ed9b63db7b33c8b61ef4d62bc15d0f098da37a21b8c0cb806c76acc59fe3ce3eda8a071d1f68bc220eb7cab22452563b
|
data/bin/docme
ADDED
data/lib/docme.rb
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# docme
|
2
|
+
|
3
|
+
require 'docme/utils'
|
4
|
+
|
5
|
+
class Docme
|
6
|
+
|
7
|
+
def self.jsParse(file)
|
8
|
+
#file = ARGV[0]
|
9
|
+
|
10
|
+
|
11
|
+
#raise exception if no file provided, file does not exsist, the file is not readable, or the file has no content
|
12
|
+
if file== nil || !File.file?(file) || !File.exists?(file)
|
13
|
+
raise "Please provide a path to the file you wish to docme."
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "\n ***Begining docme magix***"
|
17
|
+
|
18
|
+
#create the directory where the site will be stored
|
19
|
+
if !File::directory?("docme_site")
|
20
|
+
puts "+Setting up docme's living arrangements."
|
21
|
+
Dir.mkdir("docme_site")
|
22
|
+
end
|
23
|
+
|
24
|
+
puts "Woohoo! docme has a home!"
|
25
|
+
|
26
|
+
#GLOBALS
|
27
|
+
sourceFile = File.open(file).read
|
28
|
+
docmeDir = "docme"
|
29
|
+
block_flag = 0
|
30
|
+
code_flag = 0
|
31
|
+
|
32
|
+
sourceFile.each_line do |line|
|
33
|
+
#strip leading whitespaces
|
34
|
+
line = line.lstrip
|
35
|
+
|
36
|
+
#if this is the begining of a comment block then start a new function doc
|
37
|
+
if line.rindex("/*", 1) == 0
|
38
|
+
#logic to add a new function section to the erb file
|
39
|
+
next
|
40
|
+
end
|
41
|
+
|
42
|
+
#if this is the end of a comment block then there is nothing to do
|
43
|
+
if line.rindex("*/", 1) == 0
|
44
|
+
#end the function section of the erb file
|
45
|
+
next
|
46
|
+
end
|
47
|
+
|
48
|
+
#if line begins with '+' then we are defining an attribute
|
49
|
+
if line.rindex("+",0) == 0
|
50
|
+
parts = line.split(":")
|
51
|
+
|
52
|
+
#parts[0] == the attribute name
|
53
|
+
attribute = cleanAttribute(parts[0])
|
54
|
+
#add the attribute to the doc
|
55
|
+
|
56
|
+
content = parts[1].lstrip
|
57
|
+
|
58
|
+
#if the content begins with '{' then we have a block
|
59
|
+
if content.rindex("{",0) == 0
|
60
|
+
#go to the next line and look for '-', set block flag
|
61
|
+
#add the attribute to the doc
|
62
|
+
puts attribute
|
63
|
+
block_flag = 1
|
64
|
+
next
|
65
|
+
end
|
66
|
+
|
67
|
+
#add content to the doc
|
68
|
+
puts attribute
|
69
|
+
puts content
|
70
|
+
end
|
71
|
+
|
72
|
+
#if line begins with a '-' then we are in a block
|
73
|
+
if line.rindex("-",0) == 0
|
74
|
+
parts = line.split(":")
|
75
|
+
|
76
|
+
#parts[0] == the attribute name
|
77
|
+
attribute = cleanAttribute(parts[0])
|
78
|
+
#add the attribute to the doc
|
79
|
+
|
80
|
+
content = parts[1].lstrip
|
81
|
+
|
82
|
+
if attribute == "var"
|
83
|
+
# look for arrow
|
84
|
+
content_parts = content.split("->")
|
85
|
+
var_name = content_parts[0]
|
86
|
+
var_description = content_parts[1].lstrip
|
87
|
+
|
88
|
+
#put the var_name in the doc
|
89
|
+
#put the var_description in the doc
|
90
|
+
puts var_name
|
91
|
+
puts var_description
|
92
|
+
next
|
93
|
+
end
|
94
|
+
|
95
|
+
if attribute == "code"
|
96
|
+
code_flag = 1
|
97
|
+
#go ahead and skip to next line and process code
|
98
|
+
next
|
99
|
+
end
|
100
|
+
|
101
|
+
#if !var and !code, then process as regular attributes
|
102
|
+
#put the attribute name
|
103
|
+
#put the content
|
104
|
+
puts attribute
|
105
|
+
puts content
|
106
|
+
next
|
107
|
+
end
|
108
|
+
|
109
|
+
#if code flag is set and we reached the end of a block, then we reached the end of a code block, unset the flag
|
110
|
+
if code_flag == 1 && line.rindex("}",0) == 0
|
111
|
+
code_flag = 0
|
112
|
+
next
|
113
|
+
end
|
114
|
+
|
115
|
+
#if the block flag is set and we reach the end of a block, then we reached the end of a regular block, unset flag
|
116
|
+
if block_flag == 1 && line.rindex("}",0) == 0
|
117
|
+
block_flag = 0
|
118
|
+
end
|
119
|
+
|
120
|
+
#if we are in a code block, then return lines as is
|
121
|
+
if code_flag == 1
|
122
|
+
puts line
|
123
|
+
next
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
def render()
|
130
|
+
ERB.new(@template).result(binding)
|
131
|
+
end
|
132
|
+
|
133
|
+
def save(site)
|
134
|
+
FIle.open(site, "w+") do |f|
|
135
|
+
f.write(render)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
data/lib/docme/utils.rb
ADDED
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: docme
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bailey Belvis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A gem to support easy documentation for javascript files.
|
14
|
+
email: baileyb622@gmail.com
|
15
|
+
executables:
|
16
|
+
- docme
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/docme
|
21
|
+
- lib/docme.rb
|
22
|
+
- lib/docme/utils.rb
|
23
|
+
homepage: https://github.com/philosowaffle/docme
|
24
|
+
licenses:
|
25
|
+
- Mozilla Public License
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.2.2
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: A documentation site generator.
|
47
|
+
test_files: []
|