jekyll-version-docs 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 04f1fddddd249527b6e62b5ee7b22ede906a95f0949c338aa13457d5137b5879
4
+ data.tar.gz: cfff8af486963a9c9b67a44c9025331385b5ca9c40f11872dd81f22af06c2e82
5
+ SHA512:
6
+ metadata.gz: b9de75c2a83f34f77d2673f397befecde70ad4fa31509b81f5e4fae678efaa26c5b79741791956ec468e240361b2ebc7ed05e86ae4811a4fb006d71a69bd693a
7
+ data.tar.gz: 857f2d6186b557ecd6c4434ec2cd35a85211ebd7c32037b08203c71359f28fd8d67c57d5c62cff26cd09bc6ba95e0ae454911f1792dad24fb8896c3d386da0ae
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at reinangabriel1520@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jekyll-version-docs.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 ReinanHS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Jekyll::Version::Docs
2
+
3
+ > :warning: Please note that this plugin is **NOT** supported by GitHub pages. Here is a [list of all plugins supported](https://pages.github.com/versions/). However you can follow [this GitHub guide](https://help.github.com/articles/adding-jekyll-plugins-to-a-github-pages-site/) to enable it or by using [Travis CI](https://ayastreb.me/deploy-jekyll-to-github-pages-with-travis-ci/). GitLab supposedly supports [any plugin](https://about.gitlab.com/comparison/gitlab-pages-vs-github-pages.html).
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/version/docs`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ This gem was made specifically for Jekyll 3 or higher. This plugin aims to facilitate the documentation of projects with multiple versions
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'jekyll-version-docs'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install jekyll-version-docs
24
+
25
+ ## Usage
26
+
27
+ The main commands of this plugin are:
28
+
29
+ `bundle exec jekyll vdoc <VERSION>`
30
+
31
+ Creates a version to be used as documentation
32
+
33
+ See the main tags:
34
+
35
+ - `{% doc_version %}` Shows the latest version
36
+ - `{% doc_versions %}` Shows all versions
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/reinanhs/jekyll-version-docs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/reinanhs/jekyll-version-docs/blob/master/CODE_OF_CONDUCT.md).
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the Jekyll::Version::Docs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/reinanhs/jekyll-version-docs/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/version/docs"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ require_relative 'lib/jekyll/version/docs/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "jekyll-version-docs"
5
+ spec.version = Jekyll::Version::Docs::VERSION
6
+ spec.authors = ["ReinanHS"]
7
+ spec.email = ["reinangabriel1520@gmail.com"]
8
+
9
+ spec.summary = "Control your documentation"
10
+ spec.description = "Provides your documentation with a version control system"
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,111 @@
1
+ require 'kramdown'
2
+ module Jekyll
3
+ class PageWithoutAFile < Page
4
+ def read_yaml(*)
5
+ @data ||= {}
6
+ end
7
+ end
8
+ class PageBuildDocs < Page
9
+ def initialize(site, base, dir, filename, version)
10
+ @site = site
11
+ @base = base
12
+ @dir = dir
13
+ @name = 'index.html'
14
+
15
+ self.process(@name)
16
+ self.read_yaml(File.join(base, "_docs/#{version}"), filename)
17
+
18
+ self.content = Kramdown::Document.new(self.content).to_html
19
+ end
20
+ end
21
+ class BuildDoc < Generator
22
+ safe true
23
+ priority :lowest
24
+
25
+ # Main plugin action, called by Jekyll-core
26
+ def generate(site)
27
+ return Jekyll.logger.warn "\tJekyll Version Doc: The basic structure for the plugin's operation was not found" if !File.directory?("#{Dir.pwd}/_docs/")
28
+
29
+ @site = site
30
+
31
+ path = "#{Dir.pwd}/_docs/*"
32
+ Dir[path].each do |filename|
33
+ Jekyll.logger.info "\tSource: #{filename}"
34
+
35
+ version = self.getFileVersion(filename)
36
+ summaryFile = "#{filename}/Summary.md"
37
+ summaryList = []
38
+
39
+ if File.exists? summaryFile
40
+ summaryList = self.extractInformation(summaryFile, version)
41
+ else
42
+ summaryList = self.extractInformationDir(filename, version)
43
+ end
44
+
45
+ filePath = "#{Dir.pwd}/_site/docs/#{version}"
46
+ FileUtils.mkpath(filePath) unless File.exists?(filePath)
47
+
48
+
49
+ summary_json = PageWithoutAFile.new(site, site.source, "/docs/#{version}", "summary.json")
50
+ summary_json.content = summaryList.to_json
51
+ site.pages << summary_json
52
+
53
+ page = Jekyll::PageBuildDocs.new(site, site.source, "/docs/#{version}/", "#{summaryList[0].values[0]}.md", version)
54
+ page.data["sitemap"] = false
55
+ site.pages << page
56
+ end
57
+ end
58
+
59
+ def extractInformation(filename, version)
60
+ summaryList = []
61
+ summary = File.read(filename).split('-')
62
+ summary.each do |string|
63
+ title = string[(string.index("[").to_i)+1..(string.index("]").to_i)-1]
64
+ link = string[(string.index("(").to_i)+1..(string.index(")").to_i)-1]
65
+ link.to_s.sub! '.md', ''
66
+ link.to_s.sub! './', ''
67
+ # Link without the need for JavaScript
68
+ # link = self.getUrl("/docs/#{version}/#{link}")
69
+ if !title.nil?
70
+ summaryList.push({ title: title, link: link })
71
+ end
72
+ end
73
+
74
+ return summaryList
75
+ end
76
+
77
+ def extractInformationDir(dir, version)
78
+ summaryList = []
79
+ summary = Dir["#{dir}/*.md"]
80
+ summary.each do |filename|
81
+ filename = filename.split('/').last()
82
+ title = filename.to_s.sub! '.md', ''
83
+ link = filename
84
+ # Link without the need for JavaScript
85
+ # link = self.getUrl("/docs/#{version}/#{link}")
86
+ if !title.nil? && title != 'Summary.md'
87
+ summaryList.push({ title: title, link: link })
88
+ end
89
+ end
90
+
91
+ return summaryList
92
+ end
93
+
94
+ def getFileVersion(filename)
95
+ version = filename.split('/')
96
+ return version[(version.length-1)]
97
+ end
98
+
99
+ def getLastVersion
100
+ path = "#{Dir.pwd}/_docs/*"
101
+ return Dir[path].last().to_s.split("/").last()
102
+ end
103
+
104
+ def getUrl(input)
105
+ return if input.nil?
106
+ return Addressable::URI.parse(
107
+ @site.config["url"].to_s + @site.config["baseurl"] + input
108
+ ).normalize.to_s
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,69 @@
1
+ require 'fileutils'
2
+
3
+ module Jekyll
4
+ module Commands
5
+ class VDoc < Command
6
+ class << self
7
+ def init_with_program(prog)
8
+ prog.command(:vdoc) do |c|
9
+
10
+ c.syntax "vdoc VERSION"
11
+ c.description "Create a new version for the documentation"
12
+
13
+ c.action do |args, options|
14
+ if args.length != 1
15
+ Jekyll.logger.error "You entered the command with invalid parameters, See example: jekyll vdoc 1.0"
16
+ else
17
+ lastVersion = self.getLestVersion.to_s.split("/").last()
18
+ newVersion = args[0] ? args[0] : '0.0.1'
19
+ if !self.checkIncompatibility(lastVersion, newVersion)
20
+ self.createVersion(newVersion)
21
+ Jekyll.logger.info "Version #{newVersion} was successfully created"
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ def getLestVersion
29
+
30
+ path = "#{Dir.pwd}/_docs"
31
+
32
+ if !File.directory?(path)
33
+ Dir.mkdir(path) unless Dir.exist?(path)
34
+ end
35
+
36
+ return Dir["#{path}/*"].last()
37
+ end
38
+
39
+ def createVersion(newVersion)
40
+ lastVersion_dir = Dir["#{self.getLestVersion}/*.md"]
41
+ path = "#{Dir.pwd}/_docs/#{newVersion.to_s}"
42
+
43
+ if !File.directory?(path)
44
+ Dir.mkdir(path) unless Dir.exist?(path)
45
+ end
46
+
47
+ lastVersion_dir.each do |filename|
48
+ name = File.basename('filename', '.md')[0,4]
49
+ dest_folder = "#{path}/"
50
+ FileUtils.cp(filename, dest_folder)
51
+ end
52
+ end
53
+
54
+ def checkIncompatibility(lastVersion, newVersion)
55
+ path = "#{Dir.pwd}/_docs"
56
+
57
+ raise ArgumentError.new("A version already exists at #{path}/#{newVersion}") if(lastVersion == newVersion)
58
+
59
+ versions = Dir["#{path}/*"]
60
+ result = versions.find {|item| item == "#{path}/#{newVersion}" }
61
+
62
+ raise ArgumentError.new("A version already exists at #{path}/#{newVersion}") if(result)
63
+
64
+ return false
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,14 @@
1
+ require "jekyll/version/docs/version"
2
+
3
+ module Jekyll
4
+ module Version
5
+ module Docs
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
9
+ end
10
+ end
11
+
12
+ require "jekyll/version/commands/vdoc"
13
+ require "jekyll/version/build/build-doc"
14
+ require "jekyll/version/tags/render-last-version"
@@ -0,0 +1,7 @@
1
+ module Jekyll
2
+ module Version
3
+ module Docs
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,38 @@
1
+ module Jekyll
2
+ class RenderLastVersion < Liquid::Tag
3
+
4
+ def initialize(tag_name, text, tokens)
5
+ super
6
+ path = "#{Dir.pwd}/_docs/*"
7
+ @lastVersion = Dir[path].last().to_s.split("/").last()
8
+ end
9
+
10
+ def render(context)
11
+ "#{@lastVersion}"
12
+ end
13
+ end
14
+
15
+ class RenderVersions < Liquid::Tag
16
+
17
+ include Jekyll::Filters::URLFilters
18
+
19
+ def initialize(tag_name, text, tokens)
20
+ super
21
+ path = "#{Dir.pwd}/_docs/*"
22
+ @versions = Dir[path]
23
+ end
24
+
25
+ def render(context)
26
+ list = ''
27
+ @versions.each do |filename|
28
+ version = filename.to_s.split("/").last()
29
+ list = list + '<a class="dropdown-item" href="'+version+'">'+"#{version}"+'</a>'
30
+ end
31
+
32
+ return list
33
+ end
34
+ end
35
+ end
36
+
37
+ Liquid::Template.register_tag('doc_version', Jekyll::RenderLastVersion)
38
+ Liquid::Template.register_tag('doc_versions', Jekyll::RenderVersions)
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-version-docs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ReinanHS
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides your documentation with a version control system
14
+ email:
15
+ - reinangabriel1520@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - CODE_OF_CONDUCT.md
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - bin/console
27
+ - bin/setup
28
+ - jekyll-version-docs.gemspec
29
+ - lib/jekyll/version/build/build-doc.rb
30
+ - lib/jekyll/version/commands/vdoc.rb
31
+ - lib/jekyll/version/docs.rb
32
+ - lib/jekyll/version/docs/version.rb
33
+ - lib/jekyll/version/tags/render-last-version.rb
34
+ homepage: ''
35
+ licenses:
36
+ - MIT
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.3.0
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubygems_version: 3.0.6
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: Control your documentation
57
+ test_files: []