<commit_before>module RTFM
  class ManPage < Struct.new(:name, :section, :date, :summary, :synopsis, :description, :authors)
    class << self
      def text_section(*args)
        args.each do |sect|
          class_eval %Q{
            def #{sect}
              @#{sect} ||= TextSection.new(:#{sect}, "")
            end
            def #{sect}=(str)
              @#{sect} = TextSection.new(:#{sect}, str)
            end
          }
        end
      end
      alias_method :text_sections, :text_section
      
      def add_section(name, klass)
        klass = klass.to_s.intern
        class_eval %Q{
          def #{name}
            @#{name} ||= #{klass}.new
            yield @#{name} if block_given?
            @#{name}
          end
        }
      end
      
    end
    
    text_section :bugs, :diagnostics, :compatibility, :standards, :history
    add_section :see_also, SeeAlsoSection
    add_section :description, DescriptionSection
    add_section :authors, AuthorsSection
    
    def initialize(name, section=nil)
      self.name, self.section = name, section
      self.date = DateTime.now
      self.synopsis = nil
      yield self
    end

    
    def to_groff
      GroffString.groffify do |out|
        out.Dd date.strftime("%B %d, %Y")
        out.Os
        out.Dt name, (section || "")
        out.section "NAME"
        out.Nm name
        out.Nd summary
        out.section "SYNOPSIS"
        out << synopsis if synopsis
        out << @description.to_groff if @description
        out << @see_also.to_groff if @see_also
        out << @history.to_groff if @history
        out << @authors.to_groff if @authors
        out << @bugs.to_groff if @bugs
      end<commit_msg>Simplified output of full manfile<commit_after>module RTFM
  class ManPage < Struct.new(:name, :section, :date, :summary, :synopsis, :description, :authors)
    class << self
      def text_section(*args)
        args.each do |sect|
          class_eval %Q{
            def #{sect}
              @#{sect} ||= TextSection.new(:#{sect}, "")
            end
            def #{sect}=(str)
              @#{sect} = TextSection.new(:#{sect}, str)
            end
          }
        end
      end
      alias_method :text_sections, :text_section
      
      def add_section(name, klass)
        klass = klass.to_s.intern
        class_eval %Q{
          def #{name}
            @#{name} ||= #{klass}.new
            yield @#{name} if block_given?
            @#{name}
          end
        }
      end
      
    end
    
    text_section :bugs, :diagnostics, :compatibility, :standards, :history
    add_section :see_also, SeeAlsoSection
    add_section :description, DescriptionSection
    add_section :authors, AuthorsSection
    
    def initialize(name, section=nil)
      self.name, self.section = name, section
      self.date = DateTime.now
      self.synopsis = nil
      yield self
    end

    
    def to_groff
      GroffString.groffify do |out|
        out.Dd date.strftime("%B %d, %Y")
        out.Os
        out.Dt name, (section || "")
        out.section "NAME"
        out.Nm name
        out.Nd summary
        out.section "SYNOPSIS"
        out << synopsis if synopsis
        [@description, @see_also, @history, @authors, @bugs].each do |sect|
          out << sect.to_groff if sect
        end
      end
{'fraction_non_alphanumeric': 0.1125150421179302, 'fraction_numerical': 0.0, 'mean_word_length': 1.8035413153456998, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5730865', 'n_tokens_mistral': 1026, 'n_tokens_neox': 1022, 'n_words': 255}