aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/develop/manpage.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-11-20 22:44:43 -0500
committerRalph Amissah <ralph@amissah.com>2014-12-08 00:18:15 -0500
commite0fcd082741e964c3564bc2be3e4c775deb99f00 (patch)
treea25932f40a96c734fbe61a36bc146e6b9cef4400 /lib/sisu/develop/manpage.rb
parentd: ao, rearrange, introduce new file (diff)
d: txt outputs, reorganize, introduce new files
Diffstat (limited to 'lib/sisu/develop/manpage.rb')
-rw-r--r--lib/sisu/develop/manpage.rb100
1 files changed, 24 insertions, 76 deletions
diff --git a/lib/sisu/develop/manpage.rb b/lib/sisu/develop/manpage.rb
index 2d46a229..75d4c360 100644
--- a/lib/sisu/develop/manpage.rb
+++ b/lib/sisu/develop/manpage.rb
@@ -63,10 +63,12 @@ module SiSU_Manpage
include SiSU_ManpageFormat
require_relative 'shared_metadata' # shared_metadata.rb
require_relative 'generic_parts' # generic_parts.rb
+ require_relative 'txt_read' # txt_read.rb
require_relative 'txt_shared' # txt_shared.rb
- @@alt_id_count,@@alt_id_count,@@tablehead,@@number_of_cols=0,0,0,0
+ @@alt_id_count,@@alt_id_count=0,0
@@tablefoot=''
class Source
+ include SiSU_Txt_Read
def initialize(opt)
@opt=opt
if @opt.fns =~/(.+?)\.(?:-|ssm\.)?sst$/
@@ -77,37 +79,14 @@ module SiSU_Manpage
end
def read
begin
- @md=SiSU_Param::Parameters.new(@opt).get
- @env=SiSU_Env::InfoEnv.new(@opt.fns)
- tool=(@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- ? "#{@env.program.text_editor} #{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}"
- : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
- (@opt.act[:verbose][:set]==:on \
- || @opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on) \
- && @opt.act[:quiet][:set]==:on \
- ? SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Manpage',
- tool
- ).green_hi_blue
- : SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- 'Manpage',
- tool
- ).green_title_hi
- if (@opt.act[:verbose_plus][:set]==:on \
- || @opt.act[:maintenance][:set]==:on)
- SiSU_Screen::Ansi.new(
- @opt.act[:color_state][:set],
- @opt.fns,
- "#{@md.file.output_path.manpage.dir}/#{@md.file.base_filename.manpage}"
- ).flow
- end
- @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here
- SiSU_Manpage::Source::Scroll.new(@md,@ao_array).songsheet
+ md=SiSU_Param::Parameters.new(@opt).get
+ specific={
+ description: 'Manpage',
+ output_path: md.file.output_path.manpage.dir,
+ output_file: md.file.base_filename.manpage,
+ }
+ read_generic(@opt,specific)
+ SiSU_Manpage::Source::Scroll.new(md,@ao_array,@wrap_width).songsheet
rescue
SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
__LINE__.to_s + ':' + __FILE__
@@ -121,8 +100,8 @@ module SiSU_Manpage
include SiSU_Parts_Generic
include SiSU_TextUtils
@@endnotes={ para: [], end: [] }
- def initialize(md,data)
- @md,@data=md,data
+ def initialize(md,data,wrap_width)
+ @md,@data,@wrap_width=md,data,wrap_width
@tab="\t"
@@notes=:end
@manpage={ body: [], open: [], close: [], head: [], metadata: [], tail: [], endnotes: [] }
@@ -153,8 +132,8 @@ module SiSU_Manpage
notes=@n.flatten
notes.each do |e|
util=(e.to_s =~/^\[[\d*+]+\]:/) \
- ? (SiSU_TextUtils::Wrap.new(e.to_s,78,4,1))
- : (SiSU_TextUtils::Wrap.new(e.to_s,78,0,1))
+ ? (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,4,1))
+ : (SiSU_TextUtils::Wrap.new(e.to_s,@wrap_width,0,1))
wrap=util.line_wrap
wrap=if wrap =~ /^\s*[\d*+]+\s+.+?\s*\Z/m
wrap.gsub(/(^|&nbsp;|#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires
@@ -219,19 +198,19 @@ WOK
if dob.indent =~/[1-9]/ \
and dob.indent == dob.hang
util=if dob.bullet_
- SiSU_TextUtils::Wrap.new("* #{paragraph}",78,dob.indent.to_i*2)
- else SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2)
+ SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,dob.indent.to_i*2)
+ else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
end
elsif dob.hang =~/[0-9]/ \
and dob.indent != dob.hang # NOT yet implemented
- util=SiSU_TextUtils::Wrap.new(paragraph,78,dob.indent.to_i*2)
+ util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,dob.indent.to_i*2)
else
util=if dob.bullet_
- SiSU_TextUtils::Wrap.new("* #{paragraph}",78,0)
- else SiSU_TextUtils::Wrap.new(paragraph,78,0)
+ SiSU_TextUtils::Wrap.new("* #{paragraph}",@wrap_width,0)
+ else SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
end
end
- else util=SiSU_TextUtils::Wrap.new(paragraph,78,0)
+ else util=SiSU_TextUtils::Wrap.new(paragraph,@wrap_width,0)
end
w=util.line_wrap
w=w.gsub(/^(\\\.)/,' \1')
@@ -239,7 +218,7 @@ WOK
end
if lv
times=wrapped.length
- times=78 if times > 78
+ times=@wrap_width if times > @wrap_width
@manpage[:body] << case lv
when 0 then '.SH ' << wrapped.upcase << break_line << break_line
when 1..3 then '.SH ' << wrapped.upcase << break_line << break_line
@@ -387,42 +366,11 @@ WOK
content << @@endnotes[:end] if @@notes==:end
content << manpage[:metadata]
content << manpage[:tail]
- Output.new(@md,content).manpage
+ outputfile=SiSU_Env::FileOp.new(@md).write_file.manpage
+ Txt_Output::Output.new.document(content,outputfile)
@@endnotes={ para: [], end: [] }
end
end
- class Output <Source
- include SiSU_Param
- include SiSU_Env
- def initialize(md,content)
- @md,@content=md,content
- end
- def manpage #%manpage output
- SiSU_Env::FileOp.new(@md).mkdir
- filename_manpage=SiSU_Env::FileOp.new(@md).write_file.manpage
- @sisu=[]
- emptyline=0
- @content.each do |para| # this is a hack
- if para.is_a?(Array) \
- and para.length > 0
- para.each do |line|
- if line
- line=line.gsub(/[ \t]+$/m,'').
- gsub(/^\A[ ]*\Z/m,'')
- (line=~/^\A\Z/) \
- ? (emptyline+=1)
- : emptyline=0
- if emptyline < 2 #remove additional empty lines
- filename_manpage.puts line #unix manpage
- end
- end
- end
- else filename_manpage.puts para #unix manpage # /^([*=-]|\.){5}/
- end
- end
- filename_manpage.close
- end
- end
end
end
__END__