phari_doc_gen 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/generate +5 -0
- data/lib/phari_doc_gen.rb +33 -0
- data/lib/phari_doc_gen/FileHandler.rb +551 -0
- data/lib/phari_doc_gen/MethodParam.rb +21 -0
- data/lib/phari_doc_gen/Metodo.rb +49 -0
- data/lib/phari_doc_gen/Modelo.rb +31 -0
- data/lib/phari_doc_gen/Rota.rb +53 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c59179d663a41f7f6646966da28c019bded358d
|
4
|
+
data.tar.gz: 978dd3f5616a8d6e497278472547c8c4cb70ef4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb6ee7e3b71a0f94983622b5844b7301d6a82bae32573a018ad3085d54ddb16e3f3322dbcae38bdee664083cc0500270192687487d5cac2e5c00f2e73654ea08
|
7
|
+
data.tar.gz: 9f4fe4a27d14dec2dea0ff80093889412adc4531fe2f37fc7f8c111e60d54b48a4fe9734ce9e74f56938f116f61de1930713b372365066f3bb7d84bc2633514f
|
data/bin/generate
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require_relative 'phari_doc_gen/Modelo.rb'
|
3
|
+
require_relative 'phari_doc_gen/Rota.rb'
|
4
|
+
require_relative 'phari_doc_gen/Metodo.rb'
|
5
|
+
require_relative 'phari_doc_gen/MethodParam.rb'
|
6
|
+
require_relative 'phari_doc_gen/FileHandler.rb'
|
7
|
+
|
8
|
+
class PhariDocGen
|
9
|
+
def generate (project, path)
|
10
|
+
if project == nil
|
11
|
+
puts "Insert project which generate documentation"
|
12
|
+
project = gets.chomp
|
13
|
+
end
|
14
|
+
if project == ''
|
15
|
+
puts 'Aborting generation due to empty project name'
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
generate = FileHandler.new
|
19
|
+
projectDescription = generate.readProject(project)
|
20
|
+
models = generate.readFiles(project)
|
21
|
+
if path == nil
|
22
|
+
puts 'Insert path to output file'
|
23
|
+
path = gets.chomp
|
24
|
+
end
|
25
|
+
path += '/' unless path.end_with?('/')
|
26
|
+
if path == ''
|
27
|
+
puts 'Aborting generation due to empty path'
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
generate.writeFiles(models, project, projectDescription, path)
|
31
|
+
puts 'Done!'
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,551 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require_relative 'Modelo.rb'
|
3
|
+
require_relative 'Rota.rb'
|
4
|
+
require_relative 'Metodo.rb'
|
5
|
+
require_relative 'MethodParam.rb'
|
6
|
+
|
7
|
+
class FileHandler
|
8
|
+
# Leitura dos arquivos
|
9
|
+
def packageExistis?(packageName)
|
10
|
+
found = false
|
11
|
+
package = ''
|
12
|
+
Dir.glob('/**/' + packageName + '/') do |folder|
|
13
|
+
package = folder unless found
|
14
|
+
found = true
|
15
|
+
# puts 'done'
|
16
|
+
end
|
17
|
+
packagePath = package.to_s
|
18
|
+
# puts packagePath
|
19
|
+
if found
|
20
|
+
return packagePath
|
21
|
+
else
|
22
|
+
puts 'Aborting: package not found'
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def readProject(project)
|
28
|
+
path = packageExistis?(project)
|
29
|
+
projectDescription = ''
|
30
|
+
readme = File.new(path + 'README.md')
|
31
|
+
projectDescription = readProjectDescription(readme)
|
32
|
+
projectDescription
|
33
|
+
end
|
34
|
+
|
35
|
+
def readFiles(project)
|
36
|
+
models = []
|
37
|
+
path = packageExistis?(project)
|
38
|
+
Dir.glob(path + 'backend/api/models/*.rb') do |file|
|
39
|
+
filename = file.to_s
|
40
|
+
inputFile = File.new(filename)
|
41
|
+
modelname = File.basename(inputFile, '.rb')
|
42
|
+
helpername = path + 'backend/api/app/helpers/' + modelname + '_helper.rb'
|
43
|
+
controllername = path + 'backend/api/app/controllers/' + modelname + '.rb'
|
44
|
+
if File.exist?(helpername) && File.exist?(controllername)
|
45
|
+
modelHelper = File.new(helpername, 'r')
|
46
|
+
modelController = File.new(controllername, 'r')
|
47
|
+
methods = readMethods(modelHelper)
|
48
|
+
routes = readRoutes(modelController)
|
49
|
+
currentModel = Modelo.new(modelname, methods, routes)
|
50
|
+
models << currentModel
|
51
|
+
end
|
52
|
+
end
|
53
|
+
models
|
54
|
+
end
|
55
|
+
|
56
|
+
# Métodos auxiliares a leitura
|
57
|
+
def readProjectDescription(readme)
|
58
|
+
isCode = false
|
59
|
+
@projectDescription = ''
|
60
|
+
arr = IO.readlines(readme)
|
61
|
+
arr.each do |line|
|
62
|
+
next if line.start_with?('# ')
|
63
|
+
if line.start_with?('## ')
|
64
|
+
line = '<h3>' + line.slice(3, line.length - 3)
|
65
|
+
line += '</h3>'
|
66
|
+
# puts line
|
67
|
+
end
|
68
|
+
if line.start_with?('### ')
|
69
|
+
line = '<h4>' + line.slice(4, line.length - 4) + '</h4>'
|
70
|
+
# puts line
|
71
|
+
end
|
72
|
+
if line.start_with?('##### ')
|
73
|
+
line = '<h5>' + line.slice(6, line.length - 6) + '</h5>'
|
74
|
+
# puts line
|
75
|
+
end
|
76
|
+
if line.start_with?('* ')
|
77
|
+
line = '<li>' + line.slice(2, line.length - 2) + '</li>'
|
78
|
+
# puts line
|
79
|
+
end
|
80
|
+
while hasBetween?(line, '**', '**')
|
81
|
+
line = higlightText(line)
|
82
|
+
# puts line
|
83
|
+
end
|
84
|
+
line = italicText(line) while hasBetween?(line, '*', '*')
|
85
|
+
if line.include?('```')
|
86
|
+
if isCode
|
87
|
+
line = '</code><br><br>'
|
88
|
+
isCode = false
|
89
|
+
else
|
90
|
+
line = '<br><br><code>'
|
91
|
+
isCode = true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
while line.include?(' [') && line.include?('](')
|
95
|
+
line = linkText(line)
|
96
|
+
end
|
97
|
+
@projectDescription += line
|
98
|
+
end
|
99
|
+
@projectDescription
|
100
|
+
end
|
101
|
+
|
102
|
+
def hasBetween?(line, stringA, stringB)
|
103
|
+
if line.include?(stringA)
|
104
|
+
initial = line.index(stringA)
|
105
|
+
len = line.length - initial
|
106
|
+
lineSlice = line.slice(initial, len)
|
107
|
+
return true if lineSlice.include?(stringB)
|
108
|
+
end
|
109
|
+
false
|
110
|
+
end
|
111
|
+
|
112
|
+
def higlightText(line)
|
113
|
+
initialIndex = line.index('**') + 2
|
114
|
+
finalIndex = line.index('**', initialIndex)
|
115
|
+
initialString = line.slice(0, initialIndex - 2)
|
116
|
+
higlightedString = line.slice(initialIndex, finalIndex - initialIndex)
|
117
|
+
finalString = line.slice(finalIndex + 2, line.length - finalIndex + 2)
|
118
|
+
line = initialString + '<b>' + higlightedString + '</b>' + finalString
|
119
|
+
# puts line
|
120
|
+
line
|
121
|
+
end
|
122
|
+
|
123
|
+
def italicText(line)
|
124
|
+
initialIndex = line.index('*') + 1
|
125
|
+
finalIndex = line.index('*', initialIndex)
|
126
|
+
initialString = line.slice(0, initialIndex - 1)
|
127
|
+
higlightedString = line.slice(initialIndex, finalIndex - initialIndex)
|
128
|
+
finalString = line.slice(finalIndex + 1, line.length - finalIndex + 1)
|
129
|
+
line = initialString + '<i>' + higlightedString + '</i>' + finalString
|
130
|
+
# puts line
|
131
|
+
line
|
132
|
+
end
|
133
|
+
|
134
|
+
def linkText(line)
|
135
|
+
if line.include?(' [') && line.include?('](')
|
136
|
+
initialContentIndex = line.index('[') + 1
|
137
|
+
finalContentIndex = line.index(']', initialContentIndex)
|
138
|
+
initialLinkIndex = line.index('](') + 2
|
139
|
+
finalLinkIndex = line.index(')', initialLinkIndex)
|
140
|
+
initialString = line.slice(0, initialContentIndex - 1)
|
141
|
+
contentString = line.slice(initialContentIndex, finalContentIndex - initialContentIndex)
|
142
|
+
linkString = line.slice(initialLinkIndex, finalLinkIndex - initialLinkIndex)
|
143
|
+
finalString = line.slice(finalLinkIndex + 1, line.length - finalLinkIndex + 1)
|
144
|
+
line = initialString + '<a href="' + linkString + '">' + contentString + '</a>' + finalString
|
145
|
+
end
|
146
|
+
line
|
147
|
+
end
|
148
|
+
|
149
|
+
def readMethods(helper)
|
150
|
+
tipo = ''
|
151
|
+
nome = ''
|
152
|
+
descricao = ''
|
153
|
+
inputs = []
|
154
|
+
outputs = []
|
155
|
+
methods = []
|
156
|
+
toSent = true
|
157
|
+
arr = IO.readlines(helper)
|
158
|
+
arr.each do |line|
|
159
|
+
if hasKeyword?(line)
|
160
|
+
arg = decodeArgument(line)
|
161
|
+
keyword = arg[0]
|
162
|
+
argument = arg[1]
|
163
|
+
case keyword
|
164
|
+
when 'methods'
|
165
|
+
if nome != ''
|
166
|
+
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
167
|
+
inputs = []
|
168
|
+
outputs = []
|
169
|
+
toSent = false
|
170
|
+
end
|
171
|
+
tipo = argument
|
172
|
+
when 'name'
|
173
|
+
if nome != '' && toSent
|
174
|
+
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
175
|
+
inputs = []
|
176
|
+
outputs = []
|
177
|
+
else
|
178
|
+
toSent = true
|
179
|
+
end
|
180
|
+
nome = argument
|
181
|
+
# methods.last.printName
|
182
|
+
# puts "#{methods.size}"
|
183
|
+
when 'param'
|
184
|
+
data = dataValue(argument)
|
185
|
+
inputs << data
|
186
|
+
when 'return'
|
187
|
+
data = dataValue(argument)
|
188
|
+
outputs << data
|
189
|
+
end
|
190
|
+
end
|
191
|
+
descricao = decodeDescription(line) if hasDescription?(line)
|
192
|
+
end
|
193
|
+
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
194
|
+
methods
|
195
|
+
end
|
196
|
+
|
197
|
+
def readRoutes(controller)
|
198
|
+
tipo = ''
|
199
|
+
requisicao = ''
|
200
|
+
dataInput = ''
|
201
|
+
nome = ''
|
202
|
+
inputs = []
|
203
|
+
outputs = []
|
204
|
+
routes = []
|
205
|
+
toSent = true
|
206
|
+
arr = IO.readlines(controller)
|
207
|
+
arr.each do |line|
|
208
|
+
next unless hasKeyword?(line)
|
209
|
+
arg = decodeArgument(line)
|
210
|
+
keyword = arg[0]
|
211
|
+
argument = arg[1]
|
212
|
+
case keyword
|
213
|
+
when 'route'
|
214
|
+
if nome != ''
|
215
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
216
|
+
inputs = []
|
217
|
+
outputs = []
|
218
|
+
toSent = false
|
219
|
+
end
|
220
|
+
tipo = argument
|
221
|
+
when 'POST'
|
222
|
+
if nome != '' && toSent
|
223
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
224
|
+
inputs = []
|
225
|
+
outputs = []
|
226
|
+
else
|
227
|
+
toSent = true
|
228
|
+
end
|
229
|
+
requisicao = keyword
|
230
|
+
dataInput = argument
|
231
|
+
when 'GET'
|
232
|
+
if nome != '' && toSent
|
233
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
234
|
+
inputs = []
|
235
|
+
outputs = []
|
236
|
+
else
|
237
|
+
toSent = true
|
238
|
+
end
|
239
|
+
requisicao = keyword
|
240
|
+
dataInput = argument
|
241
|
+
when 'PUT'
|
242
|
+
if nome != '' && toSent
|
243
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
244
|
+
inputs = []
|
245
|
+
outputs = []
|
246
|
+
else
|
247
|
+
toSent = true
|
248
|
+
end
|
249
|
+
requisicao = keyword
|
250
|
+
dataInput = argument
|
251
|
+
when 'DELETE'
|
252
|
+
if nome != '' && toSent
|
253
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
254
|
+
inputs = []
|
255
|
+
outputs = []
|
256
|
+
else
|
257
|
+
toSent = true
|
258
|
+
end
|
259
|
+
requisicao = keyword
|
260
|
+
dataInput = argument
|
261
|
+
when 'name'
|
262
|
+
nome = argument
|
263
|
+
when 'param'
|
264
|
+
data = dataValue(argument)
|
265
|
+
inputs << data
|
266
|
+
when 'return'
|
267
|
+
data = dataValue(argument)
|
268
|
+
outputs << data
|
269
|
+
end
|
270
|
+
end
|
271
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
272
|
+
routes
|
273
|
+
end
|
274
|
+
|
275
|
+
# Métodos de decodificação da leitura
|
276
|
+
def hasKeyword?(line)
|
277
|
+
if (line.include? '#') && (line.include? '@')
|
278
|
+
if line.index('#') < line.index('@')
|
279
|
+
true
|
280
|
+
else
|
281
|
+
false
|
282
|
+
end
|
283
|
+
else
|
284
|
+
false
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def hasDescription?(line)
|
289
|
+
if (line.include? '#') && (line.include? '**')
|
290
|
+
if line.index('#') < line.index('**')
|
291
|
+
true
|
292
|
+
else
|
293
|
+
false
|
294
|
+
end
|
295
|
+
else
|
296
|
+
false
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def decodeArgument(line)
|
301
|
+
args = []
|
302
|
+
initialIndex = line.index('@') + 1
|
303
|
+
finalIndex = line.index("\s", line.index('@'))
|
304
|
+
lenght = finalIndex - initialIndex
|
305
|
+
keyword = line.slice(initialIndex, lenght)
|
306
|
+
argument = line.slice(finalIndex + 1, line.size - finalIndex)
|
307
|
+
args << keyword
|
308
|
+
args << argument
|
309
|
+
args
|
310
|
+
end
|
311
|
+
|
312
|
+
def dataValue(argument)
|
313
|
+
if argument.include? "\s"
|
314
|
+
name = argument.slice(0, argument.index("\s"))
|
315
|
+
type = argument.slice(argument.index("\s") + 1, argument.size - 1)
|
316
|
+
data = MethodParam.new(name, type)
|
317
|
+
# data.printSelf
|
318
|
+
return data
|
319
|
+
end
|
320
|
+
'nil'
|
321
|
+
end
|
322
|
+
|
323
|
+
def decodeDescription(line)
|
324
|
+
initialIndex = line.index('*') + 3
|
325
|
+
lenght = line.size - initialIndex
|
326
|
+
description = line.slice(initialIndex, lenght)
|
327
|
+
# puts "#{description}"
|
328
|
+
description
|
329
|
+
end
|
330
|
+
|
331
|
+
# Escrita dos arquivos
|
332
|
+
def writeFiles(models, project, projectDescription, path)
|
333
|
+
FileUtils.mkdir_p(path + 'css')
|
334
|
+
css = File.open(path + 'css/master.css', 'w')
|
335
|
+
writeCSS(css)
|
336
|
+
css.close
|
337
|
+
projectHTML = File.open(path + 'project.html', 'w')
|
338
|
+
writeHeader(projectHTML)
|
339
|
+
writeProjectPage(project, projectHTML, models, projectDescription)
|
340
|
+
projectHTML.close
|
341
|
+
FileUtils.mkdir_p(path + 'models')
|
342
|
+
models.each do |model|
|
343
|
+
name = model.name.downcase
|
344
|
+
modelHTML = File.open(path + "models/#{name}.html", 'w')
|
345
|
+
writeHeaderInDir(modelHTML)
|
346
|
+
writeModelPage(modelHTML, model)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
def writeCSS(file)
|
351
|
+
file.write("body{
|
352
|
+
background-color: #702794;
|
353
|
+
}
|
354
|
+
a{
|
355
|
+
color: #333;
|
356
|
+
}
|
357
|
+
li{
|
358
|
+
padding-left: 3%;
|
359
|
+
}
|
360
|
+
.logo{
|
361
|
+
margin: 5%;
|
362
|
+
}
|
363
|
+
.left{
|
364
|
+
float: left;
|
365
|
+
}
|
366
|
+
.right{
|
367
|
+
float: right;
|
368
|
+
}
|
369
|
+
.list-indexes{
|
370
|
+
font-size: 24px;
|
371
|
+
}")
|
372
|
+
end
|
373
|
+
|
374
|
+
def writeHeader(file)
|
375
|
+
file.write("<!DOCTYPE html>
|
376
|
+
|
377
|
+
<head lang='en'>
|
378
|
+
<meta charset='UTF-8'>
|
379
|
+
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous'>
|
380
|
+
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous'></script>
|
381
|
+
<link rel='stylesheet' href='css/master.css'>
|
382
|
+
</head>
|
383
|
+
|
384
|
+
<body>
|
385
|
+
<nav class='navbar navbar-default navbar-fixed-top'>
|
386
|
+
<div class='container-fluid'>
|
387
|
+
<div class='navbar-header'>
|
388
|
+
<a href='project.html'><img class='logo' src='https://lh6.googleusercontent.com/pjGCZHp28gHcczrlPXsXq91al6hGwOkI5r84860enhunQJGbAsmX1w-eXr2_X6M_5bxgajlNgQz6Sy8=w1600-h810' height='50px' alt='Logo'></a>
|
389
|
+
</div>
|
390
|
+
<ul class='nav navbar-nav'>
|
391
|
+
</ul>
|
392
|
+
</div>
|
393
|
+
</nav>
|
394
|
+
<br><br><br>")
|
395
|
+
end
|
396
|
+
|
397
|
+
def writeHeaderInDir(file)
|
398
|
+
file.write("<!DOCTYPE html>
|
399
|
+
|
400
|
+
<head lang='en'>
|
401
|
+
<meta charset='UTF-8'>
|
402
|
+
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' integrity='sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u' crossorigin='anonymous'>
|
403
|
+
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js' integrity='sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa' crossorigin='anonymous'></script>
|
404
|
+
<link rel='stylesheet' href='../css/master.css'>
|
405
|
+
</head>
|
406
|
+
|
407
|
+
<body>
|
408
|
+
<nav class='navbar navbar-default navbar-fixed-top'>
|
409
|
+
<div class='container-fluid'>
|
410
|
+
<div class='navbar-header'>
|
411
|
+
<a href='../project.html'><img class='logo' src='https://lh6.googleusercontent.com/pjGCZHp28gHcczrlPXsXq91al6hGwOkI5r84860enhunQJGbAsmX1w-eXr2_X6M_5bxgajlNgQz6Sy8=w1600-h810' height='50px' alt='Logo'></a>
|
412
|
+
</div>
|
413
|
+
<ul class='nav navbar-nav'>
|
414
|
+
</ul>
|
415
|
+
</div>
|
416
|
+
</nav>
|
417
|
+
<br><br><br>")
|
418
|
+
end
|
419
|
+
|
420
|
+
def writeProjectPage(project, file, models, description)
|
421
|
+
file.write("<div class='container panel panel-default'>
|
422
|
+
<div class='row'>
|
423
|
+
<div class='panel panel-default'>
|
424
|
+
<div class='panel-heading'>
|
425
|
+
<h1>#{project}</h1>
|
426
|
+
</div>
|
427
|
+
<div class='panel-body'>
|
428
|
+
<h2>Project Description</h2>
|
429
|
+
#{description}
|
430
|
+
</div>
|
431
|
+
</div>
|
432
|
+
</div>
|
433
|
+
<div class='row'>
|
434
|
+
<div class='col-md-4'>
|
435
|
+
<ul class='list-group'>")
|
436
|
+
models.each do |model|
|
437
|
+
link = model.name.downcase
|
438
|
+
name = model.name.capitalize
|
439
|
+
file.write("\t\t<a href='models/#{link}.html' class='list-indexes list-group-item'>#{name}</a>
|
440
|
+
")
|
441
|
+
end
|
442
|
+
file.write("\t</ul>
|
443
|
+
</div>
|
444
|
+
<div class='col-md-4 col-md-offset-2'>
|
445
|
+
<img src='https://lh6.googleusercontent.com/pjGCZHp28gHcczrlPXsXq91al6hGwOkI5r84860enhunQJGbAsmX1w-eXr2_X6M_5bxgajlNgQz6Sy8=w1600-h810' alt='Phari logo' width='100%'>
|
446
|
+
</div>
|
447
|
+
</div>
|
448
|
+
</div>
|
449
|
+
</body>")
|
450
|
+
end
|
451
|
+
|
452
|
+
def writeModelPage(file, model)
|
453
|
+
name = model.name.capitalize
|
454
|
+
file.write("<div class='container panel panel-default'>
|
455
|
+
<div class='row'>
|
456
|
+
<div class='panel panel-default'>
|
457
|
+
<div class='panel-heading'>
|
458
|
+
<h1>PhariSchool</h1>
|
459
|
+
</div>
|
460
|
+
<div class='panel-body'>
|
461
|
+
<h2>#{name} Model</h2>
|
462
|
+
</div>
|
463
|
+
</div>
|
464
|
+
</div>
|
465
|
+
<div class='row'>
|
466
|
+
<div class='col-md-6'>
|
467
|
+
<div class='panel panel-default'>
|
468
|
+
<div class='panel-heading'>
|
469
|
+
<h2>Methods</h2>
|
470
|
+
</div>
|
471
|
+
</div>
|
472
|
+
<ul class='list-group'>")
|
473
|
+
methods = model.methods
|
474
|
+
methods.each do |method|
|
475
|
+
type = method.type
|
476
|
+
name = method.name
|
477
|
+
inputs = method.inputs
|
478
|
+
outputs = method.outputs
|
479
|
+
description = method.description
|
480
|
+
file.write(" <div class='list-group-item'>
|
481
|
+
<h4 class='list-group-item-heading'>#{type} - #{name}</h4>
|
482
|
+
<p><br>Input:<br>
|
483
|
+
<ul>")
|
484
|
+
inputs.each do |input|
|
485
|
+
type = input.type
|
486
|
+
name = input.name
|
487
|
+
file.write("<li>#{type}: #{name}</li>")
|
488
|
+
end
|
489
|
+
file.write("</ul><br>Output:<br>
|
490
|
+
<ul>")
|
491
|
+
outputs.each do |output|
|
492
|
+
if output != 'nil'
|
493
|
+
type = output.type
|
494
|
+
name = output.name
|
495
|
+
file.write("<li>#{type}: #{name}</li>")
|
496
|
+
else
|
497
|
+
file.write('<li>Null</li>')
|
498
|
+
end
|
499
|
+
end
|
500
|
+
file.write("</ul><br>Description: #{description}</p>
|
501
|
+
</div>")
|
502
|
+
end
|
503
|
+
file.write("</ul>
|
504
|
+
</div>
|
505
|
+
<div class='col-md-6'>
|
506
|
+
<div class='panel panel-default'>
|
507
|
+
<div class='panel-heading'>
|
508
|
+
<h2>Routes</h2>
|
509
|
+
</div>
|
510
|
+
</div>
|
511
|
+
<ul class='list-group'>")
|
512
|
+
routes = model.routes
|
513
|
+
routes.each do |route|
|
514
|
+
type = route.type
|
515
|
+
name = route.name
|
516
|
+
request = route.request
|
517
|
+
dataInput = route.dataInput
|
518
|
+
inputs = route.inputs
|
519
|
+
outputs = route.outputs
|
520
|
+
file.write(" <div class='list-group-item'>
|
521
|
+
<h4 class='list-group-item-heading'>Route type #{type} - #{name}</h4>
|
522
|
+
<p><br>Request: #{request}<br>
|
523
|
+
<br>Notation type: #{dataInput}<br>
|
524
|
+
<br>Input:<br>
|
525
|
+
<ul>")
|
526
|
+
inputs.each do |input|
|
527
|
+
type = input.type
|
528
|
+
name = input.name
|
529
|
+
file.write("<li>#{type}: #{name}</li>")
|
530
|
+
end
|
531
|
+
file.write("</ul><br>Output:<br>
|
532
|
+
<ul>")
|
533
|
+
outputs.each do |output|
|
534
|
+
if output != 'nil'
|
535
|
+
type = output.type
|
536
|
+
name = output.name
|
537
|
+
file.write("<li>#{type}: #{name}</li>")
|
538
|
+
else
|
539
|
+
file.write('<li>Null</li>')
|
540
|
+
end
|
541
|
+
end
|
542
|
+
file.write("</ul></p>
|
543
|
+
</div>")
|
544
|
+
end
|
545
|
+
file.write("</ul>
|
546
|
+
</div>
|
547
|
+
</div>
|
548
|
+
</div>
|
549
|
+
</body>")
|
550
|
+
end
|
551
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class MethodParam
|
2
|
+
@name = ''
|
3
|
+
@type = ''
|
4
|
+
|
5
|
+
def initialize(givenName, givenType)
|
6
|
+
@name = givenName
|
7
|
+
@type = givenType
|
8
|
+
end
|
9
|
+
|
10
|
+
def type
|
11
|
+
@type
|
12
|
+
end
|
13
|
+
|
14
|
+
def name
|
15
|
+
@name
|
16
|
+
end
|
17
|
+
|
18
|
+
def printSelf
|
19
|
+
puts"Nome: #{@name}\t\tTipo: #{@type}"
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'MethodParam.rb'
|
2
|
+
|
3
|
+
class Metodo
|
4
|
+
@type = ''
|
5
|
+
@name = ''
|
6
|
+
@inputs = []
|
7
|
+
@outputs = []
|
8
|
+
@description = ''
|
9
|
+
|
10
|
+
def initialize(givenName, givenType, inputList, outputList, givenDescription)
|
11
|
+
@name = givenName
|
12
|
+
@type = givenType
|
13
|
+
@inputs = inputList
|
14
|
+
@outputs = outputList
|
15
|
+
@description = givenDescription
|
16
|
+
end
|
17
|
+
|
18
|
+
def type
|
19
|
+
@type
|
20
|
+
end
|
21
|
+
|
22
|
+
def name
|
23
|
+
@name
|
24
|
+
end
|
25
|
+
|
26
|
+
def inputs
|
27
|
+
@inputs
|
28
|
+
end
|
29
|
+
|
30
|
+
def outputs
|
31
|
+
@outputs
|
32
|
+
end
|
33
|
+
|
34
|
+
def description
|
35
|
+
@description
|
36
|
+
end
|
37
|
+
|
38
|
+
def printSelf
|
39
|
+
puts"\n\nNome: #{@name}Tipo: #{@type}Descrição: #{@description}\nInputs:"
|
40
|
+
@inputs.each(&:printSelf)
|
41
|
+
puts'Outputs:'
|
42
|
+
@outputs.each do |output|
|
43
|
+
if output != 'nil'
|
44
|
+
output.printSelf
|
45
|
+
else puts'nil'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class Modelo
|
2
|
+
@methods = []
|
3
|
+
@routes = []
|
4
|
+
@name = ''
|
5
|
+
|
6
|
+
def initialize(givenName, methodList, routeList)
|
7
|
+
@name = givenName
|
8
|
+
@methods = methodList
|
9
|
+
@routes = routeList
|
10
|
+
end
|
11
|
+
|
12
|
+
def printSelf
|
13
|
+
puts @name.to_s
|
14
|
+
puts "#{@name} methods:"
|
15
|
+
@methods.each(&:printSelf)
|
16
|
+
puts "#{@name} routes:"
|
17
|
+
@routes.each(&:printSelf)
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
@name
|
22
|
+
end
|
23
|
+
|
24
|
+
def methods
|
25
|
+
@methods
|
26
|
+
end
|
27
|
+
|
28
|
+
def routes
|
29
|
+
@routes
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class Rota
|
2
|
+
@type = ''
|
3
|
+
@name = ''
|
4
|
+
@request = ''
|
5
|
+
@dataInput = ''
|
6
|
+
@inputs = []
|
7
|
+
@outputs = []
|
8
|
+
|
9
|
+
def initialize(givenName, givenType, givenRequest, givenDataInput, inputList, outputList)
|
10
|
+
@type = givenType
|
11
|
+
@name = givenName
|
12
|
+
@request = givenRequest
|
13
|
+
@dataInput = givenDataInput
|
14
|
+
@inputs = inputList
|
15
|
+
@outputs = outputList
|
16
|
+
end
|
17
|
+
|
18
|
+
def type
|
19
|
+
@type
|
20
|
+
end
|
21
|
+
|
22
|
+
def name
|
23
|
+
@name
|
24
|
+
end
|
25
|
+
|
26
|
+
def request
|
27
|
+
@request
|
28
|
+
end
|
29
|
+
|
30
|
+
def dataInput
|
31
|
+
@dataInput
|
32
|
+
end
|
33
|
+
|
34
|
+
def inputs
|
35
|
+
@inputs
|
36
|
+
end
|
37
|
+
|
38
|
+
def outputs
|
39
|
+
@outputs
|
40
|
+
end
|
41
|
+
|
42
|
+
def printSelf
|
43
|
+
puts"\n\nNome: #{@name}Tipo: #{@type}\nInputs:"
|
44
|
+
@input.each(&:printSelf)
|
45
|
+
puts'Outputs:'
|
46
|
+
@output.each do |output|
|
47
|
+
if output != 'nil'
|
48
|
+
output.printSelf
|
49
|
+
else puts'nil'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phari_doc_gen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Phari
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A documentation generator gem for projects following sinatra-padrino
|
14
|
+
patterns.
|
15
|
+
email: luizphilippep@gmail.com
|
16
|
+
executables:
|
17
|
+
- generate
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/generate
|
22
|
+
- lib/phari_doc_gen.rb
|
23
|
+
- lib/phari_doc_gen/FileHandler.rb
|
24
|
+
- lib/phari_doc_gen/MethodParam.rb
|
25
|
+
- lib/phari_doc_gen/Metodo.rb
|
26
|
+
- lib/phari_doc_gen/Modelo.rb
|
27
|
+
- lib/phari_doc_gen/Rota.rb
|
28
|
+
homepage: ''
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.5.1
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: 'Main classes: PhariDocGen && PhariDocGen/FileHandler'
|
52
|
+
test_files: []
|