Class: Jekyll::BuildDoc
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::BuildDoc
- Defined in:
- lib/jekyll/version/build/build-doc.rb
Instance Method Summary collapse
- #extractInformation(filename, version) ⇒ Object
- #extractInformationDir(dir, version) ⇒ Object
-
#generate(site) ⇒ Object
Main plugin action, called by Jekyll-core.
- #getFileVersion(filename) ⇒ Object
- #getLastVersion ⇒ Object
- #getUrl(input) ⇒ Object
Instance Method Details
#extractInformation(filename, version) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/jekyll/version/build/build-doc.rb', line 59 def extractInformation(filename, version) summaryList = [] summary = File.read(filename).split('-') summary.each do |string| title = string[(string.index("[").to_i)+1..(string.index("]").to_i)-1] link = string[(string.index("(").to_i)+1..(string.index(")").to_i)-1] link.to_s.sub! '.md', '' link.to_s.sub! './', '' # Link without the need for JavaScript # link = self.getUrl("/docs/#{version}/#{link}") if !title.nil? summaryList.push({ title: title, link: link }) end end return summaryList end |
#extractInformationDir(dir, version) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/jekyll/version/build/build-doc.rb', line 77 def extractInformationDir(dir, version) summaryList = [] summary = Dir["#{dir}/*.md"] summary.each do |filename| filename = filename.split('/').last() title = filename.to_s.sub! '.md', '' link = filename # Link without the need for JavaScript # link = self.getUrl("/docs/#{version}/#{link}") if !title.nil? && title != 'Summary.md' summaryList.push({ title: title, link: link }) end end return summaryList end |
#generate(site) ⇒ Object
Main plugin action, called by Jekyll-core
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/jekyll/version/build/build-doc.rb', line 26 def generate(site) return Jekyll.logger.warn "\tJekyll Version Doc: The basic structure for the plugin's operation was not found" if !File.directory?("#{Dir.pwd}/_docs/") @site = site path = "#{Dir.pwd}/_docs/*" Dir[path].each do |filename| Jekyll.logger.info "\tSource: #{filename}" version = self.getFileVersion(filename) summaryFile = "#{filename}/Summary.md" summaryList = [] if File.exists? summaryFile summaryList = self.extractInformation(summaryFile, version) else summaryList = self.extractInformationDir(filename, version) end filePath = "#{Dir.pwd}/_site/docs/#{version}" FileUtils.mkpath(filePath) unless File.exists?(filePath) summary_json = PageWithoutAFile.new(site, site.source, "/docs/#{version}", "summary.json") summary_json.content = summaryList.to_json site.pages << summary_json page = Jekyll::PageBuildDocs.new(site, site.source, "/docs/#{version}/", "#{summaryList[0].values[0]}.md", version) page.data["sitemap"] = false site.pages << page end end |
#getFileVersion(filename) ⇒ Object
94 95 96 97 |
# File 'lib/jekyll/version/build/build-doc.rb', line 94 def getFileVersion(filename) version = filename.split('/') return version[(version.length-1)] end |
#getLastVersion ⇒ Object
99 100 101 102 |
# File 'lib/jekyll/version/build/build-doc.rb', line 99 def getLastVersion path = "#{Dir.pwd}/_docs/*" return Dir[path].last().to_s.split("/").last() end |
#getUrl(input) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/jekyll/version/build/build-doc.rb', line 104 def getUrl(input) return if input.nil? return Addressable::URI.parse( @site.config["url"].to_s + @site.config["baseurl"] + input ).normalize.to_s end |