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..1f8aa18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,29 +1,31 @@ name: CI -on: [push] + +on: + push: + branches: + - main + pull_request: + jobs: - build: + test: strategy: matrix: - ruby: [2.4, 2.5, 2.6, 2.7] + ruby: ['2.6', '2.7', '3.0', '3.1', '3.2'] gemfile: - - gemfiles/jekyll_4.0.gemfile - - gemfiles/jekyll_3.8.gemfile - - gemfiles/jekyll_3.7.gemfile - exclude: - - ruby: 2.4 - gemfile: gemfiles/jekyll_4.0.gemfile + - gemfiles/jekyll_3.9.gemfile + - gemfiles/jekyll_4.0.gemfile + - gemfiles/jekyll_4.1.gemfile + - gemfiles/jekyll_4.2.gemfile + - gemfiles/jekyll_4.3.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 - with: - ruby-version: ${{ matrix.ruby }} - - name: bundle install - run: | - gem install bundler - bundle install --jobs 4 --retry 3 - - name: Run Test - run: bundle exec rake + - uses: actions/checkout@v3 + - name: Set up Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run Test + run: bundle exec rake diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4d676d7..3ef8da8 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,21 +1,22 @@ name: Coverage -on: [push] + +on: + push: + branches: + - main + pull_request: + jobs: - build: - strategy: - matrix: - ruby: [2.6] + coverage: runs-on: ubuntu-latest - name: coverage steps: - - uses: actions/checkout@v2 - - name: Set up Ruby ${{ matrix.ruby }} - uses: eregon/use-ruby-action@master + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/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 + ruby-version: 3.2 + bundler-cache: true + - uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07 with: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 75338b2..a02a0a5 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -1,19 +1,20 @@ name: RuboCop -on: [push] + +on: + push: + branches: + - main + pull_request: + jobs: - build: - strategy: - matrix: - ruby: [2.6] + rubocop: runs-on: ubuntu-latest - name: rubocop steps: - - uses: actions/checkout@v2 - - name: Set up Ruby ${{ matrix.ruby }} - uses: eregon/use-ruby-action@master + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby }} - - name: bundle install - run: bundle install --jobs 4 --retry 3 + ruby-version: 3.2 + bundler-cache: true - name: Run RuboCop run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index 523762b..c753fcc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,34 +1,43 @@ AllCops: - TargetRubyVersion: 2.4 + TargetRubyVersion: 2.6 + 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 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 diff --git a/Appraisals b/Appraisals index b84be41..5f93642 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.9 4.0 4.1 4.2 4.3].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..2d2687b 100644 --- a/Gemfile +++ b/Gemfile @@ -7,5 +7,8 @@ gem 'minitest-reporters' gem 'minitest' gem 'pry' gem 'rake' +gem 'rubocop-minitest' +gem 'rubocop-performance' +gem 'rubocop-rake' gem 'rubocop' -gem 'simplecov', '~> 0.17.1' +gem 'simplecov', '~> 0.22.0' diff --git a/LICENSE.md b/LICENSE.md index 5763175..4b99c06 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Toshimaru +Copyright (c) 2020-2021 Toshimaru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index e85fc30..43012cb 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) + - [Custom CSS Class and ID](#custom-css-class-and-id) + - [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
@@ -114,10 +118,10 @@ location with the `toc_only` filter. ## 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 -