Skip to content

Commit 3515d6a

Browse files
committed
get rid of line breaks in AutoDoc
1 parent 304425b commit 3515d6a

File tree

2 files changed

+174
-383
lines changed

2 files changed

+174
-383
lines changed

examples/generate_phpdoc.rb

+13-48
Original file line numberDiff line numberDiff line change
@@ -51,36 +51,6 @@ def to_php
5151
end
5252
end
5353

54-
# we need to wrap output at 80 columns ... this output class keeps text as an
55-
# array of strings, starting a new one if the thing we append would take the
56-
# last line over @line_length
57-
class Output
58-
def initialize(start_prefix = " * ",
59-
cont_prefix = " * ",
60-
line_length = 80)
61-
@line_length = line_length
62-
@start_prefix = start_prefix
63-
@cont_prefix = cont_prefix
64-
@lines = []
65-
@current_line = @start_prefix
66-
end
67-
68-
def add(txt)
69-
if @current_line.length + txt.length > @line_length - 1
70-
@lines << @current_line
71-
@current_line = @cont_prefix
72-
end
73-
74-
# we could attempt to break txt, but for now assume it'll be under 80
75-
@current_line += txt
76-
end
77-
78-
def get
79-
@lines << @current_line if @current_line.length > 0
80-
@lines.join("\n")
81-
end
82-
end
83-
8454
def generate_operation(op)
8555
flags = op.flags
8656
return if (flags & :deprecated) != 0
@@ -135,29 +105,26 @@ def generate_operation(op)
135105
required_input.delete member_x
136106
end
137107

138-
out = Output.new
139-
out.add "@method "
140-
out.add "static " if not member_x
108+
print " * @method "
109+
print "static " if not member_x
141110
if required_output.length == 0
142-
out.add "void "
111+
print "void "
143112
elsif required_output.length == 1
144-
out.add "#{required_output[0].to_php} "
113+
print "#{required_output[0].to_php} "
145114
elsif
146-
out.add "array("
147-
out.add required_output.map(&:to_php).join(", ")
148-
out.add ") "
115+
print "array("
116+
print required_output.map(&:to_php).join(", ")
117+
print ") "
149118
end
150119

151-
out.add "#{nickname}("
120+
print "#{nickname}("
152121

153122
required_input.each do |arg|
154-
out.add "#{arg.to_php} $#{arg.name}, "
123+
print "#{arg.to_php} $#{arg.name}, "
155124
end
156-
out.add "array $options = []) "
157-
158-
out.add "#{op.description.capitalize}."
125+
print "array $options = []) "
159126

160-
puts out.get
127+
puts "#{op.description.capitalize}."
161128
end
162129

163130
def generate_class(gtype)
@@ -238,10 +205,8 @@ def generate_class(gtype)
238205

239206
# extract_area is in there twice, once as "crop" ... do them by hand
240207
puts <<EOF
241-
* @method Image extract_area(integer $left, integer $top, integer $width,
242-
* integer $height, array $options = []) Extract an area from an image.
243-
* @method Image crop(integer $left, integer $top, integer $width,
244-
* integer $height, array $options = []) Extract an area from an image.
208+
* @method Image extract_area(integer $left, integer $top, integer $width, integer $height, array $options = []) Extract an area from an image.
209+
* @method Image crop(integer $left, integer $top, integer $width, integer $height, array $options = []) Extract an area from an image.
245210
*/
246211
class AutoDocs
247212
{

0 commit comments

Comments
 (0)