Platinum Partner

POD - Plain Old Documentation


#!/usr/bin/env tt
# Author::    Daniel Brumbaugh Keeney (http://rubyforge.org/users/db-keen)
# Copyright:: 2008 Daniel Brumbaugh Keeney
# License::   GPLv3+
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see .

grammar Pod

  rule podfile
    ignored_stuff
    paragraph+
  end

  rule pod_content
    directive+
  end

  rule command_paragraph
    '=' (
      head_directive /
      item_directive /
      alternate_content_directive /
      cut_directive /
      over_directive /
      pod_directive
    ) "\n"
  end

  rule pod_directive
    'pod' ( space ( !newline_sequence . )* )? newline_sequence blank_line+
    
  end

  rule over_directive
    content:(paragraph+) '=back'
    
  end


  rule cut_directive
    'cut' ignored_stuff
    
  end

  rule ignored_stuff
    ( !command_paragraph ( !newline_sequence . )* newline_sequence? )*
    
  end

  rule item_directive
    'item' space+ liststyle:( !space . )+ space+ content:( !newline_sequence . )+
  end

  rule head_directive
    'head' [1234] space content:( !newline_sequence . )+
  end

  rule alternate_content_directive
    'begin' space+ format:( !newline_sequence . )+ newline_sequence
    content:( !"=end" . )+
    '=end' space+ format_again:( !newline_sequence . )+
  end

  rule inline_formatting
    uppercase_letter '<'
    (
      content:( !'>' . )+ /
      thickly_wrapped_inline_formatting
    ) '>'
  end

  # This rule is not in compliance with spec. The actual pod
  # specification cannot be implemented in Treetop. Luckily, I wrote
  # a rule in ruby to replace this one.
  rule thickly_wrapped_inline_formatting
    '<' (
      space content:( !( space+ ">>" ) . )+ space+ /
      thickly_wrapped_inline_formatting
    ) '>'
  end

  rule paragraph
    verbatim_paragraph /
    command_paragraph /
    ordinary_paragraph
  end

  rule ordinary_paragraph
    !space
    !( '=' [a-zA-Z] )
    non_blank_line+
    blank_line+
    
  end

  rule verbatim_paragraph
    [ \t]
    non_blank_line+
    blank_line+
    
  end

  rule data_paragraph
    non_blank_line+
    blank_line+
    
  end

  rule uppercase_letter
    [ABCDEFGHIJKLMNOPQRSTUVWXYZ]
  end

  rule space
    [\t ]
  end

  rule newline_sequence
    "\r\n" / [\n\r]
  end

  rule blank_line
    space* ( !. / newline_sequence )
  end

  rule non_blank_line
    space* ( !newline_sequence . )+ ( !. / newline_sequence )
  end

end

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}