phari_doc_gen 3.1.1 → 3.2.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.
- checksums.yaml +4 -4
- data/lib/phari_doc_gen/fileHandler.rb +88 -65
- metadata +5 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3d7a71d5f3a2b43164e8a80a7bfa06793ae636e
|
4
|
+
data.tar.gz: f531970846e40cae729f8a16d9ef6e443149bd60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a5d52a2627facdac5066513b7af36fb14b01b1382ac7c26b3014da7b1585f01a9abf15730650e0120151ab7ed77db12665a1b1bb98542858dfc897d4e2aeb7c
|
7
|
+
data.tar.gz: 851f7993034c0f848a4564202d55139c1a546ef75ddb0f67588c1ceda38460e1510e95736c9b980e655c6d2da4146102d24e8cd2b7931b7c9cb1468d15679845
|
@@ -16,12 +16,8 @@ class FileHandler
|
|
16
16
|
# Reading files
|
17
17
|
# Find a folder with the project name
|
18
18
|
def packageExistis?(packageName)
|
19
|
-
found = false
|
20
|
-
puts'Finding project'
|
21
|
-
puts'It may take some time...'
|
22
19
|
packageName += '/' unless packageName.end_with?('/')
|
23
|
-
|
24
|
-
if found
|
20
|
+
if Dir.exists?(packageName)
|
25
21
|
# Return the folder path if found
|
26
22
|
return packageName
|
27
23
|
else
|
@@ -115,8 +111,10 @@ class FileHandler
|
|
115
111
|
arr.each do |line|
|
116
112
|
# Read markdown syntax and trasform into HTML tags
|
117
113
|
next if line.start_with?('# ') || line.start_with?('#!shell')
|
118
|
-
line = '<
|
119
|
-
line = '<
|
114
|
+
line = '<h1>' + line.slice(2, line.length - 2) + '</h1>' if line.start_with?('# ')
|
115
|
+
line = '<h2>' + line.slice(3, line.length - 3) + '</h2>' if line.start_with?('## ')
|
116
|
+
line = '<h3>' + line.slice(4, line.length - 4) + '</h3>' if line.start_with?('### ')
|
117
|
+
line = '<h4>' + line.slice(5, line.length - 5) + '</h4>' if line.start_with?('#### ')
|
120
118
|
line = '<h5>' + line.slice(6, line.length - 6) + '</h5>' if line.start_with?('##### ')
|
121
119
|
line = '<li>' + line.slice(2, line.length - 2) + '</li>' if line.start_with?('* ')
|
122
120
|
line = higlightText(line) while hasBetween?(line, '**', '**')
|
@@ -269,10 +267,8 @@ class FileHandler
|
|
269
267
|
nome = argument
|
270
268
|
when 'param'
|
271
269
|
data = dataValue(argument, inputs)
|
272
|
-
inputs["#{data.name}"] = data unless data.isChild
|
273
270
|
when 'return'
|
274
271
|
data = dataValue(argument, outputs)
|
275
|
-
outputs["#{data.name}"] = data unless data.isChild
|
276
272
|
else
|
277
273
|
# If a possible syntax error is found, a warning is sent informing file and linne
|
278
274
|
puts "Warning: in #{helpername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
@@ -365,10 +361,8 @@ class FileHandler
|
|
365
361
|
nome = argument
|
366
362
|
when 'param'
|
367
363
|
data = dataValue(argument, inputs)
|
368
|
-
inputs["#{data.name}"] = data unless data.isChild
|
369
364
|
when 'return'
|
370
365
|
data = dataValue(argument, outputs)
|
371
|
-
outputs["#{data.name}"] = data unless data.isChild
|
372
366
|
else
|
373
367
|
# If a possible syntax error is found, a warning is sent informing file and linne
|
374
368
|
# (Here in the namespace comparison, i'm doing a little mcgyver)
|
@@ -443,8 +437,8 @@ class FileHandler
|
|
443
437
|
raise ArgumentError.new("Sytanx error: expected 2 arguments (none given)") unless hasSomething?(sentence)
|
444
438
|
raise ArgumentError.new("Sytanx error: expected 2 arguments (one given)") unless sentence.include?("\s")
|
445
439
|
finalIndex = line.index("\s", line.index('@'))
|
446
|
-
|
447
|
-
keyword = line.slice(initialIndex,
|
440
|
+
length = finalIndex - initialIndex
|
441
|
+
keyword = line.slice(initialIndex, length)
|
448
442
|
argument = line.slice(finalIndex + 1, line.size - finalIndex)
|
449
443
|
raise ArgumentError.new("Sytanx error: expected 2 arguments (one given)") unless hasSomething?(argument)
|
450
444
|
args << keyword
|
@@ -462,66 +456,97 @@ class FileHandler
|
|
462
456
|
false
|
463
457
|
end
|
464
458
|
|
459
|
+
def clear str
|
460
|
+
firstIndex = 0
|
461
|
+
lastIndex = str.length
|
462
|
+
for i in 0..str.length-1
|
463
|
+
if str[i].match(/^[[:alpha:]]$/)
|
464
|
+
lastIndex = i + 1
|
465
|
+
end
|
466
|
+
end
|
467
|
+
str = str.slice(0, lastIndex)
|
468
|
+
for i in 0..str.length-1
|
469
|
+
if str[i].match(/^[[:alpha:]]$/)
|
470
|
+
firstIndex = i - 1
|
471
|
+
break
|
472
|
+
end
|
473
|
+
end
|
474
|
+
str = str.slice(firstIndex + 1, str.length - firstIndex)
|
475
|
+
str
|
476
|
+
end
|
477
|
+
|
465
478
|
# If the clause is a param or return value, decode the name and datatype
|
466
479
|
def dataValue(argument, objects)
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
name = name.slice(name.index(">")+1, name.size-(name.index(">")+1))
|
492
|
-
path << prefix
|
480
|
+
args = []
|
481
|
+
while argument.include? ','
|
482
|
+
raise ArgumentError, 'Unexpected ","' unless hasSomething?(argument)
|
483
|
+
args << argument.slice(0, argument.index(','))
|
484
|
+
argument = argument.slice(argument.index(',') + 1, argument.length - argument.index(','))
|
485
|
+
argument = clear(argument)
|
486
|
+
end
|
487
|
+
argument = clear(argument)
|
488
|
+
args << argument
|
489
|
+
args.each do |arg|
|
490
|
+
if arg.include? "\s"
|
491
|
+
notNull = true
|
492
|
+
isObject = false
|
493
|
+
isCollection = false
|
494
|
+
isChild = false
|
495
|
+
name = arg.slice(0, arg.index("\s"))
|
496
|
+
if name.end_with?('?')
|
497
|
+
notNull = false
|
498
|
+
name = name.slice(0, name.index('?'))
|
499
|
+
end
|
500
|
+
type = arg.slice(arg.index("\s") + 1, arg.size - 2)
|
501
|
+
if type.include? "\s"
|
502
|
+
example = type.slice(type.index("\s")+1, type.size-1-type.index("\s"))
|
503
|
+
type = type.slice(0, type.index("\s"))
|
493
504
|
end
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
505
|
+
type = type.slice(0, type.size-1) if type.end_with?("\s") || type.end_with?("\n")
|
506
|
+
isObject = type.downcase == "object"
|
507
|
+
isCollection = type.downcase == "array"
|
508
|
+
# Inserting attributes inside objects
|
509
|
+
if name.include?(">")
|
510
|
+
isChild = true
|
511
|
+
path = []
|
512
|
+
while name.include?(">")
|
513
|
+
prefix = name.slice(0, name.index(">"))
|
514
|
+
name = name.slice(name.index(">")+1, name.size-(name.index(">")+1))
|
515
|
+
path << prefix
|
516
|
+
end
|
517
|
+
fatherObject = nil
|
518
|
+
children = objects
|
519
|
+
path.each do |object|
|
520
|
+
if (fatherObject.nil? || fatherObject.isObject)
|
521
|
+
raise ArgumentError, "Object #{object} does not exists!" unless children.has_key?(object) && (children["#{object}"].isObject || children["#{object}"].isCollection)
|
522
|
+
fatherObject = children["#{object}"]
|
523
|
+
elsif (fatherObject.isCollection)
|
524
|
+
raise ArgumentError, "Object #{object} is not a position of #{fatherObject.name}!" unless (children["content"].isObject || children["content"].isCollection)
|
525
|
+
fatherObject = children["content"]
|
526
|
+
end
|
527
|
+
children = fatherObject.childAttributes
|
502
528
|
end
|
503
|
-
objects = fatherObject.childAttributes
|
504
529
|
end
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
530
|
+
data = MethodParam.new(name, type, notNull, isObject, isCollection, isChild, example)
|
531
|
+
fatherObject.addField data unless (fatherObject.nil? || fatherObject.isCollection)
|
532
|
+
fatherObject.setContent data unless (fatherObject.nil? || fatherObject.isObject)
|
533
|
+
# Return the data
|
534
|
+
objects["#{data.name}"] = data unless data.isChild
|
535
|
+
elsif arg.include? "nil"
|
536
|
+
data = MethodParam.new('', 'nil', false, false, false, false, nil)
|
537
|
+
objects["#{data.name}"] = data unless data.isChild
|
538
|
+
else
|
539
|
+
# If any information is missing or incorrect, raises an Argument Error
|
540
|
+
raise ArgumentError.new("Syntax error: #{arg} is no data")
|
541
|
+
end
|
514
542
|
end
|
515
|
-
argumentText = argument.slice(0, argument.index("\n"))
|
516
|
-
# If any information is missing or incorrect, raises an Argument Error
|
517
|
-
raise ArgumentError.new("Sytanx error: #{argumentText} is no data")
|
518
543
|
end
|
519
544
|
|
520
545
|
# Decode the text from a description clause
|
521
546
|
def decodeDescription(line)
|
522
547
|
initialIndex = line.index('*') + 3
|
523
|
-
|
524
|
-
description = line.slice(initialIndex,
|
548
|
+
length = line.size - initialIndex
|
549
|
+
description = line.slice(initialIndex, length)
|
525
550
|
# Return the description text
|
526
551
|
description
|
527
552
|
end
|
@@ -594,9 +619,7 @@ class FileHandler
|
|
594
619
|
def gem_libdir
|
595
620
|
t = ["#{File.dirname(File.expand_path($0))}/../lib/#{Meta::NAME}",
|
596
621
|
"#{Gem.dir}/gems/#{Meta::NAME}-#{Meta::VERSION}/lib/#{Meta::NAME}"]
|
597
|
-
t.each
|
598
|
-
return i if File.readable?(i)
|
599
|
-
end
|
622
|
+
t.each {|i| return i if File.readable?(i) }
|
600
623
|
raise "both paths are invalid: #{t}"
|
601
624
|
end
|
602
625
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phari_doc_gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phari Solutions
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -65,18 +65,8 @@ dependencies:
|
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '2.7'
|
68
|
-
description:
|
69
|
-
|
70
|
-
and functional documentation generator for Ruby web aps.
|
71
|
-
PhariDoc Generator will provide you an easy way
|
72
|
-
to generate documentation for your projects. The result
|
73
|
-
will be a project page with a description that can be written using a simplified
|
74
|
-
markdown syntax. Also, each ruby
|
75
|
-
Class will have it's own page especifying it's relatios helper methods and controller
|
76
|
-
routes including their inputs, outputs and descriptions. The gem includes
|
77
|
-
an executable file and the classes that can be used individually,
|
78
|
-
providing the possibility to use the generator for any project
|
79
|
-
structure.
|
68
|
+
description: Phari Doc Generator provides an easy way to generate project documentation
|
69
|
+
for sinatra/padrino file structure patterns.
|
80
70
|
email: luiz@phari.solutions
|
81
71
|
executables:
|
82
72
|
- phari_doc_gen
|
@@ -94,7 +84,7 @@ files:
|
|
94
84
|
- lib/phari_doc_gen/templates/model.html.erb
|
95
85
|
- lib/phari_doc_gen/templates/project.html.erb
|
96
86
|
- lib/phari_doc_gen/templates/style.css
|
97
|
-
homepage: https://
|
87
|
+
homepage: https://github.com/PhariSolutions/Phari-Doc-Gen
|
98
88
|
licenses:
|
99
89
|
- Beerware
|
100
90
|
metadata: {}
|