Skip to content

Commit a183e96

Browse files
committed
Addressed edge case in comment structure.
1 parent 48a322f commit a183e96

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

lib/rsg_doc.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
module RSGDoc
99
# Version for the roku scenegraph document generator
10-
VERSION = "0.0.1"
10+
VERSION = "0.0.2"
1111
end

lib/rsg_doc/docgen.rb

+14-9
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,18 @@ def parsexml(filename)
110110
# Controls the parsing for the commands
111111
def parsebrs( script, package, parentxmlfile)
112112

113-
# Account for the path being relative, versus using package root
114-
ref_brs_script = File.join(@ROOT_DIR, package, script)
113+
# FUTURE: Account for the path being relative, versus using package root
114+
@ref_brs_script = File.join(@ROOT_DIR, package, script)
115115

116116
# html to be written to the documentation
117117
brs_doc_content = Hash.new
118118
brs_doc_content[:functions] = Array.new
119-
brs_doc_content[:name] = File.basename(ref_brs_script)
119+
brs_doc_content[:name] = File.basename(@ref_brs_script)
120120

121121
begin
122-
lines = IO.readlines(ref_brs_script)
122+
lines = IO.readlines(@ref_brs_script)
123123
rescue Errno::ENOENT
124-
puts "Warn: BrightScript file not found: #{ref_brs_script} Referenced from: #{parentxmlfile}"
124+
puts "Warn: BrightScript file not found: #{@ref_brs_script} Referenced from: #{parentxmlfile}"
125125
return
126126
else
127127
# look through the saved lines for comments to parse
@@ -146,13 +146,13 @@ def parsebrs( script, package, parentxmlfile)
146146
# Document brightscript file
147147
brs_doc_loc = File.join(
148148
@doc_dir,
149-
File.dirname(ref_brs_script).split(@ROOT_DIR)[1],
150-
File.basename(ref_brs_script)
149+
File.dirname(@ref_brs_script).split(@ROOT_DIR)[1],
150+
File.basename(@ref_brs_script)
151151
) << ".html"
152152
brs_file = File.open(brs_doc_loc, "w", 0755)
153153
brs_file.write( template.result(binding) )
154154
brs_file.close
155-
return {:content => brs_doc_content, :file => brs_doc_loc, :ref => ref_brs_script }
155+
return {:content => brs_doc_content, :file => brs_doc_loc, :ref => @ref_brs_script }
156156
end
157157
end
158158

@@ -170,7 +170,12 @@ def parseComments(comments)
170170
break
171171
end
172172
full_comment = /('|(?i:rem))\s*(?<comment>\w.*$)/.match(comments[line_num])
173-
brs_html_content[:description].push( parseDescription(full_comment['comment'] ))
173+
if not full_comment
174+
puts "fatal! Bad comment in file #{@ref_brs_script}"
175+
abort
176+
else
177+
brs_html_content[:description].push( parseDescription(full_comment['comment'] ))
178+
end
174179
line_num += 1
175180
end
176181
brs_html_content[:params] = Array.new

rsg_doc.gemspec

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#********** Copyright 2017 REDspace. All Rights Reserved. **********
2-
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
34
require 'rsg_doc'
45

56
Gem::Specification.new do |s|

0 commit comments

Comments
 (0)