class AcosOpenApiHelper::SidebarMenu

Public Class Methods

all_entries() click to toggle source

attr_accessor :title, :url

# File lib/acos_jekyll_openapi.rb, line 100
def self.all_entries
        @@entries
end
new() click to toggle source
# File lib/acos_jekyll_openapi.rb, line 109
def initialize()
    # @title = title
    # @url = url
    #@@entries << self
end

Public Instance Methods

add(entry) click to toggle source
# File lib/acos_jekyll_openapi.rb, line 104
def add(entry)
    @@entries.push(entry)
end
write(output_path, name, menuTitle) click to toggle source
# File lib/acos_jekyll_openapi.rb, line 115
def write (output_path, name, menuTitle)
    #no spaces in filename ofr sidebar.yml
    name = name.gsub(/\s+|{|}|\/|\+/, "_").downcase
    puts "Name of file %s" % [name]
    _standardLines = [
        "# THIS PAGE IS GENERATED. ANY CHANGES TO PAGE WILL POTENTIALLY BE OVERWRITTEN.",
        "# This is your sidebar TOC. The sidebar code loops through sections here and provides the appropriate formatting.",
        "entries:",
        "- title: sidebar",
        "  # product: Documentation",
        "  # version: 1.0",
        "  folders:",
        "  - title: %s" % menuTitle,
        "    output: web",
        "    type: frontmatter",
        "    folderitems: "
    ]
    puts "Writing menu with length:  %s" % @@entries.length
    @@entries.each do | item | 
            #puts "Entry: %s, url: %s" % [item.title, item.url]
            _standardLines << "    - title: %s" % item.title
            _standardLines << "      url: /%s.html" % item.url
            _standardLines << "      output: web, pdf"
    end

    # _standardLines << "    - title: %s" % "Models"
    # _standardLines << "      url: /%s.html" % "userapi_components"
    # _standardLines << "      output: web, pdf"
    # File.open("%s/%s/%s/%s.%s" % [@basePath, "pages", "swagger", @permalink, "md"], "w+") do |f|
    #     f.puts(@lines)
    #   end
    puts "Writing menu file for %s at %s" % [name, output_path]
    File.open("%s/%s.%s" % [output_path, name, "yml"], "w+") do | f |
        f.puts(_standardLines)
    end

    @@entries.clear
end