diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..18acbfa --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "bundler" + directory: "/" + schedule: + interval: "weekly" + reviewers: + - toshimaru + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + reviewers: + - toshimaru diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf76132..752b140 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,24 +1,27 @@ name: CI -on: [push] +on: [push, pull_request] jobs: build: strategy: matrix: ruby: [2.4, 2.5, 2.6, 2.7] gemfile: - - gemfiles/jekyll_4.0.gemfile - - gemfiles/jekyll_3.8.gemfile - - gemfiles/jekyll_3.7.gemfile + - gemfiles/jekyll_3.8.gemfile + - gemfiles/jekyll_3.9.gemfile + - gemfiles/jekyll_4.0.gemfile + - gemfiles/jekyll_4.1.gemfile exclude: - ruby: 2.4 gemfile: gemfiles/jekyll_4.0.gemfile + - ruby: 2.4 + gemfile: gemfiles/jekyll_4.1.gemfile env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} - uses: eregon/use-ruby-action@master + uses: actions/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4d676d7..7f88491 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,5 +1,5 @@ name: Coverage -on: [push] +on: [push, pull_request] jobs: build: strategy: @@ -10,12 +10,12 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} - uses: eregon/use-ruby-action@master + uses: actions/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install run: bundle install --jobs 4 --retry 3 - - uses: paambaati/codeclimate-action@v2.4.0 + - uses: paambaati/codeclimate-action@v2.7.4 env: CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07 with: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 75338b2..41d32df 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -1,5 +1,5 @@ name: RuboCop -on: [push] +on: [push, pull_request] jobs: build: strategy: @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} - uses: eregon/use-ruby-action@master + uses: actions/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install diff --git a/.rubocop.yml b/.rubocop.yml index 523762b..53b5802 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,34 +1,48 @@ AllCops: TargetRubyVersion: 2.4 + NewCops: enable Exclude: - "*.gemspec" - "gemfiles/*" + - "vendor/**/*" - Rakefile - Gemfile +require: + - rubocop-performance + - rubocop-minitest Metrics/MethodLength: Enabled: false - Metrics/AbcSize: Enabled: false - Metrics/ClassLength: Enabled: false -Style/WordArray: - Enabled: false - Naming/FileName: Enabled: false +Naming/VariableNumber: + Enabled: false Layout/LineLength: Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: true -Style/HashEachMethods: +Lint/RaiseException: + Enabled: true +Lint/StructNewOverride: Enabled: true +Style/WordArray: + Enabled: false +Style/HashEachMethods: + Enabled: true Style/HashTransformKeys: Enabled: true - Style/HashTransformValues: Enabled: true +Style/ExponentialNotation: + Enabled: true + +Performance/StringInclude: + Enabled: false diff --git a/.whitesource b/.whitesource new file mode 100644 index 0000000..e0aaa3e --- /dev/null +++ b/.whitesource @@ -0,0 +1,8 @@ +{ + "checkRunSettings": { + "vulnerableCheckRunConclusionLevel": "failure" + }, + "issueSettings": { + "minSeverityLevel": "LOW" + } +} \ No newline at end of file diff --git a/Appraisals b/Appraisals index b84be41..54cf478 100644 --- a/Appraisals +++ b/Appraisals @@ -1,13 +1,9 @@ # frozen_string_literal: true -appraise 'jekyll-4.0' do - gem 'jekyll', '4.0' -end - -appraise 'jekyll-3.8' do - gem 'jekyll', '3.8' -end +SUPPORTED_VERSIONS = %w[3.8 3.9 4.0 4.1].freeze -appraise 'jekyll-3.7' do - gem 'jekyll', '3.7' +SUPPORTED_VERSIONS.each do |version| + appraise "jekyll-#{version}" do + gem 'jekyll', version + end end diff --git a/Gemfile b/Gemfile index b6a433a..9da476f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,7 @@ gem 'minitest-reporters' gem 'minitest' gem 'pry' gem 'rake' +gem 'rubocop-minitest' +gem 'rubocop-performance' gem 'rubocop' gem 'simplecov', '~> 0.17.1' diff --git a/README.md b/README.md index e85fc30..b7e03c5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # jekyll-toc ![CI](https://github.com/toshimaru/jekyll-toc/workflows/CI/badge.svg) -[![Gem Version](https://badge.fury.io/rb/jekyll-toc.svg)](http://badge.fury.io/rb/jekyll-toc) +[![Gem Version](https://badge.fury.io/rb/jekyll-toc.svg)](https://badge.fury.io/rb/jekyll-toc) [![Code Climate](https://codeclimate.com/github/toshimaru/jekyll-toc/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/jekyll-toc) [![Test Coverage](https://api.codeclimate.com/v1/badges/cd56b207f327603662a1/test_coverage)](https://codeclimate.com/github/toshimaru/jekyll-toc/test_coverage) @@ -9,16 +9,19 @@ - [Installation](#installation) - [Usage](#usage) - - [1. Basic Usage](#1-basic-usage) - - [2. Advanced Usage](#2-advanced-usage) + - [Basic Usage](#basic-usage) + - [Advanced Usage](#advanced-usage) - [Generated HTML](#generated-html) -- [Default Configuration](#default-configuration) - [Customization](#customization) + - [Default Configuration](#default-configuration) - [TOC levels](#toc-levels) + - [Enable TOC by default](#enable-toc-by-default) - [Skip TOC](#skip-toc) - - [Skip TOC Section](#skip-toc-section) + - [Skip TOC Sectionally](#skip-toc-sectionally) - [CSS Styling](#css-styling) - [Custom CSS Class](#custom-css-class) + - [Using Unordered/Ordered lists](#using-unorderedordered-lists) +- [Alternative Tools](#alternative-tools) ## Installation @@ -50,7 +53,7 @@ toc: true There are three Liquid filters, which can be applied to HTML content, e.g. the Liquid variable `content` available in Jekyll's templates. -### 1. Basic Usage +### Basic Usage #### `toc` filter @@ -62,11 +65,11 @@ Add the `toc` filter to your site's `{{ content }}` (e.g. `_layouts/post.html`). This filter places the TOC directly above the content. -### 2. Advanced Usage +### Advanced Usage If you'd like separated TOC and content, you can use `{% toc %}` tag (or `toc_only` filter) and `inject_anchors` filter. -#### `{% toc %}` tag +#### `{% toc %}` tag / `toc_only` filter Generates the TOC itself as described [below](#generated-html). Mostly useful in cases where the TOC should _not_ be placed immediately @@ -85,7 +88,8 @@ above the content but at some other place of the page, i.e. an aside. :warning: **`{% toc %}` Tag Limitation** -`{% toc %}` can be available only in [Jekyll Posts](https://jekyllrb.com/docs/step-by-step/08-blogging/) and [Jekyll Collections](https://jekyllrb.com/docs/collections/). If you'd like to use `{% toc %}` except posts or collections, please use `toc_only` filter as described below. +`{% toc %}` works only for [Jekyll Posts](https://jekyllrb.com/docs/step-by-step/08-blogging/) and [Jekyll Collections](https://jekyllrb.com/docs/collections/). +If you'd like to use `{% toc %}` except posts or collections, please use `toc_only` filter as described below. ```html
@@ -112,9 +116,25 @@ They are of the form: This is only useful when the TOC itself should be placed at some other location with the `toc_only` filter. +## Testing and Linting + +To run the tests you `rake`. First install gem packages local and run `rake test`. + +Run tests + +```shell +bundle exec rake test +``` + +Run liniting with rubocop + +```shell +bundle exec rubocop +``` + ## Generated HTML -jekyll-toc generates an unordered list. The HTML output is as follows. +jekyll-toc generates an unordered list by default. The HTML output is as follows. ```html