# File lib/asciidoctor/document.rb, line 1135
  def docinfo location = :head, suffix = nil
    if safe >= SafeMode::SECURE
      ''
    else
      content = []
      qualifier = %(-#{location}) unless location == :head
      suffix = @outfilesuffix unless suffix

      if (docinfo = @attributes['docinfo']).nil_or_empty?
        if @attributes.key? 'docinfo2'
          docinfo = ['private', 'shared']
        elsif @attributes.key? 'docinfo1'
          docinfo = ['shared']
        else
          docinfo = docinfo ? ['private'] : nil
        end
      else
        docinfo = docinfo.split(',').map {|it| it.strip }
      end

      if docinfo
        docinfo_file, docinfo_dir, docinfo_subs = %(docinfo#{qualifier}#{suffix}), @attributes['docinfodir'], resolve_docinfo_subs
        unless (docinfo & ['shared', %(shared-#{location})]).empty?
          docinfo_path = normalize_system_path docinfo_file, docinfo_dir
          # NOTE normalizing the lines is essential if we're performing substitutions
          if (shd_content = (read_asset docinfo_path, :normalize => true))
            content << (apply_subs shd_content, docinfo_subs)
          end
        end

        unless @attributes['docname'].nil_or_empty? || (docinfo & ['private', %(private-#{location})]).empty?
          docinfo_path = normalize_system_path %(#{@attributes['docname']}-#{docinfo_file}), docinfo_dir
          # NOTE normalizing the lines is essential if we're performing substitutions
          if (pvt_content = (read_asset docinfo_path, :normalize => true))
            content << (apply_subs pvt_content, docinfo_subs)
          end
        end
      end

      # TODO allow document to control whether extension docinfo is contributed
      if @extensions && (docinfo_processors? location)
        content += @docinfo_processor_extensions[location].map {|ext| ext.process_method[self] }.compact
      end

      content * LF
    end
  end