Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-docs/pull/20#discussion_r55659068
  
    --- Diff: _plugins/page_structure.rb ---
    @@ -0,0 +1,220 @@
    +#
    +# Adds a liquid tag to build a page on the contents of the folder it's in
    +# 
    +# Pulls in files in the format <Number>_<title>.md in the order of version 
number. Ignores files not in this format.
    +#
    +
    +require 'rubygems'
    +require 'yaml'
    +require "kramdown"
    +
    +module PageStructureUtils
    +  
    +  class ChildPage
    +    def initialize(yaml, content)
    +      @yaml=yaml
    +      @content=content
    +    end
    +    attr_accessor :yaml
    +    attr_accessor :content
    +    def to_s # called with print / puts
    +      "YAML : #{@yaml}" #, Content : #{@content}"
    +    end
    +
    +    ##
    +    # Sort a list of children by their YAML containing section positions. 
Do this with Gem:Version
    +    #
    +    #
    +    def self.sortBySectionPositions(yaml)
    +      
    +      $major = "1"
    +      $minor = 1
    +      # first check all the child pages are numbered, if not, number them 
in the order they are
    +      yaml.each do |i|
    +        if i.yaml['section_position'] == nil
    +          i.yaml['section_position'] = $major+"."+$minor.to_s
    +          $minor += 1
    +        else
    +          # Store any major, start incrementing minor
    +          $major = i.yaml['section_position'].to_s
    +          $minor = 1
    +        end
    +      end
    +      
    +      # return the comparison between the versions
    +      yaml.sort{ |x,y| Gem::Version.new(x.yaml['section_position'].to_s) 
<=> Gem::Version.new(y.yaml['section_position'].to_s) }
    +    end
    +    ##
    --- End diff --
    
    Very minor: would prefer a blank link between previous def and the 
following TomDoc section.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to