mdtoc 0.3.0 → 0.3.1

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +112 -0
  4. data/bin/setup +37 -0
  5. data/lib/mdtoc/version.rb +1 -1
  6. metadata +4 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c01cef42824ceeae479dc235cbe2c7565c2d6ef045074c8d55b34a821ee719d
4
- data.tar.gz: c25c67f2bf841dd9e1e3bb6a632035693299e7a53367b5dd255ecfbc125adab2
3
+ metadata.gz: dd651a744c265508fe1b78eae797f688f83a417d0710ed70fdff838a05e8e2b9
4
+ data.tar.gz: bfd727b632d7d5076ef17e309e1a2715f5de971a313e74190b9e1facadcade7a
5
5
  SHA512:
6
- metadata.gz: 603bec1ab105a7438bb2d0c2e4fb0c7eead9c63b57bfe33ca9354b05458d435805ce614cd11549527749092f2cffdc1289691a177b3c86161bac714f877c3eb7
7
- data.tar.gz: 6bb0b63c4217f899d2277ba35baf7966cd97219e88f111c7a842b535108c698ac0260c0cc1f2c7e24858c9464a9cac333ea1fa4a7244104b051ba3184ed326bd
6
+ metadata.gz: 2282ca2fb424b8dc093c856c83d4c13373bc10206d0a0f6c80c05c83329d057d1b3ce2c8dcf1a68ca2a7f303df22b95fccf3a71c1ead0f4c4e6da8049477005e
7
+ data.tar.gz: 714e58db5f76da82a910398f308698ed049bd56c9632b85d7131465d04d247ac57a0648b718f28b37dfa86be275535b0aee31a0cf5362a4f86523ced23037151
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 andornaut
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # mdtoc - Markdown Table of Contents
2
+
3
+ Read Markdown files and output a table of contents.
4
+
5
+ ## Installation
6
+
7
+ Requirements:
8
+
9
+ * [Ruby](https://www.ruby-lang.org/en/) (see [.ruby-version](./.ruby-version))
10
+
11
+ ```bash
12
+ gem install mdtoc
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ $ mdtoc --help
19
+ Usage: mdtoc [options] files or directories...
20
+ -h, --help Show this message
21
+ -o, --output PATH Update a table of contents in the file at PATH
22
+ -a, --[no-]append Append to the --output file if a <!-- mdtoc --> tag isn't found
23
+ -c, --[no-]create Create the --output file if it does not exist
24
+ ```
25
+
26
+ 1. Add a `<!-- mdtoc -->` tag to a Markdown file.
27
+
28
+ ```bash
29
+ echo '<!-- mdtoc -->' >> README.md
30
+ ```
31
+
32
+ 2. Run `mdtoc` and specify input files or directories (eg. the "test/samples" directory) and an output file (eg. "README.md").
33
+
34
+ ```bash
35
+ mdtoc -aco README.md test/samples
36
+ ```
37
+
38
+ ## Example Rakefile
39
+
40
+ Create a `Rakefile` with the contents below, then run
41
+ [`rake`](https://github.com/ruby/rake) to:
42
+
43
+ * `git pullgem push pkg/mdtoc-0.2.0.gem`
44
+ * `git add` any *.md files
45
+ * Run `mdtoc` to update the generated table of contents in the ./README.md file
46
+ * Git commit and push any changes
47
+
48
+ ```ruby
49
+ task default: %w[mdtoc]
50
+
51
+ desc 'Update Markdown table of contents and push changes to the git repository'
52
+ task :mdtoc do
53
+ command = <<~CMD
54
+ set -e
55
+ if [ -n "$(git diff --name-only --diff-filter=U)" ]; then
56
+ echo 'Error: conflicts exist' >&2
57
+ exit 1
58
+ fi
59
+ mdtoc --append --create --output README.md docs/
60
+ git add *.md **/*.md
61
+ git commit -qm 'Update TOC' || true
62
+ git pull
63
+ git push
64
+ CMD
65
+ sh command, verbose: false do |ok, status|
66
+ unless ok
67
+ fail "Failed with status: #{status.exitstatus}"
68
+ end
69
+ end
70
+ end
71
+ ```
72
+
73
+ See [andornaut/til](https://github.com/andornaut/til/blob/master/Rakefile) for an example.
74
+
75
+ ## Development
76
+
77
+ ### Setup
78
+
79
+ Requirements:
80
+
81
+ * [Bundler](https://bundler.io/)
82
+ * [chruby](https://github.com/postmodern/chruby) (recommended)
83
+
84
+ ```bash
85
+ # Setup development environment
86
+ bin/setup
87
+ ```
88
+
89
+ ### Tasks
90
+
91
+ ```bash
92
+ # List rake tasks
93
+ $ rake -T
94
+ rake build # Build gem into the pkg directory
95
+ rake default # Run the build, rubocop, sorbet and test tasks
96
+ rake install # Build and install gem into system gems
97
+ rake rubocop # Run RuboCop
98
+ rake sorbet # Run the Sorbet type checker
99
+ rake test # Run tests
100
+ ```
101
+ # Run mdtoc with test inputs
102
+ $ ruby -Ilib bin/mdtoc test/samples
103
+
104
+ # Run mdtoc with test inputs, and write to a newly created output file
105
+ $ f=$(mktemp) && ruby -Ilib bin/mdtoc -aco ${f} test/samples ; cat ${f}
106
+ ```
107
+
108
+ ### Publishing
109
+
110
+ ```bash
111
+ rake release
112
+ ```
data/bin/setup ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'fileutils'
5
+
6
+ # path to your application root.
7
+ APP_ROOT = File.expand_path('..', __dir__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("
11
+ == Command #{args} failed ==")
12
+ end
13
+
14
+ FileUtils.chdir APP_ROOT do
15
+ # This script is a way to set up a development environment or update your current one.
16
+ # You can run it with `bin/setup`.
17
+
18
+ puts '== Installing dependencies =='
19
+ system! 'gem install bundler --conservative'
20
+ system('bundle check') || system!('bundle install')
21
+
22
+ puts "
23
+ == Removing old RBIs =="
24
+ FileUtils.rm_rf('sorbet/rbi/gems')
25
+ FileUtils.rm_rf('sorbet/rbi/todo.rbi')
26
+
27
+ puts "
28
+ == Generating RBIs =="
29
+ system! 'bundle exec tapioca gems'
30
+
31
+ puts "
32
+ == Initializing Sorbet =="
33
+ system! 'bundle exec srb tc'
34
+
35
+ puts "
36
+ == Setup complete! =="
37
+ end
data/lib/mdtoc/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Mdtoc
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdtoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - andornaut
@@ -227,7 +227,10 @@ executables:
227
227
  extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
+ - LICENSE
231
+ - README.md
230
232
  - bin/mdtoc
233
+ - bin/setup
231
234
  - lib/mdtoc.rb
232
235
  - lib/mdtoc/cli.rb
233
236
  - lib/mdtoc/markdown/fragment_generator.rb