aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/current/manpage.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/current/manpage.rb')
-rw-r--r--lib/sisu/current/manpage.rb103
1 files changed, 26 insertions, 77 deletions
diff --git a/lib/sisu/current/manpage.rb b/lib/sisu/current/manpage.rb
index fb5a1f3c..f297db55 100644
--- a/lib/sisu/current/manpage.rb
+++ b/lib/sisu/current/manpage.rb
@@ -63,10 +63,13 @@ 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_output' # txt_output.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 +80,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 +101,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 +133,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(/(^| |#{Mx[:nbsp]}|\s|\*)\\\*/,'\1\\\\\*'). #man page requires
@@ -219,19 +199,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 +219,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
@@ -380,49 +360,18 @@ WOK
else SiSU_Env::InfoDate.new.year #date missing decide on action
end
proj=SiSU_Env::InfoVersion.instance.get_version
- manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj[:version]}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}}
+ manpage[:open] = %{.TH "#{@md.fnb}" "#{@md.make.manpage['section']}" "#{date}" "#{proj.version}" "#{@md.title.main}"#{@md.make.manpage['name']}#{@md.make.manpage['synopsis']}}
content << manpage[:open]
content << manpage[:head]
content << manpage[:body]
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__