phari_doc_gen 2.1.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/phari_doc_gen +1 -2
- data/lib/phari_doc_gen.rb +1 -1
- data/lib/phari_doc_gen/FileHandler.rb +176 -154
- data/lib/phari_doc_gen/MethodParam.rb +31 -10
- metadata +29 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06152ff667c5bad361dcb49f7b6b231412085756
|
4
|
+
data.tar.gz: 87836418be3a511c0b5c2ff51c73bf3f2e5070dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9417a4c37cecc2b2559b28c9eb944288c8cf39932b4f9a928b91375a6d87b4245215bdba0c7a1e187f873c6ca654612caf028a4bc77220d00e1cc46cc7a3c3a4
|
7
|
+
data.tar.gz: bc9d64040b03b4c3a45dc10e8136d912b14615890ca5a9603e06b6818d95f0f6b94dfc1151f63ca24b43ff26659619ff2f628893cc1f9bccd04374b1dbe5257a
|
data/bin/phari_doc_gen
CHANGED
data/lib/phari_doc_gen.rb
CHANGED
@@ -14,7 +14,7 @@ require_relative 'phari_doc_gen/FileHandler.rb'
|
|
14
14
|
|
15
15
|
class PhariDocGen
|
16
16
|
# Generate documentation for standard projects
|
17
|
-
def generate (project, outputPath)
|
17
|
+
def self.generate (project, outputPath)
|
18
18
|
generate = FileHandler.new
|
19
19
|
# Ask for project name if nil
|
20
20
|
if project.nil?
|
@@ -5,8 +5,6 @@
|
|
5
5
|
# Luiz Philippe.
|
6
6
|
#--------------------------------------------------------------------------------------------
|
7
7
|
|
8
|
-
require 'fileutils'
|
9
|
-
require 'active_support/inflector'
|
10
8
|
require_relative 'Modelo.rb'
|
11
9
|
require_relative 'Rota.rb'
|
12
10
|
require_relative 'Metodo.rb'
|
@@ -44,8 +42,13 @@ class FileHandler
|
|
44
42
|
projectDescription = readProjectDescription(readme)
|
45
43
|
readme.close
|
46
44
|
projectDescription
|
45
|
+
elsif File.exists?(path + 'readme.md')
|
46
|
+
readme = File.new(path + 'readme.md')
|
47
|
+
projectDescription = readProjectDescription(readme)
|
48
|
+
readme.close
|
49
|
+
projectDescription
|
47
50
|
else
|
48
|
-
puts 'Warning: No
|
51
|
+
puts 'Warning: No readme.md file found.'
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
@@ -232,56 +235,56 @@ class FileHandler
|
|
232
235
|
tipo = ''
|
233
236
|
nome = ''
|
234
237
|
descricao = ''
|
235
|
-
inputs =
|
236
|
-
outputs =
|
238
|
+
inputs = {}
|
239
|
+
outputs = {}
|
237
240
|
methods = []
|
238
241
|
toSent = true
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
else
|
266
|
-
toSent = true
|
267
|
-
end
|
268
|
-
nome = argument
|
269
|
-
when 'param'
|
270
|
-
data = dataValue(argument)
|
271
|
-
inputs << data
|
272
|
-
when 'return'
|
273
|
-
data = dataValue(argument)
|
274
|
-
outputs << data
|
242
|
+
arr = IO.readlines(helper)
|
243
|
+
# Read each line from helper
|
244
|
+
arr.each do |line|
|
245
|
+
lineIndex += 1
|
246
|
+
begin
|
247
|
+
# Verify if it has a clause
|
248
|
+
if hasKeyword?(line, lineIndex, helpername)
|
249
|
+
# If it does, identify which clause it is
|
250
|
+
arg = decodeArgument(line)
|
251
|
+
keyword = arg[0]
|
252
|
+
argument = arg[1]
|
253
|
+
# Execute clause
|
254
|
+
case keyword
|
255
|
+
when 'methods'
|
256
|
+
if nome != ''
|
257
|
+
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
258
|
+
inputs = {}
|
259
|
+
outputs = {}
|
260
|
+
toSent = false
|
261
|
+
end
|
262
|
+
tipo = argument
|
263
|
+
when 'name'
|
264
|
+
if nome != '' && toSent
|
265
|
+
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
266
|
+
inputs = {}
|
267
|
+
outputs = {}
|
275
268
|
else
|
276
|
-
|
277
|
-
puts "Warning: in #{helpername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
269
|
+
toSent = true
|
278
270
|
end
|
271
|
+
nome = argument
|
272
|
+
when 'param'
|
273
|
+
data = dataValue(argument, inputs)
|
274
|
+
inputs["#{data.name}"] = data unless data.isChild
|
275
|
+
when 'return'
|
276
|
+
data = dataValue(argument, outputs)
|
277
|
+
outputs["#{data.name}"] = data unless data.isChild
|
278
|
+
else
|
279
|
+
# If a possible syntax error is found, a warning is sent informing file and linne
|
280
|
+
puts "Warning: in #{helpername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
279
281
|
end
|
280
|
-
descricao = decodeDescription(line) if hasDescription?(line, lineIndex, helpername)
|
281
282
|
end
|
282
|
-
|
283
|
-
|
284
|
-
|
283
|
+
descricao = decodeDescription(line) if hasDescription?(line, lineIndex, helpername)
|
284
|
+
rescue ArgumentError => e
|
285
|
+
# If a syntax error is found, it raises an Argument Error informing the file and line
|
286
|
+
puts "Warning: #{helpername}:#{lineIndex}: in #{nome} " + e.message
|
287
|
+
end
|
285
288
|
end
|
286
289
|
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
287
290
|
# Return a methods array
|
@@ -295,88 +298,88 @@ class FileHandler
|
|
295
298
|
requisicao = ''
|
296
299
|
dataInput = ''
|
297
300
|
nome = ''
|
298
|
-
inputs =
|
299
|
-
outputs =
|
301
|
+
inputs = {}
|
302
|
+
outputs = {}
|
300
303
|
routes = []
|
301
304
|
toSent = true
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
305
|
+
arr = IO.readlines(controller)
|
306
|
+
# Read each line from controller
|
307
|
+
arr.each do |line|
|
308
|
+
begin
|
309
|
+
lineIndex += 1
|
310
|
+
# Skip to next line if no clause is found
|
311
|
+
next unless hasKeyword?(line, lineIndex, controllername)
|
312
|
+
# If it has any clause, identify which one it is
|
313
|
+
arg = decodeArgument(line)
|
314
|
+
keyword = arg[0]
|
315
|
+
argument = arg[1]
|
316
|
+
case keyword
|
317
|
+
# Then execute clause
|
318
|
+
when 'route'
|
319
|
+
if nome != ''
|
320
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
321
|
+
inputs = {}
|
322
|
+
outputs = {}
|
323
|
+
toSent = false
|
324
|
+
end
|
325
|
+
tipo = argument
|
326
|
+
when 'POST'
|
327
|
+
if nome != '' && toSent
|
328
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
329
|
+
inputs = {}
|
330
|
+
outputs = {}
|
331
|
+
else
|
332
|
+
toSent = true
|
333
|
+
end
|
334
|
+
requisicao = keyword
|
335
|
+
dataInput = argument
|
336
|
+
when 'GET'
|
337
|
+
if nome != '' && toSent
|
338
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
339
|
+
inputs = {}
|
340
|
+
outputs = {}
|
341
|
+
else
|
342
|
+
toSent = true
|
343
|
+
end
|
344
|
+
requisicao = keyword
|
345
|
+
dataInput = argument
|
346
|
+
when 'PUT'
|
347
|
+
if nome != '' && toSent
|
348
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
349
|
+
inputs = {}
|
350
|
+
outputs = {}
|
351
|
+
else
|
352
|
+
toSent = true
|
353
|
+
end
|
354
|
+
requisicao = keyword
|
355
|
+
dataInput = argument
|
356
|
+
when 'DELETE'
|
357
|
+
if nome != '' && toSent
|
358
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
359
|
+
inputs = {}
|
360
|
+
outputs = {}
|
361
|
+
else
|
362
|
+
toSent = true
|
363
|
+
end
|
364
|
+
requisicao = keyword
|
365
|
+
dataInput = argument
|
366
|
+
when 'name'
|
367
|
+
nome = argument
|
368
|
+
when 'param'
|
369
|
+
data = dataValue(argument, inputs)
|
370
|
+
inputs["#{data.name}"] = data unless data.isChild
|
371
|
+
when 'return'
|
372
|
+
data = dataValue(argument, outputs)
|
373
|
+
outputs["#{data.name}"] = data unless data.isChild
|
374
|
+
else
|
375
|
+
# If a possible syntax error is found, a warning is sent informing file and linne
|
376
|
+
# (Here in the namespace comparison, i'm doing a little mcgyver)
|
377
|
+
puts "Warning: in #{controllername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
378
|
+
end
|
379
|
+
rescue ArgumentError => e
|
380
|
+
# If a syntax error is found, it raises an Argument Error informing the file and line
|
381
|
+
puts "Warning: #{controllername}:#{lineIndex}: in #{nome} " + e.message
|
376
382
|
end
|
377
|
-
rescue ArgumentError => e
|
378
|
-
# If a syntax error is found, it raises an Argument Error informing the file and line
|
379
|
-
puts "Warning: #{controllername}:#{lineIndex}: in #{nome} " + e.message
|
380
383
|
end
|
381
384
|
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
382
385
|
# Return a routes array
|
@@ -401,7 +404,7 @@ class FileHandler
|
|
401
404
|
return false
|
402
405
|
end
|
403
406
|
end
|
404
|
-
# Return true if it
|
407
|
+
# Return true if it does
|
405
408
|
true
|
406
409
|
else
|
407
410
|
# And false if it don't
|
@@ -462,18 +465,45 @@ class FileHandler
|
|
462
465
|
end
|
463
466
|
|
464
467
|
# If the clause is a param or return value, decode the name and datatype
|
465
|
-
def dataValue(argument)
|
468
|
+
def dataValue(argument, objects)
|
466
469
|
if argument.include? "\s"
|
470
|
+
notNull = true
|
471
|
+
isObject = false
|
472
|
+
isCollection = false
|
473
|
+
isChild = false
|
467
474
|
name = argument.slice(0, argument.index("\s"))
|
475
|
+
if name.end_with?('?')
|
476
|
+
notNull = false
|
477
|
+
name = name.slice(0, name.index('?'))
|
478
|
+
end
|
468
479
|
type = argument.slice(argument.index("\s") + 1, argument.size - 2)
|
469
|
-
|
480
|
+
if type.include? "\s"
|
481
|
+
example = type.slice(type.index("\s")+1, type.size-1-type.index("\s"))
|
482
|
+
type = type.slice(0, type.index("\s"))
|
483
|
+
end
|
484
|
+
type = type.slice(0, type.size-1) if type.end_with?("\s") || type.end_with?("\n")
|
485
|
+
isObject = true if type.downcase == "object"
|
486
|
+
if name.include?(">")
|
487
|
+
isChild = true
|
488
|
+
path = []
|
489
|
+
while name.include?(">")
|
490
|
+
prefix = name.slice(0, name.index(">"))
|
491
|
+
name = name.slice(name.index(">")+1, name.size-(name.index(">")+1))
|
492
|
+
path << prefix
|
493
|
+
end
|
494
|
+
fatherObject = nil
|
495
|
+
path.each do |object|
|
496
|
+
raise ArgumentError, "Object #{object} does not exists!" unless objects.has_key?(object) && objects["#{object}"].isObject
|
497
|
+
fatherObject = objects["#{object}"]
|
498
|
+
objects = fatherObject.childAttributes
|
499
|
+
end
|
500
|
+
end
|
501
|
+
data = MethodParam.new(name, type, notNull, isObject, isChild, example)
|
502
|
+
fatherObject.addField data unless fatherObject.nil?
|
470
503
|
# Return the data
|
471
504
|
return data
|
472
505
|
elsif argument.include? "nil"
|
473
|
-
data = MethodParam.new('', 'nil')
|
474
|
-
return data
|
475
|
-
elsif argument.include? "boolean"
|
476
|
-
data = MethodParam.new('', 'boolen')
|
506
|
+
data = MethodParam.new('', 'nil', nil, nil, nil, nil)
|
477
507
|
return data
|
478
508
|
end
|
479
509
|
argumentText = argument.slice(0, argument.index("\n"))
|
@@ -669,25 +699,21 @@ class FileHandler
|
|
669
699
|
inputs = method.inputs
|
670
700
|
outputs = method.outputs
|
671
701
|
description = method.description
|
672
|
-
file.write("
|
702
|
+
file.write(" <div class='list-group-item'>
|
673
703
|
<h4 class='list-group-item-heading'>CRUD: #{type}<br>Name: #{name}</h4>
|
674
|
-
<p><br>Inputs:<br>
|
675
|
-
<ul>")
|
704
|
+
<p><br>Inputs:<br><ul>")
|
676
705
|
unless inputs.nil?
|
677
706
|
inputs.each do |input|
|
678
|
-
|
679
|
-
|
680
|
-
file.write("<li>#{type}: #{name}</li>")
|
707
|
+
input = input[1]
|
708
|
+
file.write("<li>#{input.serialize}</li>")
|
681
709
|
end
|
682
710
|
end
|
683
|
-
file.write("</ul><br>Outputs:<br>
|
684
|
-
<ul>")
|
711
|
+
file.write("</ul><br>Outputs:<br><ul>")
|
685
712
|
unless outputs.nil?
|
686
713
|
outputs.each do |output|
|
714
|
+
output = output[1]
|
687
715
|
if output != 'nil'
|
688
|
-
|
689
|
-
name = output.name
|
690
|
-
file.write("<li>#{type}: #{name}</li>")
|
716
|
+
file.write("<li>#{output.serialize}</li>")
|
691
717
|
else
|
692
718
|
file.write('<li>Null</li>')
|
693
719
|
end
|
@@ -718,23 +744,19 @@ class FileHandler
|
|
718
744
|
<h4 class='list-group-item-heading'>CRUD: #{type}<br>Name: #{name}</h4>
|
719
745
|
<p><br>Request: #{request}<br>
|
720
746
|
<br>Notation type: #{dataInput}<br>
|
721
|
-
<br>Inputs:<br>
|
722
|
-
<ul>")
|
747
|
+
<br>Inputs:<br><ul>")
|
723
748
|
unless inputs.nil?
|
724
749
|
inputs.each do |input|
|
725
|
-
|
726
|
-
|
727
|
-
file.write("<li>#{type}: #{name}</li>")
|
750
|
+
input = input[1]
|
751
|
+
file.write("<li>#{input.serialize}</li>")
|
728
752
|
end
|
729
753
|
end
|
730
|
-
file.write("</ul><br>Outputs:<br>
|
731
|
-
<ul>")
|
754
|
+
file.write("</ul><br>Outputs:<br><ul>")
|
732
755
|
unless outputs.nil?
|
733
756
|
outputs.each do |output|
|
757
|
+
output = output[1]
|
734
758
|
if output != 'nil'
|
735
|
-
|
736
|
-
name = output.name
|
737
|
-
file.write("<li>#{type}: #{name}</li>")
|
759
|
+
file.write("<li>#{output.serialize}</li>")
|
738
760
|
else
|
739
761
|
file.write('<li>Null</li>')
|
740
762
|
end
|
@@ -6,23 +6,44 @@
|
|
6
6
|
#--------------------------------------------------------------------------------------------
|
7
7
|
|
8
8
|
class MethodParam
|
9
|
-
|
10
|
-
@type = ''
|
9
|
+
attr_accessor :name, :type, :notNull, :isObject, :isChild, :example, :childAttributes, :serial
|
11
10
|
|
12
|
-
def initialize(
|
13
|
-
@name =
|
14
|
-
@type =
|
11
|
+
def initialize(name = "", type = "", notNull = true, isObject = false, isChild = false, example = nil)
|
12
|
+
@name = name
|
13
|
+
@type = type
|
14
|
+
@notNull = notNull
|
15
|
+
@isObject = isObject
|
16
|
+
@isChild = isChild
|
17
|
+
@example = example
|
18
|
+
@childAttributes = {} if @isObject
|
19
|
+
@serial = self.serialize
|
15
20
|
end
|
16
21
|
|
17
|
-
def
|
18
|
-
@
|
22
|
+
def addField attribute
|
23
|
+
@childAttributes["#{attribute.name}"] = attribute
|
24
|
+
@serial = self.serialize
|
19
25
|
end
|
20
26
|
|
21
|
-
def
|
22
|
-
@
|
27
|
+
def serialize
|
28
|
+
if @type == 'nil'
|
29
|
+
serialized = "Null"
|
30
|
+
elsif @isObject
|
31
|
+
serialized = "#{@name}: {<br><ul>"
|
32
|
+
@childAttributes.each do |attribute|
|
33
|
+
serialized = serialized + "<li>#{attribute[1].serial}</li>"
|
34
|
+
end
|
35
|
+
serialized = serialized + "</ul>}"
|
36
|
+
else
|
37
|
+
unless @example.nil?
|
38
|
+
serialized = "#{@name}: #{@example}"
|
39
|
+
else
|
40
|
+
serialized = "#{@name}: #{@type}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
serialized
|
23
44
|
end
|
24
45
|
|
25
46
|
def printSelf
|
26
|
-
|
47
|
+
puts self.serialize
|
27
48
|
end
|
28
49
|
end
|
metadata
CHANGED
@@ -1,28 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phari_doc_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phari Solutions
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.1'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.1.4
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.1'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.1.4
|
13
33
|
description: |2-
|
14
|
-
Hi there
|
15
|
-
and functional documentation generator for
|
16
|
-
|
34
|
+
Hi there, friend! PhariDoc Generator is a simple
|
35
|
+
and functional documentation generator for Ruby web aps.
|
36
|
+
PhariDoc Generator will provide you an easy way
|
17
37
|
to generate documentation for your projects. The result
|
18
38
|
will be a project page with a description that can be written using a simplified
|
19
|
-
markdown syntax
|
39
|
+
markdown syntax. Also, each ruby
|
20
40
|
Class will have it's own page especifying it's relatios helper methods and controller
|
21
41
|
routes including their inputs, outputs and descriptions. The gem includes
|
22
42
|
an executable file and the classes that can be used individually,
|
23
43
|
providing the possibility to use the generator for any project
|
24
44
|
structure.
|
25
|
-
email:
|
45
|
+
email: luiz@phari.solutions
|
26
46
|
executables:
|
27
47
|
- phari_doc_gen
|
28
48
|
extensions: []
|
@@ -35,7 +55,7 @@ files:
|
|
35
55
|
- lib/phari_doc_gen/Metodo.rb
|
36
56
|
- lib/phari_doc_gen/Modelo.rb
|
37
57
|
- lib/phari_doc_gen/Rota.rb
|
38
|
-
homepage:
|
58
|
+
homepage: https://gitlab.com/LuizPPA/PhariDocGen
|
39
59
|
licenses:
|
40
60
|
- Beerware
|
41
61
|
metadata: {}
|