bhook 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +27 -0
- data/Rakefile +13 -0
- data/bin/bhook +11 -0
- data/lib/bhook/args_parser.rb +55 -0
- data/lib/bhook/converter/html.rb +51 -0
- data/lib/bhook/directory.rb +62 -0
- data/lib/bhook/md_file.rb +50 -0
- data/lib/bhook/theme/_after_h1.erb +7 -0
- data/lib/bhook/theme/page.erb +71 -0
- data/lib/bhook/version.rb +6 -0
- data/lib/bhook/workspace.rb +45 -0
- data/lib/bhook.rb +22 -0
- data/sorbet/config +3 -0
- data/sorbet/rbi/gems/ast.rbi +49 -0
- data/sorbet/rbi/gems/bhook.rbi +15 -0
- data/sorbet/rbi/gems/git.rbi +531 -0
- data/sorbet/rbi/gems/kramdown.rbi +255 -0
- data/sorbet/rbi/gems/listen.rbi +304 -0
- data/sorbet/rbi/gems/parallel.rbi +83 -0
- data/sorbet/rbi/gems/parser.rbi +1440 -0
- data/sorbet/rbi/gems/rainbow.rbi +122 -0
- data/sorbet/rbi/gems/rake.rbi +644 -0
- data/sorbet/rbi/gems/rchardet.rbi +181 -0
- data/sorbet/rbi/gems/regexp_parser.rbi +929 -0
- data/sorbet/rbi/gems/rexml.rbi +599 -0
- data/sorbet/rbi/gems/rspec-core.rbi +1898 -0
- data/sorbet/rbi/gems/rspec-expectations.rbi +1171 -0
- data/sorbet/rbi/gems/rspec-mocks.rbi +1094 -0
- data/sorbet/rbi/gems/rspec-support.rbi +280 -0
- data/sorbet/rbi/gems/rspec.rbi +15 -0
- data/sorbet/rbi/gems/rubocop-ast.rbi +1385 -0
- data/sorbet/rbi/gems/rubocop-rake.rbi +85 -0
- data/sorbet/rbi/gems/rubocop-rspec.rbi +1044 -0
- data/sorbet/rbi/gems/rubocop.rbi +8593 -0
- data/sorbet/rbi/gems/ruby-progressbar.rbi +304 -0
- data/sorbet/rbi/gems/unicode-display_width.rbi +20 -0
- data/sorbet/rbi/hidden-definitions/errors.txt +4944 -0
- data/sorbet/rbi/hidden-definitions/hidden.rbi +10044 -0
- data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +276 -0
- data/sorbet/rbi/sorbet-typed/lib/rake/all/rake.rbi +645 -0
- data/sorbet/rbi/sorbet-typed/lib/rspec-core/all/rspec-core.rbi +24 -0
- data/sorbet/rbi/sorbet-typed/lib/rubocop/>=1.8/rubocop.rbi +12 -0
- data/sorbet/rbi/todo.rbi +7 -0
- metadata +235 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 004e13098155733cadddffee89a4085b4c7dc78fafa28de82b4266cd86c95eab
|
4
|
+
data.tar.gz: aa6a9773afd270b0d63f230142b3ac86a3f90719b6602a7ae26cee712b36ffff
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 757d1a3bcabc583116a5d02b41beb198f19dc891cb3ce948482614bd77f7a18ae5082ee5e3e535ee777739b030d25887ae7d1b8c3ccaa566943035e7ca51cd2e
|
7
|
+
data.tar.gz: e41a385694dabe87e08d21fa51a5d0091028b7317d81f48b107e2a73797d8b9eacc1eafdf52a42715149706ecbe30c604a1aab7f3cd39e3147a767a4fc6ddb85
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.5
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bhook (0.1.0)
|
5
|
+
git (~> 1.10)
|
6
|
+
kramdown (~> 2.3)
|
7
|
+
listen (~> 3.7)
|
8
|
+
sorbet-runtime (~> 0.5)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
ast (2.4.2)
|
14
|
+
diff-lcs (1.5.0)
|
15
|
+
ffi (1.15.5)
|
16
|
+
git (1.10.2)
|
17
|
+
rchardet (~> 1.8)
|
18
|
+
kramdown (2.3.1)
|
19
|
+
rexml
|
20
|
+
listen (3.7.1)
|
21
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
22
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
23
|
+
parallel (1.21.0)
|
24
|
+
parser (3.1.0.0)
|
25
|
+
ast (~> 2.4.1)
|
26
|
+
rainbow (3.1.1)
|
27
|
+
rake (13.0.6)
|
28
|
+
rb-fsevent (0.11.1)
|
29
|
+
rb-inotify (0.10.1)
|
30
|
+
ffi (~> 1.0)
|
31
|
+
rchardet (1.8.0)
|
32
|
+
regexp_parser (2.2.0)
|
33
|
+
rexml (3.2.5)
|
34
|
+
rspec (3.11.0)
|
35
|
+
rspec-core (~> 3.11.0)
|
36
|
+
rspec-expectations (~> 3.11.0)
|
37
|
+
rspec-mocks (~> 3.11.0)
|
38
|
+
rspec-core (3.11.0)
|
39
|
+
rspec-support (~> 3.11.0)
|
40
|
+
rspec-expectations (3.11.0)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.11.0)
|
43
|
+
rspec-mocks (3.11.0)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.11.0)
|
46
|
+
rspec-support (3.11.0)
|
47
|
+
rubocop (1.25.1)
|
48
|
+
parallel (~> 1.10)
|
49
|
+
parser (>= 3.1.0.0)
|
50
|
+
rainbow (>= 2.2.2, < 4.0)
|
51
|
+
regexp_parser (>= 1.8, < 3.0)
|
52
|
+
rexml
|
53
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
54
|
+
ruby-progressbar (~> 1.7)
|
55
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
56
|
+
rubocop-ast (1.15.1)
|
57
|
+
parser (>= 3.0.1.1)
|
58
|
+
rubocop-rake (0.6.0)
|
59
|
+
rubocop (~> 1.0)
|
60
|
+
rubocop-rspec (2.8.0)
|
61
|
+
rubocop (~> 1.19)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
sorbet (0.5.9626)
|
64
|
+
sorbet-static (= 0.5.9626)
|
65
|
+
sorbet-runtime (0.5.9626)
|
66
|
+
sorbet-static (0.5.9626-universal-darwin-21)
|
67
|
+
unicode-display_width (2.1.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
arm64-darwin-21
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
bhook!
|
74
|
+
rake (~> 13.0)
|
75
|
+
rspec (~> 3.1)
|
76
|
+
rubocop (~> 1.0)
|
77
|
+
rubocop-rake (~> 0.6)
|
78
|
+
rubocop-rspec (~> 2.8)
|
79
|
+
sorbet (~> 0.5)
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.3.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Sidu Ponnappa
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Bhook
|
2
|
+
|
3
|
+
Bhook is a static bliki generator.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it yourself as:
|
8
|
+
|
9
|
+
$ gem install bhook
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
TODO: Write usage instructions here
|
14
|
+
|
15
|
+
## Development
|
16
|
+
|
17
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
18
|
+
|
19
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
20
|
+
|
21
|
+
## Contributing
|
22
|
+
|
23
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bhook.
|
24
|
+
|
25
|
+
## License
|
26
|
+
|
27
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/bhook
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'bhook'
|
6
|
+
|
7
|
+
puts "Bhook version #{Bhook::VERSION}"
|
8
|
+
args = Bhook::ArgsParser.new(ARGV).parse!
|
9
|
+
workspace = Bhook::Workspace.new(args.source, args.output)
|
10
|
+
|
11
|
+
args.watch ? workspace.watch! : workspace.process!
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Bhook
|
2
|
+
class ArgsParser
|
3
|
+
Options = Struct.new(:source, :output, :watch)
|
4
|
+
|
5
|
+
def initialize(argv)
|
6
|
+
@args = Options.new(nil, nil, false)
|
7
|
+
@argv = argv.clone
|
8
|
+
@opt_parser = build_opt_parser
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse!
|
12
|
+
begin
|
13
|
+
@opt_parser.parse!(@argv)
|
14
|
+
rescue OptionParser::InvalidOption => e
|
15
|
+
puts
|
16
|
+
puts "Error! #{e.message}"
|
17
|
+
puts
|
18
|
+
end
|
19
|
+
|
20
|
+
if !@argv.empty? || (!@args.source || !@args.output)
|
21
|
+
puts @opt_parser
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
@args
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def build_opt_parser
|
29
|
+
OptionParser.new do |opts|
|
30
|
+
opts.banner = "Usage: bhook --source /source/path --output /output/path"
|
31
|
+
|
32
|
+
opts.on("-sSOURCE", "--source=SOURCE",
|
33
|
+
String, "Path to version controlled directory containing source md files") do |s|
|
34
|
+
@args.source = s
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on("-oOUTPUT", "--output=OUTPUT",
|
38
|
+
String, "Path to directory where output files are to be generated") do |o|
|
39
|
+
@args.output = o
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on("-w", "--watch",
|
43
|
+
FalseClass,
|
44
|
+
"Continuously watch the source directory for changes and generate output") do |w|
|
45
|
+
@args.watch = true
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("-h", "--help", "Prints this help") do
|
49
|
+
puts opts
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Bhook
|
5
|
+
module Converter
|
6
|
+
class Html < ::Kramdown::Converter::Html
|
7
|
+
extend T::Sig
|
8
|
+
|
9
|
+
sig { params(root: Kramdown::Element, options: T::Hash[Symbol, T.untyped]).void }
|
10
|
+
def initialize(root, options)
|
11
|
+
@options = T.let({}, T::Hash[Symbol, T.untyped])
|
12
|
+
super(root, options)
|
13
|
+
end
|
14
|
+
|
15
|
+
sig { params(el: Kramdown::Element, indent: Integer).returns(String) }
|
16
|
+
def convert_a(el, indent)
|
17
|
+
href_path = el.attr['href']
|
18
|
+
if valid_relative_md_link?(href_path)
|
19
|
+
puts "Found link: #{href_path}"
|
20
|
+
el.attr['href'].gsub!(/\.md/, '.html')
|
21
|
+
end
|
22
|
+
super(el, indent)
|
23
|
+
end
|
24
|
+
|
25
|
+
sig { params(el: Kramdown::Element, indent: Integer).returns(String) }
|
26
|
+
def convert_header(el, indent)
|
27
|
+
header = super(el, indent)
|
28
|
+
after_h1_strategy = @options[:after_h1_strategy]
|
29
|
+
h1_callback = @options[:h1_callback]
|
30
|
+
src_title = el.options[:raw_text]
|
31
|
+
after_h1_html = after_h1_strategy.call(binding)
|
32
|
+
|
33
|
+
level = output_header_level(el.options[:level])
|
34
|
+
if level == 1
|
35
|
+
h1_callback.call(src_title)
|
36
|
+
"#{header}#{' ' * indent}#{after_h1_html}"
|
37
|
+
else
|
38
|
+
header
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
sig { params(href_path: String).returns(T::Boolean) }
|
45
|
+
def valid_relative_md_link?(href_path)
|
46
|
+
(href_path.end_with?('.md') || href_path.include?('.md#')) &&
|
47
|
+
Pathname.new(href_path).relative?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# typed: true
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Bhook
|
5
|
+
class Directory
|
6
|
+
GIT_DIR = '.git'
|
7
|
+
MD_EXT = '.md'
|
8
|
+
|
9
|
+
attr_reader :sub_dirs, :md_files
|
10
|
+
|
11
|
+
def initialize(src_path, git = nil)
|
12
|
+
@src_path = src_path
|
13
|
+
@git = git
|
14
|
+
@sub_dirs = []
|
15
|
+
@md_files = []
|
16
|
+
build_next_level_nodes
|
17
|
+
end
|
18
|
+
|
19
|
+
def root_dir_for_a_commit?
|
20
|
+
!@git
|
21
|
+
end
|
22
|
+
|
23
|
+
def write!(out_path)
|
24
|
+
dir_path = if root_dir_for_a_commit?
|
25
|
+
out_path
|
26
|
+
else
|
27
|
+
File.join(out_path, @src_path.basename)
|
28
|
+
end
|
29
|
+
|
30
|
+
FileUtils.mkdir_p(dir_path, verbose: true)
|
31
|
+
@sub_dirs.each { |dir| dir.write!(dir_path) }
|
32
|
+
@md_files.each { |file| file.write!(dir_path) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def all_md_files
|
36
|
+
@md_files + @sub_dirs.map(&:all_md_files).flatten
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_s
|
40
|
+
@src_path.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def build_next_level_nodes
|
46
|
+
if root_dir_for_a_commit?
|
47
|
+
@git = Git.open(@src_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
@sub_dirs = @src_path.children.map do |child|
|
51
|
+
if child.directory? && child.basename.to_s != GIT_DIR
|
52
|
+
Directory.new(child, @git)
|
53
|
+
end
|
54
|
+
end.compact
|
55
|
+
@md_files = @src_path.children.select do |child|
|
56
|
+
!child.directory? && child.extname == MD_EXT
|
57
|
+
end.map do |child|
|
58
|
+
MdFile.new(child, @git)
|
59
|
+
end.compact
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Bhook
|
5
|
+
class MdFile
|
6
|
+
extend T::Sig
|
7
|
+
PAGE_TEMPLATE = File.read(File.join(File.dirname(__FILE__), 'theme', 'page.erb'))
|
8
|
+
AFTER_H1_TEMPLATE = File.read(File.join(File.dirname(__FILE__), 'theme', '_after_h1.erb'))
|
9
|
+
|
10
|
+
def initialize(src_file_path, git)
|
11
|
+
@md = T.let(File.read(src_file_path), String)
|
12
|
+
@src_file_path = src_file_path.expand_path
|
13
|
+
file_meta_data = git.lib.send(:command, 'log',
|
14
|
+
'-n 1',
|
15
|
+
'--pretty=format:%ad|%h',
|
16
|
+
'--date=short',
|
17
|
+
'--',
|
18
|
+
@src_file_path)
|
19
|
+
@src_file_date, @src_file_sha = file_meta_data.split('|')
|
20
|
+
end
|
21
|
+
|
22
|
+
sig { returns(Pathname) }
|
23
|
+
attr_reader :src_file_path
|
24
|
+
|
25
|
+
sig { params(out_path: String).void }
|
26
|
+
def write!(out_path)
|
27
|
+
out_file_name = File.basename(@src_file_path).gsub(/\.md$/, '.html')
|
28
|
+
out_file_path = File.join(out_path, out_file_name)
|
29
|
+
src_file_sha = @src_file_sha
|
30
|
+
src_file_date = @src_file_date
|
31
|
+
src_title = ''
|
32
|
+
puts "Parsing: #{@src_file_sha} #{out_file_path}"
|
33
|
+
after_h1_strategy = ->(binding_instance) { ERB.new(AFTER_H1_TEMPLATE, trim_mode: '-').result(binding_instance) }
|
34
|
+
|
35
|
+
doc = Kramdown::Document.new(@md)
|
36
|
+
output, warnings = Converter::Html.convert(doc.root, doc.options.merge(
|
37
|
+
after_h1_strategy: after_h1_strategy,
|
38
|
+
h1_callback: ->(str) { src_title = str }
|
39
|
+
))
|
40
|
+
rendered_page = ERB.new(PAGE_TEMPLATE, trim_mode: '-').result(binding)
|
41
|
+
puts "Writing: #{@src_file_sha} #{out_file_path}"
|
42
|
+
File.write(out_file_path, rendered_page)
|
43
|
+
end
|
44
|
+
|
45
|
+
sig { returns(String) }
|
46
|
+
def to_s
|
47
|
+
@src_file_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<div class="after-h1">
|
2
|
+
<a class="twitter-share-button"
|
3
|
+
href="https://twitter.com/intent/tweet?text=<%= CGI.escape(src_title) -%>&via=ponnappa">Tweet</a>
|
4
|
+
<a class="twitter-follow-button" href="https://twitter.com/ponnappa">Follow @ponnappa</a>
|
5
|
+
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
6
|
+
</div>
|
7
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
8
|
+
<link href='https://fonts.googleapis.com/css?family=Fira+Sans' rel='stylesheet' type='text/css'>
|
9
|
+
|
10
|
+
<!-- Bootstrap -->
|
11
|
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
12
|
+
<style>
|
13
|
+
body {
|
14
|
+
font-family: 'Fira Sans', sans-serif;
|
15
|
+
color: #000000;
|
16
|
+
}
|
17
|
+
|
18
|
+
h2, h5 {
|
19
|
+
margin-bottom: 0.5em;
|
20
|
+
}
|
21
|
+
|
22
|
+
.after-h1 {
|
23
|
+
border-bottom: 1px solid #bbbbbb;
|
24
|
+
margin-bottom: 1.5em;
|
25
|
+
}
|
26
|
+
|
27
|
+
.footer {
|
28
|
+
margin: 0.5em 0 1.5em 0;
|
29
|
+
}
|
30
|
+
|
31
|
+
table {
|
32
|
+
margin: 0.5em 0 0.5em 0.5em;
|
33
|
+
}
|
34
|
+
|
35
|
+
table thead tr {
|
36
|
+
background: #eeeeee;
|
37
|
+
}
|
38
|
+
|
39
|
+
table td, table th {
|
40
|
+
padding: 0.1em 1em 0.1em 1em;
|
41
|
+
border: 1px solid #bbbbbb;
|
42
|
+
}
|
43
|
+
</style>
|
44
|
+
<title><%= src_title -%></title>
|
45
|
+
</head>
|
46
|
+
<body>
|
47
|
+
<div class="body container">
|
48
|
+
<div class="content row justify-content-center">
|
49
|
+
<div class="col-10">
|
50
|
+
<%= output %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
<div class="footer d-flex justify-content-center">
|
54
|
+
<div>
|
55
|
+
v. <%= src_file_sha -%>, <%= src_file_date -%> © <a href="https://sidu.in">Sidu Ponnappa</a>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
<script type='text/javascript'>
|
60
|
+
var _gaq = _gaq || [];
|
61
|
+
_gaq.push(['_setAccount', 'UA-24685691-1']);
|
62
|
+
_gaq.push(['_trackPageview']);
|
63
|
+
|
64
|
+
(function() {
|
65
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
66
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
67
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
68
|
+
})();
|
69
|
+
</script>
|
70
|
+
</body>
|
71
|
+
</html>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Bhook
|
5
|
+
class Workspace
|
6
|
+
extend T::Sig
|
7
|
+
|
8
|
+
sig { params(src_path: String, out_path: String).void }
|
9
|
+
def initialize(src_path, out_path)
|
10
|
+
@src_path = src_path
|
11
|
+
@out_path = out_path
|
12
|
+
end
|
13
|
+
|
14
|
+
sig { void }
|
15
|
+
def process!
|
16
|
+
root = root_dir
|
17
|
+
root.write!(@out_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
sig { void }
|
21
|
+
def watch!
|
22
|
+
process!
|
23
|
+
puts
|
24
|
+
puts "Watching #{@src_path} for changes..."
|
25
|
+
listener = Listen.to(@src_path, File.join(@src_path, '.git')) do |_modified, _added, _removed|
|
26
|
+
process!
|
27
|
+
puts "-----\n"
|
28
|
+
end
|
29
|
+
listener.start
|
30
|
+
sleep
|
31
|
+
end
|
32
|
+
|
33
|
+
sig { returns(T::Array[MdFile]) }
|
34
|
+
def all_md_files
|
35
|
+
root_dir.all_md_files
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
sig { returns(Bhook::Directory) }
|
41
|
+
def root_dir
|
42
|
+
Directory.new(Pathname.new(@src_path))
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/bhook.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'set'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'pathname'
|
7
|
+
require 'erb'
|
8
|
+
require 'optparse'
|
9
|
+
require 'sorbet-runtime'
|
10
|
+
require 'git'
|
11
|
+
require 'kramdown'
|
12
|
+
require 'listen'
|
13
|
+
require_relative 'bhook/version'
|
14
|
+
require_relative 'bhook/args_parser'
|
15
|
+
require_relative 'bhook/converter/html'
|
16
|
+
require_relative 'bhook/directory'
|
17
|
+
require_relative 'bhook/md_file'
|
18
|
+
require_relative 'bhook/workspace'
|
19
|
+
|
20
|
+
module Bhook
|
21
|
+
class Error < StandardError; end
|
22
|
+
end
|
data/sorbet/config
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
|
2
|
+
# srb rbi gems
|
3
|
+
|
4
|
+
# typed: strict
|
5
|
+
#
|
6
|
+
# If you would like to make changes to this file, great! Please create the gem's shim here:
|
7
|
+
#
|
8
|
+
# https://github.com/sorbet/sorbet-typed/new/master?filename=lib/ast/all/ast.rbi
|
9
|
+
#
|
10
|
+
# ast-2.4.2
|
11
|
+
|
12
|
+
module AST
|
13
|
+
end
|
14
|
+
class AST::Node
|
15
|
+
def +(array); end
|
16
|
+
def <<(element); end
|
17
|
+
def ==(other); end
|
18
|
+
def append(element); end
|
19
|
+
def assign_properties(properties); end
|
20
|
+
def children; end
|
21
|
+
def clone; end
|
22
|
+
def concat(array); end
|
23
|
+
def deconstruct; end
|
24
|
+
def dup; end
|
25
|
+
def eql?(other); end
|
26
|
+
def fancy_type; end
|
27
|
+
def hash; end
|
28
|
+
def initialize(type, children = nil, properties = nil); end
|
29
|
+
def inspect(indent = nil); end
|
30
|
+
def original_dup; end
|
31
|
+
def to_a; end
|
32
|
+
def to_ast; end
|
33
|
+
def to_s(indent = nil); end
|
34
|
+
def to_sexp(indent = nil); end
|
35
|
+
def to_sexp_array; end
|
36
|
+
def type; end
|
37
|
+
def updated(type = nil, children = nil, properties = nil); end
|
38
|
+
end
|
39
|
+
class AST::Processor
|
40
|
+
include AST::Processor::Mixin
|
41
|
+
end
|
42
|
+
module AST::Processor::Mixin
|
43
|
+
def handler_missing(node); end
|
44
|
+
def process(node); end
|
45
|
+
def process_all(nodes); end
|
46
|
+
end
|
47
|
+
module AST::Sexp
|
48
|
+
def s(type, *children); end
|
49
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
|
2
|
+
# srb rbi gems
|
3
|
+
|
4
|
+
# typed: strict
|
5
|
+
#
|
6
|
+
# If you would like to make changes to this file, great! Please create the gem's shim here:
|
7
|
+
#
|
8
|
+
# https://github.com/sorbet/sorbet-typed/new/master?filename=lib/bhook/all/bhook.rbi
|
9
|
+
#
|
10
|
+
# bhook-0.1.0
|
11
|
+
|
12
|
+
module Bhook
|
13
|
+
end
|
14
|
+
class Bhook::Error < StandardError
|
15
|
+
end
|