# Reference: linux.die.net/man/5/pandoc_markdown

if version

> % {{ full_name.to_hyphen }}(1) Version {{ version }} | {{ summary }}

else

> % {{ full_name.to_hyphen }}(1) | {{ summary }}

end

> % {{ x_mandoc_authors&.for_manpage }} > % {{ Date.today.strftime “%B %Y” }} >

> NAME > ================================================== > > **{{ full_name }}** - {{ summary }} >

> SYNOPSIS > ================================================== > > {{ usage_string.gsub(/^#{full_name}/, “**#{full_name}**”) }} >

> DESCRIPTION > ================================================== > > {{ help.for_manpage }} >

if default

> - *Default Command*

end if alt.any?

> - Alias: **{{ alt.join ', ' }}**

end if extensible

if extensible.is_a? String
  > - Extensible: **{{ extensible }}**
else
  > - *Extensible*
end

end >

if visible_commands.any?

grouped_commands.each do |group, commands|
  > {{ group.gsub(/:$/, '').upcase }}
  > ==================================================
  >
  commands.each do |subcommand|
    > {{ subcommand.full_name }}
    > --------------------------------------------------
    >
    > {{ subcommand.summary.for_manpage }}
    >
  end
  >
end

end

if args.any?

> ARGUMENTS
> ==================================================
> 
args.each do |arg|
  > {{ arg.name.upcase }}
  > --------------------------------------------------
  >
  > {{ arg.help.for_manpage }}
  >
  if arg.required
    > - *Required*
  end
  if arg.repeatable
    > - *Repeatable*
  end
  if arg.default
    > - Default Value: **{{ arg.default }}**
  end
  if arg.allowed
    > - Allowed Values: **{{ arg.allowed.join(', ') }}**
  end    
  >
end

if catch_all.label && catch_all.help
  > {{ catch_all.label }}
  > --------------------------------------------------
  >
  if catch_all.help
    > {{ catch_all.help.for_manpage }}
    >
  end
  >

  if catch_all.required?
    > - *Required*
    >
  end
end

end

if flags.any?

> OPTIONS
> ==================================================
> 
flags.each do |flag|
  > {{ flag.usage_string }}
  > --------------------------------------------------
  >
  > {{ flag.help.for_manpage }}
  >

  if flag.required
    > - *Required*
  end
  if flag.repeatable
    > - *Repeatable*
  end
  if flag.default
    > - Default Value: **{{ flag.default }}**
  end
  if flag.allowed
    > - Allowed Values: **{{ flag.allowed.join(', ') }}**
  end
  if flag.conflicts
    > - Conflicts With: **{{ flag.conflicts.join(', ') }}**
  end
  if flag.needs
    > - Needs: **{{ flag.needs.join(', ') }}**
  end
  >
end

end

if dependencies.any?

> DEPENDENCIES
> ==================================================
>
dependencies.each do |dependency|
  > {{ dependency.commands.join ', ' }}
  > --------------------------------------------------
  >
  if dependency.help
    > {{ dependency.help.for_manpage }}
    >
  end
  >
end

end

if visible_environment_variables.any?

> ENVIRONMENT VARIABLES
> ==================================================
>
visible_environment_variables.each do |environment_variable|
  > {{ environment_variable.name.upcase }}
  > --------------------------------------------------
  >
  > {{ environment_variable.help.for_manpage }}
  >

  if environment_variable.required
    > - *Required*
  end
  if environment_variable.default
    > - Default Value: **{{ environment_variable.default }}**
  end
  >
end

end

if examples

> EXAMPLES
> ==================================================
>
> ~~~
examples.each do |example|
  > {{ example.for_manpage }}
  >
end
> ~~~
>

end

see_also = [] see_also << parents.first if parents.any? see_also += visible_commands.map { |x| x.full_name.to_hyphen } if visible_commands.any? see_also += x_mandoc_see_also if x_mandoc_see_also && x_mandoc_see_also.is_a?(Array) see_also.map! do |item|

item.match(/(.+)(\(\d\))/) ? "**#{$1}**#{$2}" : "**#{item}**(1)"

end

if see_also.any?

> SEE ALSO
> ==================================================
>
= see_also.join ', '
>

end

x_mandoc_footer&.for_manpage

>